From 3b989706df0af7d7a3a042cd3470fcee90f208cf Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 27 Jun 2006 14:02:26 +0000 Subject: [PATCH] * io.c (pipe_open): backout unnecessary fix on 2006-06-26. [ruby-dev:28865] * eval.c (rb_yield_0): exact argument number check now done only for lambda Proc. * eval.c (rb_yield_0): add check for number of arguments, if there's one lambda block parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/test.rb | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/sample/test.rb b/sample/test.rb index 29c0383043..4a053b9bf7 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -1023,38 +1023,28 @@ def call_argument_test(state, proc, *args) test_ok(x,2) end -def yield_argument_test(state, proc, *args) - x = state - begin - proc.yield(*args) - rescue ArgumentError - x = !x - end - test_ok(x,2) -end - call_argument_test(true, lambda{||}) call_argument_test(false, lambda{||}, 1) call_argument_test(true, lambda{|a,|}, 1) call_argument_test(false, lambda{|a,|}) call_argument_test(false, lambda{|a,|}, 1,2) -yield_argument_test(true, lambda{||}) -yield_argument_test(true, lambda{||}, 1) -yield_argument_test(true, lambda{|a,|}, 1) -yield_argument_test(true, lambda{|a,|}) -yield_argument_test(true, lambda{|a,|}, 1,2) +call_argument_test(true, Proc.new{||}) +call_argument_test(true, Proc.new{||}, 1) +call_argument_test(true, Proc.new{|a,|}, 1) +call_argument_test(true, Proc.new{|a,|}) +call_argument_test(true, Proc.new{|a,|}, 1,2) def block_get(&block) block end test_ok(Proc == block_get{}.class) -yield_argument_test(true, block_get{||}) -yield_argument_test(true, block_get{||}, 1) -yield_argument_test(true, block_get{|a,|}, 1) -yield_argument_test(true, block_get{|a,|}) -yield_argument_test(true, block_get{|a,|}, 1,2) +call_argument_test(true, block_get{||}) +call_argument_test(true, block_get{||}, 1) +call_argument_test(true, block_get{|a,|}, 1) +call_argument_test(true, block_get{|a,|}) +call_argument_test(true, block_get{|a,|}, 1,2) call_argument_test(true, block_get(&lambda{||})) call_argument_test(false, block_get(&lambda{||}),1) @@ -1074,7 +1064,7 @@ test_ok(lmd.clone.call == 44) test_ok(block_get(&lmd).class == Proc) test_ok(Proc.new{|a,| a}.yield(1,2,3) == 1) -yield_argument_test(true, Proc.new{|a,|}, 1,2) +call_argument_test(true, Proc.new{|a,|}, 1,2) test_ok(Proc.new{|&b| b.call(10)}.call {|x| x} == 10) test_ok(Proc.new{|a,&b| b.call(a)}.call(12) {|x| x} == 12)