diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-13 13:54:48 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2023-03-13 13:54:48 +1300 |
| commit | a4430f0fb86871ad15b1fce586f69a1486dc7844 (patch) | |
| tree | 6645a8b67167de98794756c3ec6df5adc91b6d69 /spec/parcom_spec.cr | |
| parent | bbae80606ce3c355f2ccb6cda95410e4b39fe551 (diff) | |
Slightly more robust test case
Diffstat (limited to 'spec/parcom_spec.cr')
| -rw-r--r-- | spec/parcom_spec.cr | 27 |
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 |
