summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorXavier Noria <[email protected]>2025-04-20 23:42:34 +0200
committerJean Boussier <[email protected]>2025-04-23 07:07:18 +0200
commit80cf292c79ff0cd91353ab5e7e1112a6f800413d (patch)
treeb47d264247356da1056c7c791d1951aa309d9946 /spec/ruby
parent6d0dd7d86390458e02830684dd45830b5869a7aa (diff)
Add a new spec for const_added
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13141
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/module/const_added_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/core/module/const_added_spec.rb b/spec/ruby/core/module/const_added_spec.rb
index 1b3dad514b..dfa2e011cc 100644
--- a/spec/ruby/core/module/const_added_spec.rb
+++ b/spec/ruby/core/module/const_added_spec.rb
@@ -219,5 +219,20 @@ describe "Module#const_added" do
ScratchPad.recorded.should == [:const_added, :inherited]
end
+
+ it "the superclass of a class assigned to a constant is set before const_added is called" do
+ ScratchPad.record []
+
+ parent = Class.new do
+ def self.const_added(name)
+ ScratchPad << name
+ ScratchPad << const_get(name).superclass
+ end
+ end
+
+ class parent::C < parent; end
+
+ ScratchPad.recorded.should == [:C, parent]
+ end
end
end