summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-17 01:01:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-17 01:01:09 +0000
commitb69699a08c5ede7c92f192e9c5fff7388052852b (patch)
tree4e17726f705d852409c4600b29f2c1a67b5ca339 /test/ruby
parent7d753a99998d38e39837b664b03e68de59b6e0a1 (diff)
downloadruby-b69699a08c5ede7c92f192e9c5fff7388052852b.tar.gz
test/ruby/test_symbol.rb: tests for [Bug #8531]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_symbol.rb30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 02cc804933..012c487fd4 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(':>=')
@@ -114,6 +114,34 @@ 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]'
+ m = :m_block_given?.to_proc
+ m2 = :m2_block_given?.to_proc
+ assert_equal([true, false], m2.call(self) {}, "#{bug8531} nested with block")
+ assert_equal([false, false], m2.call(self), "#{bug8531} nested without block")
+ end
+
def test_succ
assert_equal(:fop, :foo.succ)
end