From 82651c7b6e207d1d9737636df492e011d21bdd28 Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(B-4.4.46a)> Date: Fri, 10 Dec 2010 16:48:22 +0100 Subject: [PATCH] Remove check for current position, it should be handled earlier I.E. empty sentence shouldn't be passed anyway and that is what Operator class is checking for. But otherwise, at the level of operator, it can deal with a sentence that has current pos outside of boundaries. --- libwccl/ops/functions/strset/getlemmas.cpp | 2 +- libwccl/ops/functions/strset/getorth.cpp | 2 +- libwccl/ops/functions/tset/getsymbols.cpp | 2 +- tests/getlemmas.cpp | 6 ++++-- tests/getorth.cpp | 6 ++++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libwccl/ops/functions/strset/getlemmas.cpp b/libwccl/ops/functions/strset/getlemmas.cpp index 750b677..a1e9cbe 100644 --- a/libwccl/ops/functions/strset/getlemmas.cpp +++ b/libwccl/ops/functions/strset/getlemmas.cpp @@ -18,7 +18,7 @@ GetLemmas::BaseRetValPtr GetLemmas::apply_internal(const FunExecContext& context { const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context); const SentenceContext& sc = context.sentence_context(); - if(pos->is_outside(sc) || !sc.is_current_inside()) { + if(pos->is_outside(sc)) { return detail::DefaultFunction<StrSet>()->apply(context); } boost::shared_ptr<StrSet> u_set = boost::make_shared<StrSet>(); diff --git a/libwccl/ops/functions/strset/getorth.cpp b/libwccl/ops/functions/strset/getorth.cpp index 666b9f3..0fd96ea 100644 --- a/libwccl/ops/functions/strset/getorth.cpp +++ b/libwccl/ops/functions/strset/getorth.cpp @@ -18,7 +18,7 @@ GetOrth::BaseRetValPtr GetOrth::apply_internal(const FunExecContext& context) co { const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context); const SentenceContext& sc = context.sentence_context(); - if(pos->is_outside(sc) || !sc.is_current_inside()) { + if(pos->is_outside(sc)) { return detail::DefaultFunction<StrSet>()->apply(context); } boost::shared_ptr<StrSet> u_set = boost::make_shared<StrSet>(); diff --git a/libwccl/ops/functions/tset/getsymbols.cpp b/libwccl/ops/functions/tset/getsymbols.cpp index 5137ca2..4e4a376 100644 --- a/libwccl/ops/functions/tset/getsymbols.cpp +++ b/libwccl/ops/functions/tset/getsymbols.cpp @@ -28,7 +28,7 @@ GetSymbols::BaseRetValPtr GetSymbols::apply_internal(const FunExecContext& conte { const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context); const SentenceContext& sc = context.sentence_context(); - if(pos->is_outside(sc) || !sc.is_current_inside()) { + if(pos->is_outside(sc)) { return detail::DefaultFunction<TSet>()->apply(context); } diff --git a/tests/getlemmas.cpp b/tests/getlemmas.cpp index 3c92eb2..568c687 100644 --- a/tests/getlemmas.cpp +++ b/tests/getlemmas.cpp @@ -97,7 +97,7 @@ BOOST_FIXTURE_TEST_CASE(lemmas_begin, LemmasPredFix) sc.advance(); BOOST_CHECK(lemmas.apply(cx)->equals(first_lemmas)); sc.advance(); - BOOST_CHECK(lemmas.apply(cx)->equals(empty_set)); + BOOST_CHECK(lemmas.apply(cx)->equals(first_lemmas)); } BOOST_FIXTURE_TEST_CASE(lemmas_end, LemmasPredFix) @@ -107,7 +107,7 @@ BOOST_FIXTURE_TEST_CASE(lemmas_end, LemmasPredFix) sc.advance(); BOOST_CHECK(lemmas.apply(cx)->equals(second_lemmas)); sc.advance(); - BOOST_CHECK(lemmas.apply(cx)->equals(empty_set)); + BOOST_CHECK(lemmas.apply(cx)->equals(second_lemmas)); } BOOST_FIXTURE_TEST_CASE(lemmas_zero, LemmasPredFix) @@ -137,6 +137,8 @@ BOOST_FIXTURE_TEST_CASE(lemmas_minus_one, LemmasPredFix) sc.advance(); BOOST_CHECK(lemmas.apply(cx)->equals(first_lemmas)); sc.advance(); + BOOST_CHECK(lemmas.apply(cx)->equals(second_lemmas)); + sc.advance(); BOOST_CHECK(lemmas.apply(cx)->equals(empty_set)); } //------ to_string test cases ------- diff --git a/tests/getorth.cpp b/tests/getorth.cpp index 947e9bb..49e2b4a 100644 --- a/tests/getorth.cpp +++ b/tests/getorth.cpp @@ -96,7 +96,7 @@ BOOST_FIXTURE_TEST_CASE(orth_begin, OrthPredFix) sc.advance(); BOOST_CHECK(orth.apply(cx)->equals(first_orth)); sc.advance(); - BOOST_CHECK(orth.apply(cx)->equals(empty_set)); + BOOST_CHECK(orth.apply(cx)->equals(first_orth)); sc.goto_start(); } @@ -107,7 +107,7 @@ BOOST_FIXTURE_TEST_CASE(orth_end, OrthPredFix) sc.advance(); BOOST_CHECK(orth.apply(cx)->equals(second_orth)); sc.advance(); - BOOST_CHECK(orth.apply(cx)->equals(empty_set)); + BOOST_CHECK(orth.apply(cx)->equals(second_orth)); sc.goto_start(); } @@ -140,6 +140,8 @@ BOOST_FIXTURE_TEST_CASE(orth_minus_one, OrthPredFix) sc.advance(); BOOST_CHECK(orth.apply(cx)->equals(first_orth)); sc.advance(); + BOOST_CHECK(orth.apply(cx)->equals(second_orth)); + sc.advance(); BOOST_CHECK(orth.apply(cx)->equals(empty_set)); sc.goto_start(); } -- GitLab