From 3463e83192215c36bdcebad8be907eaa09593a41 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 30 Aug 2019 19:23:10 -0700 Subject: Warn for keyword to last hash parameter when method has no optional/rest parameters Previously, there was no warning in this case, even though we will be changing the behavior in Ruby 3. Fixes [Bug #14130] --- spec/ruby/language/method_spec.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'spec/ruby') diff --git a/spec/ruby/language/method_spec.rb b/spec/ruby/language/method_spec.rb index 41c8268f83..410dba99e2 100644 --- a/spec/ruby/language/method_spec.rb +++ b/spec/ruby/language/method_spec.rb @@ -717,7 +717,9 @@ describe "A method" do ruby m(1, b: 2).should == [1, 2] - -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + suppress_keyword_warning.call do + -> { m("a" => 1, b: 2) }.should raise_error(ArgumentError) + end end evaluate <<-ruby do @@ -726,7 +728,9 @@ describe "A method" do m(2).should == [2, 1] m(1, b: 2).should == [1, 2] - m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, 1] + suppress_keyword_warning.call do + m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, 1] + end end evaluate <<-ruby do @@ -735,7 +739,9 @@ describe "A method" do m(1).should == 1 m(1, a: 2, b: 3).should == 1 - m("a" => 1, b: 2).should == {"a" => 1, b: 2} + suppress_keyword_warning.call do + m("a" => 1, b: 2).should == {"a" => 1, b: 2} + end end evaluate <<-ruby do @@ -744,7 +750,9 @@ describe "A method" do m(1).should == [1, {}] m(1, a: 2, b: 3).should == [1, {a: 2, b: 3}] - m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, {}] + suppress_keyword_warning.call do + m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, {}] + end end evaluate <<-ruby do -- cgit v1.2.3