|
public void testVariableStatement() throws CompilerException {
assertParserOutput(
new VariableStatement(
new VariableDeclaration[] {
new VariableDeclaration(
new Identifier("foo"),
null
)
}
),
"var foo;"
);
assertParserOutput(
new VariableStatement(
new VariableDeclaration[] {
new VariableDeclaration(
new Identifier("foo"),
new NumberLiteral(1.0)
)
}
),
"var foo = 1.0;"
);
assertParserOutput(
new VariableStatement(
new VariableDeclaration[] {
new VariableDeclaration(
new Identifier("bar"),
new BinaryOperatorExpression(
new Identifier("x"),
new Identifier("baz"),
Token.KEYWORD_IN
)
)
}
),
"var bar = x in baz;"
);
assertParserOutput(
new VariableStatement(
new VariableDeclaration[] {
new VariableDeclaration(
new Identifier("foo"),
null
),
new VariableDeclaration(
new Identifier("bar"),
null
)
}
),
"var foo, bar;"
);
assertParserOutput(
new VariableStatement(
new VariableDeclaration[] {
new VariableDeclaration(
new Identifier("foo"),
new NumberLiteral(1.0)
),
new VariableDeclaration(
new Identifier("bar"),
null
)
}
),
"var foo = 1.0, bar;"
);
assertParserOutput(
new VariableStatement(
new VariableDeclaration[] {
new VariableDeclaration(
new Identifier("foo"),
new NumberLiteral(1.0)
),
new VariableDeclaration(
new Identifier("bar"),
new BinaryOperatorExpression(
new Identifier("x"),
new Identifier("baz"),
Token.KEYWORD_IN
|