summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-26 08:11:48 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-26 08:11:48 +0000
commitb20ecf49d4d81474bf9352c0f14963cefea660c7 (patch)
tree7c4180bee03d7b0ac4e390d910dd6b59c8291413 /test
parentc4b61464a69c3b3fb6f9701a3c5b8e0aededb336 (diff)
merge revision(s) 41343,41360,41386: [Backport #8531]
test/ruby/test_symbol.rb: tests for [Bug #8531] * include/ruby/ruby.h, vm_eval.c (rb_funcall_with_block): new function to invoke a method with a block passed as an argument. * string.c (sym_call): use the above function to avoid a block sharing. [ruby-dev:47438] [Bug #8531] * vm_insnhelper.c (vm_yield_with_cfunc): don't set block in the frame. * test/ruby/test_symbol.rb (TestSymbol#test_block_given_to_proc): run related tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@41653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_symbol.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index c98f954092..23c50e6778 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -33,7 +33,7 @@ class TestSymbol < Test::Unit::TestCase
assert_inspect_evaled(':foo')
assert_inspect_evaled(':foo!')
assert_inspect_evaled(':bar?')
- assert_inspect_evaled(':<<')
+ assert_inspect_evaled(":<<")
assert_inspect_evaled(':>>')
assert_inspect_evaled(':<=')
assert_inspect_evaled(':>=')
@@ -102,6 +102,33 @@ class TestSymbol < Test::Unit::TestCase
assert_raise(ArgumentError) { :foo.to_proc.call }
end
+ def m_block_given?
+ block_given?
+ end
+
+ def m2_block_given?(m = nil)
+ if m
+ [block_given?, m.call(self)]
+ else
+ block_given?
+ end
+ end
+
+ def test_block_given_to_proc
+ bug8531 = '[Bug #8531]'
+ m = :m_block_given?.to_proc
+ assert(!m.call(self), "#{bug8531} without block")
+ assert(m.call(self) {}, "#{bug8531} with block")
+ assert(!m.call(self), "#{bug8531} without block second")
+ end
+
+ def test_block_persist_between_calls
+ bug8531 = '[Bug #8531]'
+ m2 = :m2_block_given?.to_proc
+ assert_equal([true, false], m2.call(self, m2) {}, "#{bug8531} nested with block")
+ assert_equal([false, false], m2.call(self, m2), "#{bug8531} nested without block")
+ end
+
def test_succ
assert_equal(:fop, :foo.succ)
end