summaryrefslogtreecommitdiff
path: root/test/ruby/test_parse.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-13 12:17:57 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-08-13 12:17:57 +0000
commit5129155a253293e96cacb83da0803aa1130e815e (patch)
tree53a73034b9f15bdcdd3118ea6d1e063d1d0b6ae4 /test/ruby/test_parse.rb
parent979d413fab7bd257334ba4580f0845c2b390c724 (diff)
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
Diffstat (limited to 'test/ruby/test_parse.rb')
-rw-r--r--test/ruby/test_parse.rb14
1 files changed, 14 insertions, 0 deletions
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; /(?<a>)/ =~ ''")}
+ end
end