diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-07-15 14:23:47 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-07-15 14:23:47 +0100 |
| commit | bc06840e00425db342bc5a021c0900d9e63b71f0 (patch) | |
| tree | 0aa45a4ea475804a36a5ee33f9a726656f45bc1f /src/test/java/org/zwobble/couscous/tests/CompilerTests.java | |
| parent | 3be68289f34a37ac7f9e1e95fa0d95dfc1bb3836 (diff) | |
Split switch handling off to desugar step
Diffstat (limited to 'src/test/java/org/zwobble/couscous/tests/CompilerTests.java')
| -rw-r--r-- | src/test/java/org/zwobble/couscous/tests/CompilerTests.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/couscous/tests/CompilerTests.java b/src/test/java/org/zwobble/couscous/tests/CompilerTests.java index be3ca29..94c6e6a 100644 --- a/src/test/java/org/zwobble/couscous/tests/CompilerTests.java +++ b/src/test/java/org/zwobble/couscous/tests/CompilerTests.java @@ -289,6 +289,30 @@ public abstract class CompilerTests { } @Test + public void switchStatements() throws Exception { + switchStatementTest("simpleReturn", "one", 1); + switchStatementTest("simpleReturn", "zero", 0); + + switchStatementTest("simpleFallthroughReturn", "one", 1); + switchStatementTest("simpleFallthroughReturn", "two", 1); + switchStatementTest("simpleFallthroughReturn", "zero", 0); + + switchStatementTest("noDefaultReturn", "one", 1); + switchStatementTest("noDefaultReturn", "zero", 0); + } + + private void switchStatementTest(String methodName, String input, int expected) throws Exception { + assertEquals( + value(expected), + execTestProgram( + "switch-statements", + ScalarType.of("com.example.SwitchStatements"), + methodName, + list(value(input)), + Types.INT)); + } + + @Test public void stringAdd() throws Exception { assertEquals(value("42"), evalExpression(Types.STRING, "\"4\" + \"2\"")); } |
