[前][次][番号順一覧][スレッド一覧]

ruby-changes:36605

From: headius <ko1@a...>
Date: Wed, 3 Dec 2014 03:22:28 +0900 (JST)
Subject: [ruby-changes:36605] headius:r48686 (trunk): * test/ruby/test_eval.rb: add case to test "sticky" instance_eval

headius	2014-12-03 03:22:15 +0900 (Wed, 03 Dec 2014)

  New Revision: 48686

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48686

  Log:
    * test/ruby/test_eval.rb: add case to test "sticky" instance_eval
      self when passed a reified block (proc/lambda).

  Modified files:
    trunk/test/ruby/test_eval.rb
Index: test/ruby/test_eval.rb
===================================================================
--- test/ruby/test_eval.rb	(revision 48685)
+++ test/ruby/test_eval.rb	(revision 48686)
@@ -190,6 +190,15 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L190
     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"))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]