mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@d6921ef
This commit is contained in:
parent
207a5a5bc1
commit
a6c6eef04a
44 changed files with 1141 additions and 250 deletions
|
@ -225,4 +225,43 @@ describe "The ** operator" do
|
|||
h.should == { two: 2 }
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "3.1" do
|
||||
describe "hash with omitted value" do
|
||||
it "accepts short notation 'key' for 'key: value' syntax" do
|
||||
a, b, c = 1, 2, 3
|
||||
h = eval('{a:}')
|
||||
{a: 1}.should == h
|
||||
h = eval('{a:, b:, c:}')
|
||||
{a: 1, b: 2, c: 3}.should == h
|
||||
end
|
||||
|
||||
it "ignores hanging comma on short notation" do
|
||||
a, b, c = 1, 2, 3
|
||||
h = eval('{a:, b:, c:,}')
|
||||
{a: 1, b: 2, c: 3}.should == h
|
||||
end
|
||||
|
||||
it "accepts mixed syntax" do
|
||||
a, e = 1, 5
|
||||
h = eval('{a:, b: 2, "c" => 3, :d => 4, e:}')
|
||||
eval('{a: 1, :b => 2, "c" => 3, "d": 4, e: 5}').should == h
|
||||
end
|
||||
|
||||
it "works with methods and local vars" do
|
||||
a = Class.new
|
||||
a.class_eval(<<-RUBY)
|
||||
def bar
|
||||
"baz"
|
||||
end
|
||||
|
||||
def foo(val)
|
||||
{bar:, val:}
|
||||
end
|
||||
RUBY
|
||||
|
||||
a.new.foo(1).should == {bar: "baz", val: 1}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue