diff --git a/src/nft/operations.cc b/src/nft/operations.cc index 58c54371a..ecedc3caf 100644 --- a/src/nft/operations.cc +++ b/src/nft/operations.cc @@ -1271,7 +1271,7 @@ bool Nft::is_in_lang_by_levels(const std::vector& level_words, const bool if (level == 0 && level_target == 0) { for (Level level_loop{ level }; level_loop < levels.num_of_levels; ++level_loop) { if (next_words_its[level_loop] == track_words_ends[level_loop] || - not symbols_match(*word_symbol_it, *next_words_its[level_loop])) { + not symbols_match(symbol_post_it->symbol, *next_words_its[level_loop])) { jump_failed = true; break; } @@ -1281,7 +1281,7 @@ bool Nft::is_in_lang_by_levels(const std::vector& level_words, const bool for (Level level_loop{ level }; level_loop != level_target; level_loop = levels.next_level_after(level_loop)) { if (next_words_its[level_loop] == track_words_ends[level_loop] || - not symbols_match(*word_symbol_it, *next_words_its[level_loop])) { + not symbols_match(symbol_post_it->symbol, *next_words_its[level_loop])) { jump_failed = true; break; } diff --git a/tests/nft/nft.cc b/tests/nft/nft.cc index 9f2fd5e9a..8edc9eb4f 100644 --- a/tests/nft/nft.cc +++ b/tests/nft/nft.cc @@ -3418,6 +3418,30 @@ TEST_CASE("mata::nft:: create simple automata") { CHECK(!nft.is_in_lang({ 3 })); } +TEST_CASE("ISSUE #613 - mata::nft::nft::is_in_lang()") { + SECTION("DONT_CARE jump") { + Nft nft{ builder::create_sigma_star_nft(2) }; + CHECK(nft.is_in_lang({ 'a', 'b' })); + CHECK(nft.is_in_lang({ 'a', 'a' })); + CHECK(nft.is_in_lang({ 'b', 'a' })); + + Nft nft3{ builder::create_sigma_star_nft(3) }; + CHECK(nft3.is_in_lang({ 'a', 'b', 'c' })); + } + + SECTION("DONT_CARE in the word") { + Nft nft{ Nft::with_levels({ 2, { 0 } }, 1, { 0 }, { 0 }) }; + nft.delta.add(0, 'x', 0); + + CHECK(nft.is_in_lang({ 'x', 'x' })); + CHECK(nft.is_in_lang({ DONT_CARE, 'x' })); + CHECK(nft.is_in_lang({ 'x', DONT_CARE })); + CHECK(!nft.is_in_lang({ DONT_CARE, 'b' })); + CHECK(!nft.is_in_lang({ 'b', DONT_CARE })); + } +} + + TEST_CASE("mata::nft::print_to_mata()") { Nft aut_big{ Nft::with_levels(2, 9) }; aut_big.initial = { 1, 2 };