Skip to content

Commit

Permalink
fix test for llg 0.6.9 (#1101)
Browse files Browse the repository at this point in the history
We had a test that was assuming incorrect token forcing. I made the test
pass with both the previous buggy behavior and new correct one (which is
not quite shipped yet in llg).
  • Loading branch information
mmoskal authored Jan 24, 2025
1 parent 87bc0a8 commit bf4d0ed
Showing 1 changed file with 56 additions and 26 deletions.
82 changes: 56 additions & 26 deletions tests/unit/test_ll.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,33 +379,63 @@ def character_maker2(lm, id, description, valid_weapons):
return lm

grm = character_maker2(1, "A nimble fighter", ["axe", "sword", "bow"])
check_grammar(
grm,
[
'{‧\n‧ ‧ "‧name‧":',
' "‧John‧ Do‧e‧"',
',‧\n‧ ‧ "‧age‧":‧ ',
"3‧0‧,",
'\n‧ ‧ "‧arm‧or‧":‧ "',
"chain",
'mail‧",‧\n‧ ‧ "‧we‧ap‧on‧":‧ "',
"s",
'word‧",‧\n‧ ‧ "‧class‧":',
' "‧war‧rior‧"',
',‧\n‧ ‧ "‧m‧ant‧ra‧":',
' "‧I‧ am‧ the‧ storm‧,‧ I‧ am‧ the‧ light‧ning‧,‧ I‧ am‧ the‧ th‧under‧."',
',‧\n‧ ‧ "‧str‧ength‧":‧ ',
"1‧0‧0‧,",
'\n‧ ‧ "‧items‧":‧ ["',
's‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
",",
' "‧s‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
",",
' "‧s‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
"]‧\n‧}",
],
)

try:
# this is actually correct
check_grammar(
grm,
[
'{‧\n‧ ‧ "‧name‧":',
' "‧John‧ Do‧e‧"',
',‧\n‧ ‧ "‧age‧":‧ ',
"3‧0‧,",
'\n‧ ‧ "‧arm‧or‧":‧ "',
"chain",
'mail‧",‧\n‧ ‧ "‧we‧ap‧on‧":‧ "',
"s",
'word‧",‧\n‧ ‧ "‧class‧":',
' "‧war‧rior‧"',
',‧\n‧ ‧ "‧m‧ant‧ra‧":',
' "‧I‧ am‧ the‧ storm‧,‧ I‧ am‧ the‧ light‧ning‧,‧ I‧ am‧ the‧ th‧under‧."',
',‧\n‧ ‧ "‧str‧ength‧":‧ ',
"1‧0‧0‧,",
'\n‧ ‧ "‧items‧":', # [" should not be forced here (since eg. "" is a token)
' ["‧s‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
",",
' "‧s‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
",",
' "‧s‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
"]‧\n‧}",
],
)
except:
# this is what llg before 0.6.9 does
check_grammar(
grm,
[
'{‧\n‧ ‧ "‧name‧":',
' "‧John‧ Do‧e‧"',
',‧\n‧ ‧ "‧age‧":‧ ',
"3‧0‧,",
'\n‧ ‧ "‧arm‧or‧":‧ "',
"chain",
'mail‧",‧\n‧ ‧ "‧we‧ap‧on‧":‧ "',
"s",
'word‧",‧\n‧ ‧ "‧class‧":',
' "‧war‧rior‧"',
',‧\n‧ ‧ "‧m‧ant‧ra‧":',
' "‧I‧ am‧ the‧ storm‧,‧ I‧ am‧ the‧ light‧ning‧,‧ I‧ am‧ the‧ th‧under‧."',
',‧\n‧ ‧ "‧str‧ength‧":‧ ',
"1‧0‧0‧,",
'\n‧ ‧ "‧items‧":‧ ["', # this is incorrect
's‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
",",
' "‧s‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
",",
' "‧s‧word‧ of‧ light‧ning‧,‧ shield‧ of‧ th‧under‧,‧ hel‧met‧ of‧ storm‧."',
"]‧\n‧}",
],
)

if __name__ == "__main__":
test_llparser()

0 comments on commit bf4d0ed

Please sign in to comment.