diff options
| author | ksss <[email protected]> | 2014-05-21 23:09:19 +0900 |
|---|---|---|
| committer | ksss <[email protected]> | 2014-05-21 23:09:19 +0900 |
| commit | 0bd8e48773b2fe16a57f444979d7824f706d08ba (patch) | |
| tree | 1cad985ac0d17ef548addac371e51a7e205f0208 | |
| parent | f4570d411db6fba6925f4c931f032c187b53ecec (diff) | |
| download | mruby-0bd8e48773b2fe16a57f444979d7824f706d08ba.tar.gz mruby-0bd8e48773b2fe16a57f444979d7824f706d08ba.zip | |
Module#initialize set created object
for block argument
| -rw-r--r-- | src/class.c | 2 | ||||
| -rw-r--r-- | test/t/module.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c index 5c5aa52f0..44d415f0c 100644 --- a/src/class.c +++ b/src/class.c @@ -897,7 +897,7 @@ mrb_mod_initialize(mrb_state *mrb, mrb_value mod) mrb_get_args(mrb, "&", &b); if (!mrb_nil_p(b)) { - mrb_yield_with_class(mrb, b, 0, 0, mod, mrb_class_ptr(mod)); + mrb_yield_with_class(mrb, b, 1, &mod, mod, mrb_class_ptr(mod)); } return mod; } diff --git a/test/t/module.rb b/test/t/module.rb index 806824b70..fcf46fe3a 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -344,6 +344,9 @@ assert('Module#initialize', '15.2.2.4.31') do assert_kind_of Module, Module.new mod = Module.new { def hello; "hello"; end } assert_equal [:hello], mod.instance_methods + a = nil + mod = Module.new { |m| a = m } + assert_equal mod, a end assert('Module#instance_methods', '15.2.2.4.33') do |
