1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* compile.c: fix to output warning when the same literals

are available as a condition of same case clause.
  And remove infomation ('#n') because we can find duplicated
  condition with explicit line numbers.
  [ruby-core:38343] [Ruby 1.9 - Bug #5068]
* test/ruby/test_syntax.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2012-04-24 09:20:42 +00:00
parent 24f00be686
commit 66d247bcb5
3 changed files with 79 additions and 48 deletions

View file

@ -128,6 +128,29 @@ class TestSyntax < Test::Unit::TestCase
assert_not_label(:foo, 'class Foo < not_label:foo; end', bug6347)
end
def test_duplicated_when
w = 'warning: duplicated when clause is ignored'
assert_warn(/3: #{w}.+4: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
eval %q{
case 1
when 1, 1
when 1, 1
when 1, 1
end
}
}
assert_warn(/#{w}/){#/3: #{w}.+4: #{w}.+5: #{w}.+5: #{w}/m){
a = 1
eval %q{
case 1
when 1, 1
when 1, a
when 1, 1
end
}
}
end
private
def not_label(x) @result = x; @not_label ||= nil end