From 0bce3a36d2b6b0d4bccdbf3b75b279a13fbb22e4 Mon Sep 17 00:00:00 2001 From: Keita Obo Date: Wed, 18 Sep 2013 00:20:13 +0900 Subject: Fixed self value in a block is changed with return value fix #1504 --- test/t/proc.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/t/proc.rb b/test/t/proc.rb index 4227772dd..8587a7bc7 100644 --- a/test/t/proc.rb +++ b/test/t/proc.rb @@ -54,3 +54,19 @@ assert('Proc#call', '15.2.17.4.3') do assert_equal 1, a assert_equal 5, a2 end + +assert('Proc#return_does_not_break_self') do + class TestClass + attr_accessor :block + def initialize + end + def register_block + @block = Proc.new { self } + return [] + end + end + + c = TestClass.new + assert_equal [], c.register_block + assert_equal c, c.block.call +end -- cgit v1.2.3