diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/parcom_spec.cr | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/parcom_spec.cr b/spec/parcom_spec.cr index c586a7c..efb3964 100644 --- a/spec/parcom_spec.cr +++ b/spec/parcom_spec.cr @@ -418,10 +418,23 @@ describe Parser do # Parses two of the same word, with whitespace between: two_words = (p_any_word << space).and_then(p_string) - tokens = Tokens.from_string("foo foo") - result = two_words.parse(tokens) + it "succeeds if the original parser and generated parser succeed" do + tokens = Tokens.from_string("foo foo") + result = two_words.parse(tokens) - result.value.should eq("foo") + result.value.should eq("foo") + result.tokens.empty?.should be_true + end + + it "fails if the original parser fails" do + tokens = Tokens.from_string("__ foo") + expect_raises(ParserFail) { two_words.parse(tokens) } + end + + it "fails if the generated parser fails" do + tokens = Tokens.from_string("bar foo") + expect_raises(ParserFail) { two_words.parse(tokens) } + end end describe "#many" do |
