aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/language/method_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/language/method_spec.rb')
-rw-r--r--spec/ruby/language/method_spec.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/spec/ruby/language/method_spec.rb b/spec/ruby/language/method_spec.rb
index 54f0c6ccf8..c5612ed19f 100644
--- a/spec/ruby/language/method_spec.rb
+++ b/spec/ruby/language/method_spec.rb
@@ -1269,7 +1269,7 @@ describe "A method" do
def m(a, b = nil, c = nil, d, e: nil, **f)
[a, b, c, d, e, f]
end
- ruby
+ ruby
result = m(1, 2)
result.should == [1, nil, nil, 2, nil, {}]
@@ -1281,6 +1281,19 @@ describe "A method" do
result.should == [1, nil, nil, {foo: :bar}, nil, {}]
end
end
+
+ context "assigns keyword arguments from a passed Hash without modifying it" do
+ evaluate <<-ruby do
+ def m(a: nil); a; end
+ ruby
+
+ options = {a: 1}.freeze
+ lambda do
+ m(options).should == 1
+ end.should_not raise_error
+ options.should == {a: 1}
+ end
+ end
end
describe "A method call with a space between method name and parentheses" do