class.c: prepend for each classes

* class.c (include_modules_at): allow prepend each modules upto
  once for each classes.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-19 13:08:28 +00:00
parent 4c3d694fb4
commit 59270c607b
3 changed files with 29 additions and 14 deletions

View file

@ -1725,6 +1725,17 @@ class TestModule < Test::Unit::TestCase
assert_equal('hello!', foo.new.hello, bug9236)
end
def test_multiple_prepend
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])
end
def test_class_variables
m = Module.new
m.class_variable_set(:@@foo, 1)