From 5129155a253293e96cacb83da0803aa1130e815e Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 13 Aug 2014 12:17:57 +0000 Subject: [PATCH] test_parse.rb: for warnings * test/ruby/test_parse.rb (TestParse): add tests for parser warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_parse.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 008dbbcd92..c8f47d6224 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -851,4 +851,18 @@ x = __ENCODING__ actual = e.backtrace.first[/\A#{Regexp.quote(__FILE__)}:(\d+):/o, 1].to_i assert_equal(expected, actual, bug5614) end + + def test_shadowing_variable + assert_warning(/shadowing outer local variable/) {eval("a=1; tap {|a|}")} + end + + def test_unused_variable + o = Object.new + assert_warning(/assigned but unused variable/) {o.instance_eval("def foo; a=1; nil; end")} + end + + def test_named_capture_conflict + a = 1 + assert_warning(/named capture conflict/) {eval("a = 1; /(?)/ =~ ''")} + end end