mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (compile_cpath, iseq_compile_each): reverted
constant/class variable lookup in instance_eval etc. to the behavior of 1.8. * eval.c (rb_mod_nesting): ditto. * insns.def (putspecialobject, defineclass): ditto. * node.h (NODE_FL_CREF_PUSHED_BY_EVAL): ditto. * vm_core.h (VM_SPECIAL_OBJECT_CONST_BASE): ditto. * vm_eval.c (yield_under, eval_under): ditto. * vm_insnhelper.c (vm_cref_push, vm_get_const_base, vm_get_ev_const, vm_get_cvar_base): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9998481d4e
commit
7dbfe89630
10 changed files with 105 additions and 22 deletions
|
@ -416,12 +416,20 @@ class TestObject < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class InstanceExec
|
||||
INSTANCE_EXEC = 123
|
||||
end
|
||||
|
||||
def test_instance_exec
|
||||
x = 1.instance_exec(42) {|a| self + a }
|
||||
assert_equal(43, x)
|
||||
|
||||
x = "foo".instance_exec("bar") {|a| self + a }
|
||||
assert_equal("foobar", x)
|
||||
|
||||
assert_raise(NameError) do
|
||||
InstanceExec.new.instance_exec { INSTANCE_EXEC }
|
||||
end
|
||||
end
|
||||
|
||||
def test_extend
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue