зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
fbf5509d11
Коммит
62ef383523
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче