summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-21 14:04:23 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-21 14:04:23 +0000
commit539ab3056902c5946291433cb807ad7c5b8fea4c (patch)
tree03aa4991fd8cbc51cce4c813ef1cf7a964edadbd /test/ruby
parentdd6be57da8054b95855c01d1ebedd21d4a91cd68 (diff)
merge revision(s) 57192,57464,58016,58018,58019: [Backport #12705]
[Bug #12705] add a ticket number. test_lambda.rb: refine test * test/ruby/test_lambda.rb (test_lambda_as_iterator): refine a test for the intention of the original report. [ruby-core:61340] [Bug #9605] test_lambda.rb: remove duplcate tests vm_args.c: arity check of lambda * vm_eval.c (rb_yield_lambda): new function which yields an array to a proc and splat to a lambda. mainly for Enumerable only. * vm_args.c (setup_parameters_complex): remove special lambda splatting for [Bug #9605]. [ruby-core:77065] [Bug #12705] * vm_insnhelper.c (vm_callee_setup_block_arg): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@58045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_lambda.rb32
-rw-r--r--test/ruby/test_yield.rb2
2 files changed, 8 insertions, 26 deletions
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index c47351886a..3ac2e4cb98 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -31,8 +31,10 @@ class TestLambdaParameters < Test::Unit::TestCase
bug9605 = '[ruby-core:61468] [Bug #9605]'
assert_nothing_raised(ArgumentError, bug9605) {1.times(&->(n){ a += 1 })}
assert_equal(3, a, bug9605)
- assert_nothing_raised(ArgumentError, bug9605) {a = [[1, 2]].map(&->(x, y) {x+y})}
- assert_equal([3], a, bug9605)
+ assert_nothing_raised(ArgumentError, bug9605) {
+ a = %w(Hi there how are you).each_with_index.detect(&->(w, i) {w.length == 3})
+ }
+ assert_equal(["how", 2], a, bug9605)
end
def test_call_rest_args
@@ -99,29 +101,9 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_equal(:ok, x, bug13090)
end
- def yield_1(arg)
- yield arg
- end
-
- tap do |;bug9605, expected, result|
- bug9605 = '[ruby-core:65887] [Bug #9605] arity check should be relaxed'
- expected = [1,2,3]
-
- [
- ["array", expected],
- ["to_ary", Struct.new(:to_ary).new(expected)],
- ].product \
- [
- ["proc", proc {|a, b, c| [a, b, c]}],
- ["lambda", lambda {|a, b, c| [a, b, c]}],
- ] do
- |(vtype, val), (btype, block)|
- define_method("test_yield_relaxed(#{vtype},&#{btype})") do
- result = assert_nothing_raised(ArgumentError, bug9605) {
- break yield_1(val, &block)
- }
- assert_equal(expected, result, bug9605)
- end
+ def test_arity_error
+ assert_raise(ArgumentError, '[Bug #12705]') do
+ [1, 2].tap(&lambda {|a, b|})
end
end
diff --git a/test/ruby/test_yield.rb b/test/ruby/test_yield.rb
index 0690d3cdf4..9b2b2f37e0 100644
--- a/test/ruby/test_yield.rb
+++ b/test/ruby/test_yield.rb
@@ -245,7 +245,7 @@ class TestRubyYieldGen < Test::Unit::TestCase
throw :emuerror, ArgumentError
end
else
- if args.length != params.length and !(args.length == 1 and Array === args[0] and args[0].length == params.length)
+ if args.length != params.length
throw :emuerror, ArgumentError
end
end