summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorKeita Obo <[email protected]>2013-09-18 00:57:23 +0900
committerKeita Obo <[email protected]>2013-09-18 00:57:23 +0900
commitc4e5a8b1675a187afaf04fb54b09d6a35c83e045 (patch)
treefdf45ef6151de836f7e9a2669674903dc5db8bb7 /test
parent0bce3a36d2b6b0d4bccdbf3b75b279a13fbb22e4 (diff)
downloadmruby-c4e5a8b1675a187afaf04fb54b09d6a35c83e045.tar.gz
mruby-c4e5a8b1675a187afaf04fb54b09d6a35c83e045.zip
Fix self value in a block is changed with return value for Fixnum, nil, instance variable.
Fix #1504
Diffstat (limited to 'test')
-rw-r--r--test/t/proc.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/t/proc.rb b/test/t/proc.rb
index 8587a7bc7..151e1df86 100644
--- a/test/t/proc.rb
+++ b/test/t/proc.rb
@@ -60,13 +60,34 @@ assert('Proc#return_does_not_break_self') do
attr_accessor :block
def initialize
end
- def register_block
+ def return_array
@block = Proc.new { self }
return []
end
+ def return_instance_variable
+ @block = Proc.new { self }
+ return @block
+ end
+ def return_const_fixnum
+ @block = Proc.new { self }
+ return 123
+ end
+ def return_nil
+ @block = Proc.new { self }
+ return nil
+ end
end
c = TestClass.new
- assert_equal [], c.register_block
+ assert_equal [], c.return_array
+ assert_equal c, c.block.call
+
+ c.return_instance_variable
+ assert_equal c, c.block.call
+
+ assert_equal 123, c.return_const_fixnum
+ assert_equal c, c.block.call
+
+ assert_equal nil, c.return_nil
assert_equal c, c.block.call
end