mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
Add a new spec for inherited
This commit is contained in:
parent
80cf292c79
commit
5f3fb35a14
Notes:
git
2025-04-23 05:10:30 +00:00
1 changed files with 17 additions and 0 deletions
|
@ -98,4 +98,21 @@ describe "Class.inherited" do
|
||||||
-> { Class.new(top) }.should_not raise_error
|
-> { Class.new(top) }.should_not raise_error
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue