summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-24 09:20:42 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-24 09:20:42 +0000
commit66d247bcb50a29769ff940100223544c125521aa (patch)
tree2d6f3c72524c2669cbb370b14204a914344c6614 /test
parent24f00be686bdd5dc78a59b7566e85ab70796de01 (diff)
* 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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb23
1 files changed, 23 insertions, 0 deletions
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