diff --git a/libwccl/ops/functions/bool/iteration.cpp b/libwccl/ops/functions/bool/iteration.cpp index cb2034a70c7a8f159f34b0bd5541a04241e4b7c1..9a6982a177dda80cdcd6c2d70f52702c6a4617ef 100644 --- a/libwccl/ops/functions/bool/iteration.cpp +++ b/libwccl/ops/functions/bool/iteration.cpp @@ -25,11 +25,8 @@ std::ostream& Iteration::write_to(std::ostream& os) const Iteration::BaseRetValPtr Iteration::apply_internal(const FunExecContext& context) const { - // Set iteration variable to Nowhere - // Should be overridden if succeeded const boost::shared_ptr<Position>& iter_var = context.variables()->get_fast(iter_var_acc_); - iter_var->set_value(Position::Nowhere); const SentenceContext& sc = context.sentence_context(); // Proceed only if range extremes are not "nowhere". const boost::shared_ptr<const Position>& range_left = @@ -48,7 +45,7 @@ Iteration::BaseRetValPtr Iteration::apply_internal(const FunExecContext& context } } } - // Failure. Make sure iteration variable points Nowhere and return False + // Failure. Set iteration variable to Nowhere and return False iter_var->set_value(Position::Nowhere); return Predicate::False(context); } diff --git a/tests/data/crossing.ccl b/tests/data/crossing.ccl index abae649250d598a801cae0029091c56d28ca2709..23dd82df465d8b57d48bc1fa9cdf377796f6cf72 100644 --- a/tests/data/crossing.ccl +++ b/tests/data/crossing.ccl @@ -36,3 +36,58 @@ only(1, 0, $It, False) True It=nowhere --- +and(setvar($It,2), rlook(0, 1, $It, True)) + +True +It=0 +--- +and(setvar($It,2), llook(1, 0, $It, True)) + +True +It=1 +--- +and(setvar($It,2), rlook(1, 0, $It, True)) + +False +It=nowhere +--- +and(setvar($It,2), llook(0, 1, $It, True)) + +False +It=nowhere +--- +and(setvar($It,2), only(0, 1, $It, True)) + +True +It=1 +--- +and(setvar($It,2), only(1, 0, $It, True)) + +True +It=2 +--- +and(setvar($It,2), only(1, 0, $It, False)) + +True +It=2 +--- +and(setvar($It,2), only(0, 1, $It, False)) + +False +It=nowhere +--- +and(setvar($It,6), atleast(0, 3, $It, inside($It), 2)) + +True +It=1 +--- +and(setvar($It,6), atleast(3, 0, $It, inside($It), 2)) + +False +It=nowhere +--- +and(setvar($It,6), atleast(0, 3, $It, inside($It), 7)) + +False +It=nowhere +---