1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/ruby/test_eval.rb: add case to test "sticky" instance_eval

self when passed a reified block (proc/lambda).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
headius 2014-12-02 18:22:15 +00:00
parent f9dcfb2bca
commit 0b31b7cd14

View file

@ -190,6 +190,15 @@ class TestEval < Test::Unit::TestCase
end
end
def test_instance_eval_block_self
# instance_eval(&block)'s self must not be sticky (jruby/jruby#2060)
pr = proc { self }
assert_equal self, pr.call
o = Object.new
assert_equal o, o.instance_eval(&pr)
assert_equal self, pr.call
end
def test_instance_eval_cvar
[Object.new, [], 7, :sym, true, false, nil].each do |obj|
assert_equal(13, obj.instance_eval("@@cvar"))