Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6dca3f

Browse files
committed
Add test cases for the prefix language
1 parentd7946a7 commitc6dca3f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎pyformlang/cfg/tests/test_cfg.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,31 @@ def test_to_text_epsilon(self):
842842
cfg=CFG.from_text("S -> a S b | a b epsilon")
843843
assertcfg.contains(["a","b"])
844844

845+
deftest_prefix_lang(self):
846+
cfg=CFG.from_text("S -> a S b | a b | c")
847+
prefix_cfg=cfg.get_prefix_language()
848+
assertprefix_cfg.contains("")
849+
forwordin [
850+
"ab",
851+
"aabb",
852+
]:
853+
assertcfg.contains(word)
854+
assertprefix_cfg.contains(word)
855+
forprefixin [
856+
"aaa",
857+
"aaac",
858+
"aaacb"
859+
]:
860+
assertnotcfg.contains(prefix)
861+
assertprefix_cfg.contains(prefix)
862+
forinvalidin [
863+
"abb",
864+
"aba",
865+
"aaaba",
866+
]:
867+
assertnotcfg.contains(invalid)
868+
assertnotprefix_cfg.contains(invalid)
869+
845870

846871
defget_example_text_duplicate():
847872
""" Duplicate text """

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp