super(name);
}
public void testSwitchStatement() throws CompilerException {
assertParserOutput(
new SwitchStatement(
new Identifier("something"),
new CaseStatement[] {
}
),
"switch (something) {}"
);
assertParserOutput(
new SwitchStatement(
new Identifier("something"),
new CaseStatement[] {
new CaseStatement(
null,
new Statement[] {
new ExpressionStatement(
new Identifier("foo")
)
}
)
}
),
"switch (something) {default: foo;}"
);
assertParserOutput(
new SwitchStatement(
new Identifier("something"),
new CaseStatement[] {
new CaseStatement(
new NumberLiteral(0),
new Statement[] {
new ExpressionStatement(
new Identifier("bar")
)
}
)
}
),
"switch (something) {case 0: bar;}"
);
assertParserOutput(
new SwitchStatement(
new Identifier("something"),
new CaseStatement[] {
new CaseStatement(
new NumberLiteral(0),
new Statement[] {
new ExpressionStatement(
new Identifier("bar")
)
}
),
new CaseStatement(
new NumberLiteral(1),
new Statement[] {
new ExpressionStatement(
new Identifier("baz")
)
}
)
}
),
"switch (something) {case 0: bar; case 1: baz;}"
);
assertParserOutput(
new SwitchStatement(
new Identifier("something"),
new CaseStatement[] {
new CaseStatement(
null,
new Statement[] {
new ExpressionStatement(
new Identifier("foo")
)
}
),
new CaseStatement(
new NumberLiteral(0),
new Statement[] {
new ExpressionStatement(
new Identifier("bar")
)
}
),
new CaseStatement(
new NumberLiteral(1),
new Statement[] {
new ExpressionStatement(
new Identifier("baz")
)
}
)
}
),
"switch (something) {default: foo; case 0: bar; case 1: baz;}"
);
assertParserOutput(
new SwitchStatement(
new Identifier("something"),
new CaseStatement[] {
new CaseStatement(
new NumberLiteral(0),
new Statement[] {
new ExpressionStatement(
new Identifier("bar")
)
}
),
new CaseStatement(
null,
new Statement[] {
new ExpressionStatement(
new Identifier("foo")
)
}
),
new CaseStatement(
new NumberLiteral(1),
new Statement[] {
new ExpressionStatement(
new Identifier("baz")
)
}
)
}
),
"switch (something) {case 0: bar; default: foo; case 1: baz;}"
);
assertParserOutput(
new SwitchStatement(
new Identifier("something"),
new CaseStatement[] {
new CaseStatement(
new NumberLiteral(0),
new Statement[] {