From f962890a928b566c0f5ca7fdff5ef4ce19207e65 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 9 Jul 2015 23:46:54 +0200 Subject: Implement Module#prepend. --- test/t/module.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'test') diff --git a/test/t/module.rb b/test/t/module.rb index ecb969475..9faaf6e2c 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -474,6 +474,39 @@ end # Not ISO specified +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 + + class C0 + include M0 + prepend M1 + def m1; [:C0, super, :C0] end + end + class C1 < C0 + prepend M2, M3 + include M4 + def m1; [:C1, super, :C1] end + end + + obj = C1.new + expected = [:M2,[:M3,[:C1,[:M4,[:M1,[:C0,[:M0],:C0],:M1],:M4],:C1],:M3],:M2] + assert_equal(expected, obj.m1) +end + assert('Module#to_s') do module Test4to_sModules end -- cgit v1.2.3