Sha256: 580a4195626b5bb5f49c6d3d1d289d3b8eee5d9feb9cfc1cd3ee91fdf1455aeb

Contents?: true

Size: 638 Bytes

Versions: 6

Compression:

Stored size: 638 Bytes

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe "Hash literals" do
  it "without any assocs should return an empty hash sexp" do
    opal_parse("{}").should == [:hash]
  end

  it "adds each assoc pair as individual args onto sexp" do
    opal_parse("{1 => 2}").should == [:hash, [:lit, 1], [:lit, 2]]
    opal_parse("{1 => 2, 3 => 4}").should == [:hash, [:lit, 1], [:lit, 2], [:lit, 3], [:lit, 4]]
  end

  it "supports 1.9 style hash keys" do
    opal_parse("{ a: 1 }").should == [:hash, [:lit, :a], [:lit, 1]]
    opal_parse("{ a: 1, b: 2 }").should == [:hash, [:lit, :a], [:lit, 1], [:lit, :b], [:lit, 2]]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-0.3.20 spec/grammar/hash_spec.rb
opal-0.3.19 spec/grammar/hash_spec.rb
opal-0.3.18 spec/grammar/hash_spec.rb
opal-0.3.17 test/grammar/hash_spec.rb
opal-0.3.16 spec/grammar/hash_spec.rb
opal-0.3.15 spec/grammar/hash_spec.rb