diff options
author | Jeremy Evans <[email protected]> | 2022-01-05 16:12:31 -0800 |
---|---|---|
committer | Jeremy Evans <[email protected]> | 2022-01-06 08:03:33 -0800 |
commit | a79c59472df38297c246b27713c277f2edaefa7a (patch) | |
tree | 8e048103810370901f8ad6bcc37893978c933120 /test/ruby/test_module.rb | |
parent | 73be7a85cd4da6229f9a898b77492357e3811210 (diff) |
Allow include before calling Module#initialize
This is to allow Module subclasses that include modules before
calling super in the subclass's initialize.
Remove rb_module_check_initializable from Module#initialize.
Module#initialize only calls module_exec if a block is passed,
it doesn't have other issues that would cause problems if
called multiple times or with an already initialized module.
Move initialization of super to Module#allocate, though I'm not
sure it is required there. However, it's needed to be removed
from Module#initialize for this to work.
Fixes [Bug #18292]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5398
Diffstat (limited to 'test/ruby/test_module.rb')
-rw-r--r-- | test/ruby/test_module.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index e1524a5d81..b84a090fce 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -519,6 +519,16 @@ class TestModule < Test::Unit::TestCase assert_raise(ArgumentError) { Module.new { include } } end + def test_include_before_initialize + m = Class.new(Module) do + def initialize(...) + include Enumerable + super + end + end.new + assert_equal(true, m < Enumerable) + end + def test_prepend_self m = Module.new assert_equal([m], m.ancestors) |