summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-20 01:58:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-20 01:58:52 +0000
commit62ef3835238e733f9faaef121730d81caf254990 (patch)
treef3a8312ab8cda92d286cd23a068bb7ebbe01b706 /test
parentfbf5509d11730bc1dc1d05915bf325802fc1921d (diff)
test_module.rb: more tests
* test/ruby/test_module.rb: more tests for multiple prepend. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_module.rb26
1 files changed, 18 insertions, 8 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 8413c47..f2694d7 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1725,15 +1725,25 @@ class TestModule < Test::Unit::TestCase
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