diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-03 20:17:26 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-03 20:17:26 +0100 |
| commit | 357e3977eff476e67139848d09ec63d3e503873b (patch) | |
| tree | be5c61ae2f7ef46701571a7377d47fb4e00f4a41 /src/test/java | |
| parent | 958053114ed20d91a3f17746398728efc0962927 (diff) | |
Compile val node as namespace statement to stack IR
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java b/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java index 3126c82b..a03e91b6 100644 --- a/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java +++ b/src/test/java/org/shedlang/compiler/stackir/StackCompilerValTests.java @@ -9,7 +9,7 @@ import static org.zwobble.precisely.Matchers.isSequence; public class StackCompilerValTests { @Test - public void expressionIsEvaluatedAndStoredAsLocal() { + public void whenValIsFunctionStatementThenExpressionIsEvaluatedAndStoredAsLocal() { var node = Typed.val( Typed.targetVariable("x"), Typed.stringLiteral("hello") @@ -22,4 +22,19 @@ public class StackCompilerValTests { isLocalStoreInstruction("x") )); } + + @Test + public void whenValIsNamespaceStatementThenExpressionIsEvaluatedAndStoredAsLocal() { + var node = Typed.val( + Typed.targetVariable("x"), + Typed.stringLiteral("hello") + ); + + var instructions = StackCompiler.compileNamespaceStatement(node); + + assertThat(instructions, isSequence( + isPushStringInstruction("hello"), + isLocalStoreInstruction("x") + )); + } } |
