1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Update specs for keyword argument separation

This commit is contained in:
Jeremy Evans 2019-10-06 09:26:58 -07:00
parent ff96565686
commit e014e6bf66
Notes: git 2020-01-03 11:41:09 +09:00
5 changed files with 657 additions and 237 deletions

View file

@ -179,17 +179,33 @@ describe "A lambda literal -> () { }" do
result.should == [1, 2, 3, [4, 5], 6, [7, 8], 9, 10, 11, 12]
end
evaluate <<-ruby do
@a = -> (*, **k) { k }
ruby
ruby_version_is ''...'2.8' do
evaluate <<-ruby do
@a = -> (*, **k) { k }
ruby
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
suppress_keyword_warning do
h = mock("keyword splat")
h.should_receive(:to_hash).and_return({a: 1})
@a.(h).should == {a: 1}
end
end
end
ruby_version_is '2.8' do
evaluate <<-ruby do
@a = -> (*, **k) { k }
ruby
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
suppress_keyword_warning do
h = mock("keyword splat")
h.should_receive(:to_hash).and_return({a: 1})
@a.(h).should == {a: 1}
h.should_not_receive(:to_hash)
@a.(h).should == {}
end
end
@ -533,17 +549,33 @@ describe "A lambda expression 'lambda { ... }'" do
result.should == [1, 2, 3, [4, 5], 6, [7, 8], 9, 10, 11, 12]
end
evaluate <<-ruby do
@a = lambda { |*, **k| k }
ruby
ruby_version_is ''...'2.8' do
evaluate <<-ruby do
@a = lambda { |*, **k| k }
ruby
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
suppress_keyword_warning do
h = mock("keyword splat")
h.should_receive(:to_hash).and_return({a: 1})
@a.(h).should == {a: 1}
end
end
end
ruby_version_is '2.8' do
evaluate <<-ruby do
@a = lambda { |*, **k| k }
ruby
@a.().should == {}
@a.(1, 2, 3, a: 4, b: 5).should == {a: 4, b: 5}
suppress_keyword_warning do
h = mock("keyword splat")
h.should_receive(:to_hash).and_return({a: 1})
@a.(h).should == {a: 1}
h.should_not_receive(:to_hash)
@a.(h).should == {}
end
end