summaryrefslogtreecommitdiff
path: root/spec/ruby/language/send_spec.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-27 16:12:47 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-27 16:12:47 +0000
commita34db218ade33b79e7404488db5a15bad2841c25 (patch)
tree2ed22ad149cd75e36d9aabbe29b32e96c27fa3a6 /spec/ruby/language/send_spec.rb
parent0f989b87a06563add3fdeb9cda983492e8a420af (diff)
Update to ruby/spec@0fe33ac
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/language/send_spec.rb')
-rw-r--r--spec/ruby/language/send_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/ruby/language/send_spec.rb b/spec/ruby/language/send_spec.rb
index 646a700785..15b73aac7f 100644
--- a/spec/ruby/language/send_spec.rb
+++ b/spec/ruby/language/send_spec.rb
@@ -403,6 +403,29 @@ describe "Invoking a method" do
specs.rest_len(0,*a,4,*5,6,7,*c,-1).should == 11
end
+ it "expands the Array elements from the splat after executing the arguments and block if no other arguments follow the splat" do
+ def self.m(*args, &block)
+ [args, block]
+ end
+
+ args = [1, nil]
+ m(*args, &args.pop).should == [[1], nil]
+
+ args = [1, nil]
+ order = []
+ m(*(order << :args; args), &(order << :block; args.pop)).should == [[1], nil]
+ order.should == [:args, :block]
+ end
+
+ it "evaluates the splatted arguments before the block if there are other arguments after the splat" do
+ def self.m(*args, &block)
+ [args, block]
+ end
+
+ args = [1, nil]
+ m(*args, 2, &args.pop).should == [[1, nil, 2], nil]
+ end
+
it "expands an array to arguments grouped in parentheses" do
specs.destructure2([40,2]).should == 42
end