aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/parcom_spec.cr27
1 files changed, 23 insertions, 4 deletions
diff --git a/spec/parcom_spec.cr b/spec/parcom_spec.cr
index feea102..25ae2e9 100644
--- a/spec/parcom_spec.cr
+++ b/spec/parcom_spec.cr
@@ -737,10 +737,29 @@ describe "Practical use" do
arrs.map { |chars| chars.join }
end
- tokens = Tokens.from_string("test number 1 ")
- result = tokenizer.parse(tokens)
- result.value.should eq(["test", "number", "1"])
- result.tokens.empty?.should be_true
+ good_strings = [
+ "test with no trailing whitespace",
+ " test with whitespace in the front",
+ "test with whitespace in the back",
+ " test surrounded by whitespace ",
+ ]
+
+ good_strings.each do |s|
+ tokens = Tokens.from_string(s)
+ result = tokenizer.parse(tokens)
+ result.value.should eq(s.strip.split(/\s+/))
+ result.tokens.empty?.should be_true
+ end
+
+ bad_strings = [
+ "",
+ " ",
+ ]
+
+ bad_strings.each do |s|
+ tokens = Tokens.from_string(s)
+ expect_raises(ParserFail) { tokenizer.parse(tokens) }
+ end
end
end