Sha256: 2a89bfb9d3c756bd19d3c892c318b1939697a42033ccd7c9698221bfd2663c08

Contents?: true

Size: 1.69 KB

Versions: 17

Compression:

Stored size: 1.69 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "/../../helper"))

class ArrayLiteralNodeTest < Johnson::NodeTestCase
  def test_array_literal
    assert_sexp(
                [[:var, [[:assign, [:name, "foo"], [:array, [[:lit, 1]]]]]]],
                @parser.parse('var foo = [1];')
               )
    assert_ecma(
                'var foo = [1];',
                @parser.parse('var foo = [1];')
               )
  end

  def test_paren
    assert_ecma("(a && b);", @parser.parse("(a && b)"))
  end

  def test_array_with_commas
    assert_sexp(
                [[:var, [[:assign, [:name, "foo"], [:array, [
                  [:nil],
                  [:nil],
                  [:lit, 1]
                ]]]]]],
                @parser.parse('var foo = [,,1];')
               )
    assert_ecma(
                'var foo = [null, null, 1];',
                @parser.parse('var foo = [,,1];')
               )
    assert_sexp(
                [[:var, [[:assign, [:name, "foo"], [:array, [
                  [:str, 'foo'],
                  [:nil],
                  [:lit, 1]
                ]]]]]],
                @parser.parse('var foo = ["foo",,1];')
               )
    assert_ecma(
                'var foo = ["foo", null, 1];',
                @parser.parse('var foo = ["foo",,1];')
               )
    assert_sexp(
                [[:var, [[:assign, [:name, "foo"], [:array, [
                  [:name, 'bar'],
                  [:nil],
                  [:lit, 1]
                ]]]]]],
                @parser.parse('var foo = [bar,,1];')
               )
    assert_ecma(
                'var foo = [bar, null, 1];',
                @parser.parse('var foo = [bar,,1];')
               )
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
jbarnette-johnson-1.0.0.200806240111 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.200807291507 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.200808062051 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.200808062111 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.200811251942 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20081126120511 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20090127202936 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20090225110820 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20090326122910 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20090326154650 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20090326161333 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20090402144841 test/johnson/nodes/array_literal_test.rb
jbarnette-johnson-1.0.0.20090402155420 test/johnson/nodes/array_literal_test.rb
johnson-1.2.0 test/johnson/nodes/array_literal_test.rb
johnson-1.1.1 test/johnson/nodes/array_literal_test.rb
johnson-1.1.2 test/johnson/nodes/array_literal_test.rb
johnson-1.1.0 test/johnson/nodes/array_literal_test.rb