From ee80e67965f300c28aaf64f33e876a0aca9da85f Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Tue, 1 Apr 2025 22:06:45 -0400 Subject: [PATCH] Ensure endless rules are on a single line In 7df506e I had added an endless rule but I made a mistake in the semantic predicate. I examined the first token (aka `'rule'`) and not the last one (the "parsing expression"). @cjhealth fixed it up for me in 229d2c8 but it seems prudent to add a test to verify this. This commit adds this test. If I update the test replacing the newline with just a normal space between the literals then test fails. But with the newline in the parsing expression the test passes (i.e. it fails to parse). --- spec/compiler/parsing_rule_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/compiler/parsing_rule_spec.rb b/spec/compiler/parsing_rule_spec.rb index 0b16b20..f13f7c9 100644 --- a/spec/compiler/parsing_rule_spec.rb +++ b/spec/compiler/parsing_rule_spec.rb @@ -72,5 +72,16 @@ module ParsingRuleSpec result = parse('boo') result.should_not be_nil end + + context "breaking rule defination" do + it "does not parse" do + compiling_grammar(%{ + grammar EndlessRule + rule foo = ('should' + ' fail') + end + }).should raise_error RuntimeError + end + end end end