diff options
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/language/send_spec.rb | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/spec/ruby/language/send_spec.rb b/spec/ruby/language/send_spec.rb index c56d5e8c26..17381166dc 100644 --- a/spec/ruby/language/send_spec.rb +++ b/spec/ruby/language/send_spec.rb @@ -421,18 +421,36 @@ 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] + ruby_version_is ""..."2.8" do + 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 + end - args = [1, nil] - m(*args, &args.pop).should == [[1], nil] + ruby_version_is "2.8" do + it "expands the Array elements from the splat before applying block argument operations" do + def self.m(*args, &block) + [args, block] + end - args = [1, nil] - order = [] - m(*(order << :args; args), &(order << :block; args.pop)).should == [[1], nil] - order.should == [:args, :block] + args = [1, nil] + m(*args, &args.pop).should == [[1, nil], nil] + + args = [1, nil] + order = [] + m(*(order << :args; args), &(order << :block; args.pop)).should == [[1, nil], nil] + order.should == [:args, :block] + end end it "evaluates the splatted arguments before the block if there are other arguments after the splat" do |