diff options
Diffstat (limited to 'src/test/java/org')
| -rw-r--r-- | src/test/java/org/zwobble/couscous/tests/interpreter/InterpreterTests.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/couscous/tests/interpreter/InterpreterTests.java b/src/test/java/org/zwobble/couscous/tests/interpreter/InterpreterTests.java index 66a1f8b..58a1b6b 100644 --- a/src/test/java/org/zwobble/couscous/tests/interpreter/InterpreterTests.java +++ b/src/test/java/org/zwobble/couscous/tests/interpreter/InterpreterTests.java @@ -117,6 +117,19 @@ public class InterpreterTests { assertEquals(new VariableNotInScope(42), exception); } + + @Test + public void errorIfTryingToGetValueOfVariableNotInScope() { + val localVariableDeclaration = localVariableDeclaration( + 42, StringValue.REF, "x", literal("")); + val method = staticMethod("hello") + .statement(new ReturnNode(reference(localVariableDeclaration))); + + val exception = assertThrows(VariableNotInScope.class, + () -> runMethod(method)); + + assertEquals(new VariableNotInScope(42), exception); + } private InterpreterValue runMethod(MethodNode.MethodNodeBuilder methodBuilder, InterpreterValue... arguments) { val method = methodBuilder.build(); |
