summaryrefslogtreecommitdiff
path: root/test/ruby/test_module.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2021-09-24 00:55:11 +0900
committerNobuyoshi Nakada <[email protected]>2021-09-24 08:29:00 +0900
commit65285bf673914424e960671d1d35e357c455985e (patch)
tree551c2e9aac3b017d462fadd00c924ddfbeec5ee0 /test/ruby/test_module.rb
parent854fe9d1c1d52037a0c04d75b75765f25f028d1e (diff)
Consider modified modules initialized [Bug #18185]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4883
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r--test/ruby/test_module.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 385d8dddfe..429fab897e 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -446,6 +446,32 @@ class TestModule < Test::Unit::TestCase
end
end
+ class Bug18185 < Module
+ module InstanceMethods
+ end
+ def initialize
+ include InstanceMethods
+ end
+ class Foo
+ attr_reader :key
+ def initialize(key:)
+ @key = key
+ end
+ end
+ end
+
+ def test_module_subclass_initialize
+ mod = Bug18185.new
+ c = Class.new(Bug18185::Foo) do
+ include mod
+ end
+ anc = c.ancestors
+ assert_include(anc, mod)
+ assert_equal(1, anc.count(BasicObject), ->{anc.inspect})
+ b = c.new(key: 1)
+ assert_equal(1, b.key)
+ end
+
def test_dup
OtherSetup.call