From c2197ee71ac1cc3cb2ad3bf8a93b579f7251316e Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Mon, 13 Mar 2023 13:10:50 +1300 Subject: Fix Many hanging when wrapped parser never fails --- spec/parcom_spec.cr | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec') 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 -- cgit v1.2.1