diff options
| author | Corey Powell <[email protected]> | 2015-07-11 11:09:52 -0500 |
|---|---|---|
| committer | Blaž Hrastnik <[email protected]> | 2015-07-13 14:04:42 +0200 |
| commit | 99aff17075905738a8e45d8b213b92a291588053 (patch) | |
| tree | 5c956af408f32af9f5d5a994c0147daf7da12331 /test | |
| parent | d4b009b394d3933ee1b828d0e91d3c6aaa522339 (diff) | |
| download | mruby-99aff17075905738a8e45d8b213b92a291588053.tar.gz mruby-99aff17075905738a8e45d8b213b92a291588053.zip | |
Ported a bit more of the MRI Module#prepend tests over
Currently kind_of fails miserably, still looking for the reason
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/module.rb | 94 |
1 files changed, 68 insertions, 26 deletions
diff --git a/test/t/module.rb b/test/t/module.rb index 3c87c122b..6fa22e8b4 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -474,38 +474,80 @@ end # Not ISO specified +# @!group prepend assert('Module#prepend') do - module M0 - def m1; [:M0] end - end - module M1 - def m1; [:M1, super, :M1] end - end - module M2 - def m1; [:M2, super, :M2] end - end - M3 = Module.new do - def m1; [:M3, super, :M3] end - end - module M4 - def m1; [:M4, super, :M4] end - end + assert('test_prepend') do + module M0 + def m1; [:M0] end + end + module M1 + def m1; [:M1, super, :M1] end + end + module M2 + def m1; [:M2, super, :M2] end + end + M3 = Module.new do + def m1; [:M3, super, :M3] end + end + module M4 + def m1; [:M4, super, :M4] end + end - class P0 - include M0 - prepend M1 - def m1; [:C0, super, :C0] end + class P0 + include M0 + prepend M1 + def m1; [:C0, super, :C0] end + end + class P1 < P0 + prepend M2, M3 + include M4 + def m1; [:C1, super, :C1] end + end + + obj = P1.new + expected = [:M2,[:M3,[:C1,[:M4,[:M1,[:C0,[:M0],:C0],:M1],:M4],:C1],:M3],:M2] + assert_equal(expected, obj.m1) end - class P1 < P0 - prepend M2, M3 - include M4 - def m1; [:C1, super, :C1] end + + # mruby shouldn't be affected by this since there is + # no visibility control (yet) + assert('test_public_prepend') do + assert_nothing_raised('ruby/ruby #8846') do + Class.new.prepend(Module.new) + end end - obj = P1.new - expected = [:M2,[:M3,[:C1,[:M4,[:M1,[:C0,[:M0],:C0],:M1],:M4],:C1],:M3],:M2] - assert_equal(expected, obj.m1) + assert('test_prepend_inheritance') do + bug6654 = '[ruby-core:45914]' + a = Module.new + b = Module.new { include a } + c = Module.new { prepend b } + + assert bug6654 do + # the Module#< operator should be used here instead, but we don't have it + assert_include(c.ancestors, a) + assert_include(c.ancestors, b) + end + + bug8357 = '[ruby-core:54736] [Bug #8357]' + b = Module.new { prepend a } + c = Class.new { include b } + + assert bug8357 do + # the Module#< operator should be used here instead, but we don't have it + assert_include(c.ancestors, a) + assert_include(c.ancestors, b) + end + + bug8357 = '[ruby-core:54742] [Bug #8357]' + t_print c.new.kind_of?(b) + t_print "\n" + t_print [b, b.ancestors, c, c.ancestors].inspect + t_print "\n" + assert_kind_of(b, c.new, bug8357) + end end +# @!endgroup prepend assert('Module#to_s') do module Test4to_sModules |
