summaryrefslogtreecommitdiff
path: root/test/racc
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2020-08-13 21:50:16 -0400
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-28 18:07:24 +0900
commit97d1a381e112e843ff014a05a083e42165b7bb01 (patch)
tree5c995202ecb3de5101ef45e9bc749537f7539faf /test/racc
parent3da3c2747feb0c4a122182792150a49012bed1a6 (diff)
downloadruby-97d1a381e112e843ff014a05a083e42165b7bb01.tar.gz
[Fixes #137] Improve reporting
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