mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
979d413fab
commit
5129155a25
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue