1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2006-06-27 14:02:26 +00:00
parent efb806f46c
commit 3b989706df

View file

@ -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)