summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2025-04-20 23:43:02 +0200
committerJean Boussier <jean.boussier@gmail.com>2025-04-23 07:07:18 +0200
commit5f3fb35a14665374f353d3889ded3e8a0061895a (patch)
treed244d31ae23d1fc867aa6ed513a424cce980ae67
parent80cf292c79ff0cd91353ab5e7e1112a6f800413d (diff)
Add a new spec for inherited
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13141
-rw-r--r--spec/ruby/core/class/inherited_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/class/inherited_spec.rb b/spec/ruby/core/class/inherited_spec.rb
index 8ef8bb8c35..2a8d1ff813 100644
--- a/spec/ruby/core/class/inherited_spec.rb
+++ b/spec/ruby/core/class/inherited_spec.rb
@@ -98,4 +98,21 @@ describe "Class.inherited" do
-> { Class.new(top) }.should_not raise_error
end
+ it "if the subclass is assigned to a constant, it is all set" do
+ ScratchPad.record []
+
+ parent = Class.new do
+ def self.inherited(subclass)
+ ScratchPad << defined?(self::C)
+ ScratchPad << const_defined?(:C)
+ ScratchPad << constants
+ ScratchPad << const_get(:C)
+ ScratchPad << subclass.name.match?(/\A#<Class:0x\w+>::C\z/)
+ end
+ end
+
+ class parent::C < parent; end
+
+ ScratchPad.recorded.should == ["constant", true, [:C], parent::C, true]
+ end
end