Package com.google.minijoe.compiler.ast

Examples of com.google.minijoe.compiler.ast.ArrayLiteral


      }
    }

    readToken(Token.OPERATOR_CLOSESQUARE);

    return new ArrayLiteral(Util.vectorToExpressionArray(arrayElements));
  }
View Full Code Here


  }

  public void testArrayLiteral() throws CompilerException {
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                }
            )
        ),
        "[];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    null
                }
            )
        ),
        "[,];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(0.0)
                }
            )
        ),
        "[0.0];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    null,
                    new NumberLiteral(0.0)
                }
            )
        ),
        "[,0.0];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(0.0)
                }
            )
        ),
        "[0.0,];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(0.0),
                    null
                }
            )
        ),
        "[0.0,,];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(0.0),
                    null,
                    new NumberLiteral(1.0)
                }
            )
        ),
        "[0.0,,1.0];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(0.0),
                    null,
                    new NumberLiteral(1.0)
                }
            )
        ),
        "[0.0,,1.0,];"
    );
    assertParserOutput(
        new ExpressionStatement(
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(0.0),
                    null,
                    new NumberLiteral(1.0),
                    null
View Full Code Here

  public void testForInStatement() throws CompilerException {
    assertParserOutput(
        new ForInStatement(
            new Identifier("foo"),
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(1.0),
                    new NumberLiteral(2.0),
                    new NumberLiteral(3.0),
                    new NumberLiteral(4.0)
                }
            ),
            new EmptyStatement()
        ),
        "for (foo in [1, 2, 3, 4]);"
    );
    assertParserOutput(
        new ForInStatement(
            new PropertyExpression(
                new Identifier("foo"),
                new StringLiteral("bar")
            ),
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(1.0),
                    new NumberLiteral(2.0),
                    new NumberLiteral(3.0),
                    new NumberLiteral(4.0)
                }
            ),
            new EmptyStatement()
        ),
        "for (foo.bar in [1, 2, 3, 4]);"
    );
    assertParserOutput(
        new ForInStatement(
            new VariableDeclaration(
                new Identifier("foo"),
                null
            ),
            new ArrayLiteral(
                new Expression[] {
                    new NumberLiteral(1.0),
                    new NumberLiteral(2.0),
                    new NumberLiteral(3.0),
                    new NumberLiteral(4.0)
View Full Code Here

TOP

Related Classes of com.google.minijoe.compiler.ast.ArrayLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.