diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-13 13:10:50 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-13 13:10:50 +1300 |
| commit | c2197ee71ac1cc3cb2ad3bf8a93b579f7251316e (patch) | |
| tree | e4c23056e68652fe37972faf4c2bea7b74fb8a21 /spec | |
| parent | c340687df1215940d33eb822f46598f51e5b3b95 (diff) | |
Fix Many hanging when wrapped parser never fails
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/parcom_spec.cr | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/parcom_spec.cr b/spec/parcom_spec.cr index 11d2446..dde6f21 100644 --- a/spec/parcom_spec.cr +++ b/spec/parcom_spec.cr @@ -494,6 +494,16 @@ describe Many do result.value.should eq("aaa".chars) result.tokens.should eq(tokens[3..]) end + + it "stops parsing when the wapped parser succeeds without consuming any input" do + a_optional : Parser(Char, Char?) + a_optional = Optional.new(Token.new('a')) + tokens = Tokens.from_string("aaa") + result = Many(Char, Char?).new(a_optional).parse(tokens) + + result.value.should eq("aaa".chars) + result.tokens.should eq(tokens[3..]) + end end end |
