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.4.3 spec/parser/hash_spec.rb
opal-0.4.2 spec/parser/hash_spec.rb
opal-0.4.1 spec/parser/hash_spec.rb
opal-0.4.0 spec/parser/hash_spec.rb
opal-0.3.44 spec/parser/hash_spec.rb
opal-0.3.43 spec/parser/hash_spec.rb
opal-0.3.42 spec/grammar/hash_spec.rb
opal-0.3.41 spec/grammar/hash_spec.rb
opal-0.3.40 spec/grammar/hash_spec.rb
opal-0.3.39 spec/grammar/hash_spec.rb
opal-0.3.38 spec/grammar/hash_spec.rb
opal-0.3.37 spec/grammar/hash_spec.rb
opal-0.3.36 spec/grammar/hash_spec.rb
opal-0.3.35 spec/grammar/hash_spec.rb
opal-0.3.34 spec/grammar/hash_spec.rb
opal-0.3.33 spec/grammar/hash_spec.rb
opal-0.3.32 spec/grammar/hash_spec.rb
opal-0.3.31 spec/grammar/hash_spec.rb
opal-0.3.30 spec/grammar/hash_spec.rb
opal-0.3.29 spec/grammar/hash_spec.rb