ruby-changes:37257
From: nobu <ko1@a...>
Date: Tue, 20 Jan 2015 10:59:17 +0900 (JST)
Subject: [ruby-changes:37257] nobu:r49338 (trunk): test_module.rb: more tests
nobu 2015-01-20 10:58:52 +0900 (Tue, 20 Jan 2015) New Revision: 49338 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49338 Log: test_module.rb: more tests * test/ruby/test_module.rb: more tests for multiple prepend. Modified files: trunk/test/ruby/test_module.rb Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 49337) +++ test/ruby/test_module.rb (revision 49338) @@ -1725,15 +1725,25 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1725 assert_equal('hello!', foo.new.hello, bug9236) end - def test_multiple_prepend + def test_prepend_each_classes m = labeled_module("M") - c1 = labeled_class("C1") { - prepend m - } - c2 = labeled_class("C2", c1) { - prepend m - } - assert_equal([m, c2, m, c1], c2.ancestors[0, 4]) + c1 = labeled_class("C1") {prepend m} + c2 = labeled_class("C2", c1) {prepend m} + assert_equal([m, c2, m, c1], c2.ancestors[0, 4], "should be able to prepend each classes") + end + + def test_prepend_no_duplication + m = labeled_module("M") + c = labeled_class("C") {prepend m; prepend m} + assert_equal([m, c], c.ancestors[0, 2], "should never duplicate") + end + + def test_prepend_in_superclass + m = labeled_module("M") + c1 = labeled_class("C1") + c2 = labeled_class("C2", c1) {prepend m} + c1.class_eval {prepend m} + assert_equal([m, c2, m, c1], c2.ancestors[0, 4], "should accesisble prepended module in superclass") end def test_class_variables -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/