Sha256: b783f258369f947fdda819d3dec1fa26091c12d88e18f73f6d410ade6b4413fa

Contents?: true

Size: 836 Bytes

Versions: 6

Compression:

Stored size: 836 Bytes

Contents

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

describe "Arrays" do
  it "should parse empty arrays as s(:array)" do
    opal_parse("[]").should == [:array]
  end

  it "should append regular args onto end of array sexp" do
    opal_parse("[1]").should == [:array, [:lit, 1]]
    opal_parse("[1, 2]").should == [:array, [:lit, 1], [:lit, 2]]
    opal_parse("[1, 2, 3]").should == [:array, [:lit, 1], [:lit, 2], [:lit, 3]]
  end

  it "should return a single item s(:array) with given splat if no norm args" do
    opal_parse("[*1]").should == [:array, [:splat, [:lit, 1]]]
  end

  it "should allow splats combined with any number of norm args" do
    opal_parse("[1, *2]").should == [:array, [:lit, 1], [:splat, [:lit, 2]]]
    opal_parse("[1, 2, *3]").should == [:array, [:lit, 1], [:lit, 2], [:splat, [:lit, 3]]]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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