aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_const.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-08-13 22:44:36 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-14 09:50:14 -0700
commitfbcd0652944568c43a6ae427960d909d62ce6a8d (patch)
tree5c81bdb7b8258c9bc00734c30b69a48c7502632c /test/ruby/test_const.rb
parent7d32cb7631677172d12010233432b7470046ec2a (diff)
downloadruby-fbcd0652944568c43a6ae427960d909d62ce6a8d.tar.gz
Remove support for nil::Constant
This was an intentional bug added in 1.9. The approach taken here is to add a second operand to the getconstant instruction for whether nil should be allowed and treated as current scope. Fixes [Bug #11718]
Diffstat (limited to 'test/ruby/test_const.rb')
-rw-r--r--test/ruby/test_const.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb
index 8784e0e988..6284434db0 100644
--- a/test/ruby/test_const.rb
+++ b/test/ruby/test_const.rb
@@ -48,6 +48,12 @@ class TestConst < Test::Unit::TestCase
assert_equal 8, TEST4
end
+ def test_const_access_from_nil
+ assert_raise(TypeError) { eval("nil::Object") }
+ assert_raise(TypeError) { eval("c = nil; c::Object") }
+ assert_raise(TypeError) { eval("sc = Class.new; sc::C = nil; sc::C::Object") }
+ end
+
def test_redefinition
c = Class.new
name = "X\u{5b9a 6570}"