mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
method in instance_eval
* class.c (rb_special_singleton_class_of): utility function. * vm_eval.c (eval_under): special deal for class variable scope with instance_eval. * vm_eval.c (rb_obj_instance_eval, rb_obj_instance_exec): allow method definition in instance_eval of special constants. [ruby-core:28324] [Bug #2788] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
353833c466
commit
28827e61d1
6 changed files with 61 additions and 23 deletions
|
@ -200,6 +200,21 @@ class TestEval < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_instance_eval_method
|
||||
bug2788 = '[ruby-core:28324]'
|
||||
[Object.new, [], nil, true, false].each do |o|
|
||||
assert_nothing_raised(TypeError, "#{bug2788} (#{o.inspect})") do
|
||||
o.instance_eval {
|
||||
def defd_using_instance_eval() :ok end
|
||||
}
|
||||
end
|
||||
assert_equal(:ok, o.defd_using_instance_eval)
|
||||
class << o
|
||||
remove_method :defd_using_instance_eval
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# From ruby/test/ruby/test_eval.rb
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue