aboutsummaryrefslogtreecommitdiff
path: root/spec/parcom_spec.cr
diff options
context:
space:
mode:
Diffstat (limited to 'spec/parcom_spec.cr')
-rw-r--r--spec/parcom_spec.cr20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/parcom_spec.cr b/spec/parcom_spec.cr
index 6301c2e..fd4b470 100644
--- a/spec/parcom_spec.cr
+++ b/spec/parcom_spec.cr
@@ -539,6 +539,7 @@ describe AtLeast do
it "fails if there are not enough matching tokens to parse" do
p = AtLeast.new(5, letter_a)
expect_raises(ParserException) { p.parse(tokens) }
+ #expect_raises(ParserException) { raise ParserException.new("sdgseg") }
end
it "parses n or more times with the given parser" do
@@ -584,7 +585,24 @@ describe AtMost do
end
end
-pending Between do
+describe Between do
+ letter_a = Token.new('a')
+ tokens = TokenStream.from_string("aaaabcd")
+
+ describe "#parse" do
+ it "parses at least i times, up to a limit of j times" do
+ p0_4 = Between.new(0, 4, letter_a)
+ r0_4 = p0_4.parse(tokens)
+
+ r0_4.value.should eq("aaaa".chars)
+ r0_4.tokens.should eq(tokens[4..])
+ end
+
+ it "fails if there are not enough parser successes" do
+ p = Between.new(5, 6, letter_a)
+ expect_raises(ParserException) { p.parse(tokens) }
+ end
+ end
end
pending StopAt do