From 66d247bcb50a29769ff940100223544c125521aa Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 24 Apr 2012 09:20:42 +0000 Subject: * 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 --- test/ruby/test_syntax.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/ruby/test_syntax.rb') diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index af795440c5..fd5b14d6c3 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -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 -- cgit v1.2.3