From bc2a1f2a98b04f040ea485cedd3283f2f3906e4c Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 3 Sep 2011 15:11:53 +0000 Subject: * variable.c (rb_const_set): show the previous definition location. [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_const.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb index 3708a5a0ca..31adb2a0ce 100644 --- a/test/ruby/test_const.rb +++ b/test/ruby/test_const.rb @@ -45,4 +45,13 @@ class TestConst < Test::Unit::TestCase assert defined?(TEST4) assert_equal 8, TEST4 end + + def test_redefinition + c = Class.new + c.const_set(:X, 1) + assert_output(nil, <<-WARNING) {c.const_set(:X, 2)} +#{__FILE__}:#{__LINE__-1}: warning: already initialized constant X +#{__FILE__}:#{__LINE__-3}: warning: previous definition of X was here +WARNING + end end -- cgit v1.2.3