diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/parcom_spec.cr | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/parcom_spec.cr b/spec/parcom_spec.cr index 5be59b9..937c43c 100644 --- a/spec/parcom_spec.cr +++ b/spec/parcom_spec.cr @@ -378,7 +378,28 @@ describe Optional do end end -pending Tokens do +describe Tokens do + p = Tokens.new("test".chars) + + describe "#parse" do + it "fails if the input stream is too short" do + input = TokenStream.from_string("") + expect_raises(ParserException) { p.parse(input) } + end + + it "fails if it encounters an unexpected token" do + input = TokenStream.from_string("text") + expect_raises(ParserException) { p.parse(input) } + end + + it "succeeds if the input starts with the expected tokens" do + input = TokenStream.from_string("testing") + result = p.parse(input) + + result.tokens.should eq(input[4..]) + result.value.should eq("test".chars) + end + end end pending Many do |
