aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_const.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-03 15:11:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-09-03 15:11:53 +0000
commitbc2a1f2a98b04f040ea485cedd3283f2f3906e4c (patch)
tree833ab2f599dfd7576201ab5745e7ffeb5436fd88 /test/ruby/test_const.rb
parent3e0819c66a0908be61fbb769e96c1accb1d67f26 (diff)
downloadruby-bc2a1f2a98b04f040ea485cedd3283f2f3906e4c.tar.gz
* 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
Diffstat (limited to 'test/ruby/test_const.rb')
-rw-r--r--test/ruby/test_const.rb9
1 files changed, 9 insertions, 0 deletions
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