ruby-changes:29291
From: nobu <ko1@a...>
Date: Mon, 17 Jun 2013 10:01:24 +0900 (JST)
Subject: [ruby-changes:29291] nobu:r41343 (trunk): test/ruby/test_symbol.rb: tests for [Bug #8531]
nobu 2013-06-17 10:01:09 +0900 (Mon, 17 Jun 2013) New Revision: 41343 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41343 Log: test/ruby/test_symbol.rb: tests for [Bug #8531] Modified files: trunk/test/ruby/test_symbol.rb Index: test/ruby/test_symbol.rb =================================================================== --- test/ruby/test_symbol.rb (revision 41342) +++ test/ruby/test_symbol.rb (revision 41343) @@ -33,7 +33,7 @@ class TestSymbol < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L33 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_symbol.rb#L114 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/