summaryrefslogtreecommitdiff
path: root/spec/ruby/language
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 /spec/ruby/language
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 'spec/ruby/language')
-rw-r--r--spec/ruby/language/module_spec.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/ruby/language/module_spec.rb b/spec/ruby/language/module_spec.rb
index 1a5fcaf46f..e361bf58f5 100644
--- a/spec/ruby/language/module_spec.rb
+++ b/spec/ruby/language/module_spec.rb
@@ -28,9 +28,18 @@ describe "The module keyword" do
ModuleSpecs::Reopened.should be_true
end
- it "reopens a module included in Object" do
- module IncludedModuleSpecs; Reopened = true; end
- ModuleSpecs::IncludedInObject::IncludedModuleSpecs::Reopened.should be_true
+ ruby_version_is '3.2' do
+ it "does not reopen a module included in Object" do
+ module IncludedModuleSpecs; Reopened = true; end
+ ModuleSpecs::IncludedInObject::IncludedModuleSpecs.should_not == Object::IncludedModuleSpecs
+ end
+ end
+
+ ruby_version_is ''...'3.2' do
+ it "reopens a module included in Object" do
+ module IncludedModuleSpecs; Reopened = true; end
+ ModuleSpecs::IncludedInObject::IncludedModuleSpecs::Reopened.should be_true
+ end
end
it "raises a TypeError if the constant is a Class" do