Sha256: aa4d9761691fe7a042bceb620c5b2c58914b880718d847b87f112d664762a6af

Contents?: true

Size: 604 Bytes

Versions: 5

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, [:int, 1], [:int, 2]]
    opal_parse("{1 => 2, 3 => 4}").should == [:hash, [:int, 1], [:int, 2], [:int, 3], [:int, 4]]
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-0.5.5 spec/opal/parser/hash_spec.rb
opal-0.5.4 spec/opal/parser/hash_spec.rb
opal-0.5.2 spec/opal/parser/hash_spec.rb
opal-0.5.0 spec/opal/parser/hash_spec.rb
opal-0.4.4 spec/parser/hash_spec.rb