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.cr21
1 files changed, 20 insertions, 1 deletions
diff --git a/spec/parcom_spec.cr b/spec/parcom_spec.cr
index c395636..d9af3b9 100644
--- a/spec/parcom_spec.cr
+++ b/spec/parcom_spec.cr
@@ -336,7 +336,26 @@ describe Phrase do
end
end
-pending Recover do
+describe Recover do
+ p = Recover.new(Token.new('t'), '@')
+
+ describe "#parse" do
+ it "succeeds and returns the wrapped parser's value if it succeeds" do
+ tokens = TokenStream.from_string("testing")
+ result = p.parse(tokens)
+
+ result.tokens.should eq(tokens[1..])
+ result.value.should eq('t')
+ end
+
+ it "succeeds and returns the default value without modifying the input of the wrapped parser fails" do
+ tokens = TokenStream.from_string("_____")
+ result = p.parse(tokens)
+
+ result.tokens.should eq(tokens)
+ result.value.should eq('@')
+ end
+ end
end
pending Optional do