mirror of
https://github.com/ruby/ruby.git
synced 2025-09-24 04:54:01 +02:00
class.c: check redefinition
* class.c (rb_prepend_module): check redefinition of built-in opimized methods. [ruby-dev:47124] [Bug #7983] * vm.c (rb_vm_check_redefinition_by_prepend): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
00a8203b0b
commit
f113ab552c
4 changed files with 62 additions and 11 deletions
|
@ -1475,6 +1475,20 @@ class TestModule < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_prepend_optmethod
|
||||
bug7983 = '[ruby-dev:47124] [Bug #7983]'
|
||||
assert_separately [], %{
|
||||
module M
|
||||
def /(other)
|
||||
to_f / other
|
||||
end
|
||||
end
|
||||
Fixnum.send(:prepend, M)
|
||||
assert_equal(0.5, 1 / 2, "#{bug7983}")
|
||||
}
|
||||
assert_equal(0, 1 / 2)
|
||||
end
|
||||
|
||||
def test_class_variables
|
||||
m = Module.new
|
||||
m.class_variable_set(:@@foo, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue