Sha256: d347d416a233a008e55e16089481bfe8ebec833a6159e8adbd038975e2f17580

Contents?: true

Size: 604 Bytes

Versions: 26

Compression:

Stored size: 604 Bytes

Contents

require 'spec_helper'

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

26 entries across 26 versions & 1 rubygems

Version Path
opal-0.3.28 spec/grammar/hash_spec.rb
opal-0.3.27 spec/lib/grammar/hash_spec.rb
opal-0.3.26 spec/lib/grammar/hash_spec.rb
opal-0.3.25 spec/lib/grammar/hash_spec.rb
opal-0.3.22 spec/grammar/hash_spec.rb
opal-0.3.21 spec/grammar/hash_spec.rb