diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-10-05 18:10:32 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-10-05 18:10:32 +0100 |
| commit | 27ffd2d94482ccdcd10acbb1111ce0a0ddae6c01 (patch) | |
| tree | 83104ba83bba3ccfd2dbf0bb1f0d9afc1ea076dd /src/test/java/org/zwobble/couscous/tests/interpreter | |
| parent | 9e850b3a09ceebf6140e77982b45abab0c57ad6c (diff) | |
Add types to expression nodes
Diffstat (limited to 'src/test/java/org/zwobble/couscous/tests/interpreter')
| -rw-r--r-- | src/test/java/org/zwobble/couscous/tests/interpreter/EvaluatorTests.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/test/java/org/zwobble/couscous/tests/interpreter/EvaluatorTests.java b/src/test/java/org/zwobble/couscous/tests/interpreter/EvaluatorTests.java index 766cf3c..fab65ef 100644 --- a/src/test/java/org/zwobble/couscous/tests/interpreter/EvaluatorTests.java +++ b/src/test/java/org/zwobble/couscous/tests/interpreter/EvaluatorTests.java @@ -24,6 +24,7 @@ import org.zwobble.couscous.values.StringValue; import com.google.common.collect.ImmutableMap; +import static java.util.Arrays.asList; import static org.junit.Assert.assertEquals; import static org.zwobble.couscous.ast.AssignmentNode.assign; import static org.zwobble.couscous.ast.FormalArgumentNode.formalArg; @@ -59,7 +60,11 @@ public class EvaluatorTests extends BackendEvalTests { @Test public void canCallMethodWithArgumentsOnBuiltin() { val result = eval(emptyEnvironment(), - methodCall(literal("hello"), "substring", literal(1), literal(4))); + methodCall( + literal("hello"), + "substring", + asList(literal(1), literal(4)), + StringValue.REF)); assertEquals(new StringInterpreterValue("ell"), result); } @@ -67,7 +72,11 @@ public class EvaluatorTests extends BackendEvalTests { public void errorIfMethodDoesNotExist() { val exception = assertThrows(NoSuchMethod.class, () -> eval(emptyEnvironment(), - methodCall(literal("hello"), "size"))); + methodCall( + literal("hello"), + "size", + asList(), + IntegerValue.REF))); assertEquals(new NoSuchMethod("size"), exception); } @@ -75,7 +84,11 @@ public class EvaluatorTests extends BackendEvalTests { public void errorIfWrongNumberOfArgumentsArePassed() { val exception = assertThrows(WrongNumberOfArguments.class, () -> eval(emptyEnvironment(), - methodCall(literal("hello"), "substring", literal(1)))); + methodCall( + literal("hello"), + "substring", + asList(literal(1)), + StringValue.REF))); assertEquals(new WrongNumberOfArguments(2, 1), exception); } @@ -83,7 +96,11 @@ public class EvaluatorTests extends BackendEvalTests { public void errorIfArgumentIsWrongType() { val exception = assertThrows(UnexpectedValueType.class, () -> eval(emptyEnvironment(), - methodCall(literal("hello"), "substring", literal(0), literal("")))); + methodCall( + literal("hello"), + "substring", + asList(literal(0), literal("")), + StringValue.REF))); assertEquals(new UnexpectedValueType(IntegerValue.REF, StringValue.REF), exception); } |
