class.c: cyclic prepend

* class.c (include_modules_at): detect cyclic prepend with original
  method table.  [ruby-core:52205] [Bug #7841]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-02-14 02:08:31 +00:00
parent bd255c4686
commit 632ab19c4d
3 changed files with 19 additions and 3 deletions

View file

@ -1465,6 +1465,16 @@ class TestModule < Test::Unit::TestCase
assert_equal([:m1], Class.new(Class.new{def m2;end}){ prepend Module.new; def m1; end }.instance_methods(false), bug6660)
end
def test_cyclic_prepend
bug7841 = '[ruby-core:52205] [Bug #7841]'
m1 = Module.new
m2 = Module.new
m1.instance_eval { prepend(m2) }
assert_raise(ArgumentError, bug7841) do
m2.instance_eval { prepend(m1) }
end
end
def test_class_variables
m = Module.new
m.class_variable_set(:@@foo, 1)