mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-19 00:56:52 +08:00
20 lines
724 B
Ruby
20 lines
724 B
Ruby
describe "Hash literal" do
|
|
describe 'new-style hash syntax' do
|
|
it 'constructs a new hash with the given elements' do
|
|
{foo: 123}.should == {:foo => 123}
|
|
{rbx: :cool, specs: 'fail_sometimes'}.should == {:rbx => :cool, :specs => 'fail_sometimes'}
|
|
end
|
|
|
|
it 'ignores a hanging comma' do
|
|
{foo: 123,}.should == {:foo => 123}
|
|
{rbx: :cool, specs: 'fail_sometimes',}.should == {:rbx => :cool, :specs => 'fail_sometimes'}
|
|
end
|
|
|
|
it 'can mix and match syntax styles' do
|
|
{rbx: :cool, :specs => 'fail_sometimes'}.should == {:rbx => :cool, :specs => 'fail_sometimes'}
|
|
{'rbx' => :cool, specs: 'fail_sometimes'}.should == {'rbx' => :cool, :specs => 'fail_sometimes'}
|
|
end
|
|
end
|
|
end
|
|
|