summaryrefslogtreecommitdiff
path: root/test/racc
diff options
context:
space:
mode:
Diffstat (limited to 'test/racc')
-rw-r--r--test/racc/assets/ifelse.y14
-rw-r--r--test/racc/test_racc_command.rb15
2 files changed, 29 insertions, 0 deletions
diff --git a/test/racc/assets/ifelse.y b/test/racc/assets/ifelse.y
new file mode 100644
index 0000000000..18dbe4b1a7
--- /dev/null
+++ b/test/racc/assets/ifelse.y
@@ -0,0 +1,14 @@
+class C::Parser
+token tSOMETHING
+rule
+ statement
+ : tSOMETHING
+ | 'if' statement 'then' statement
+ | 'if' statement 'then' statement 'else' statement
+ ;
+
+ dummy
+ : tSOMETHING '+' tSOMETHING
+ | tSOMETHING '-' tSOMETHING
+ ;
+
diff --git a/test/racc/test_racc_command.rb b/test/racc/test_racc_command.rb
index b4fc0c6745..f1116a371f 100644
--- a/test/racc/test_racc_command.rb
+++ b/test/racc/test_racc_command.rb
@@ -318,5 +318,20 @@ module Racc
assert_debugfile 'tp_plus.y', [21, 0, 0, 0]
assert_output_unchanged 'tp_plus.y'
end
+
+ def test_ifelse
+ stderr = nil
+ racc "-o#{@TAB_DIR}/ifelse", "#{ASSET_DIR}/ifelse.y", stdout_filter: ->(s) { stderr = s }
+ stderr = stderr.lines[1..-1].join if RUBY_PLATFORM.match? /java/
+ assert_equal(<<~STDERR, stderr)
+ 1 useless nonterminals:
+ dummy
+ 2 useless rules:
+ #4 (dummy)
+ #5 (dummy)
+ 1 shift/reduce conflicts
+ Turn on logging with "-v" and check ".output" file for details
+ STDERR
+ end
end
end