Sha256: cfa02db0f7875cd5b59229f5e57835f8e0906c99e0958d27c06f066ef3c2275a

Contents?: true

Size: 802 Bytes

Versions: 26

Compression:

Stored size: 802 Bytes

Contents

require 'spec_helper'

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

26 entries across 26 versions & 1 rubygems

Version Path
opal-0.4.3 spec/parser/array_spec.rb
opal-0.4.2 spec/parser/array_spec.rb
opal-0.4.1 spec/parser/array_spec.rb
opal-0.4.0 spec/parser/array_spec.rb
opal-0.3.44 spec/parser/array_spec.rb
opal-0.3.43 spec/parser/array_spec.rb
opal-0.3.42 spec/grammar/array_spec.rb
opal-0.3.41 spec/grammar/array_spec.rb
opal-0.3.40 spec/grammar/array_spec.rb
opal-0.3.39 spec/grammar/array_spec.rb
opal-0.3.38 spec/grammar/array_spec.rb
opal-0.3.37 spec/grammar/array_spec.rb
opal-0.3.36 spec/grammar/array_spec.rb
opal-0.3.35 spec/grammar/array_spec.rb
opal-0.3.34 spec/grammar/array_spec.rb
opal-0.3.33 spec/grammar/array_spec.rb
opal-0.3.32 spec/grammar/array_spec.rb
opal-0.3.31 spec/grammar/array_spec.rb
opal-0.3.30 spec/grammar/array_spec.rb
opal-0.3.29 spec/grammar/array_spec.rb