aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-06-20 15:51:05 -0700
committerJeremy Evans <code@jeremyevans.net>2022-07-21 08:28:05 -0700
commit12ac8971a394118a57640299f654e46e763093fa (patch)
tree9496a60714ae5b67c525e895998d11db105169b7 /test
parent04f86ad0b5d2fe4711ff300d855228a6aed55f33 (diff)
downloadruby-12ac8971a394118a57640299f654e46e763093fa.tar.gz
Do not have class/module keywords look up ancestors of Object
Fixes case where Object includes a module that defines a constant, then using class/module keyword to define the same constant on Object itself. Implements [Feature #18832]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_module.rb2
-rw-r--r--test/ruby/test_syntax.rb15
2 files changed, 15 insertions, 2 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 3dae3916ff..137da09bc3 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1328,8 +1328,6 @@ class TestModule < Test::Unit::TestCase
end
end
include LangModuleSpecInObject
- module LangModuleTop
- end
puts "ok" if LangModuleSpecInObject::LangModuleTop == LangModuleTop
INPUT
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 1d7b89de57..b0ad012131 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1907,6 +1907,21 @@ eom
assert_equal 0...1, exp.call(a: 0)
end
+ def test_class_module_Object_ancestors
+ assert_separately([], <<-RUBY)
+ m = Module.new
+ m::Bug18832 = 1
+ include m
+ class Bug18832; end
+ RUBY
+ assert_separately([], <<-RUBY)
+ m = Module.new
+ m::Bug18832 = 1
+ include m
+ module Bug18832; end
+ RUBY
+ end
+
def test_cdhash
assert_separately([], <<-RUBY)
n = case 1 when 2r then false else true end