blob: 1f9c24e8433fad7abf3358c692709441c658f9c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package org.shedlang.compiler.shid;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.ast.typed.Typed;
import static org.shedlang.compiler.shid.instructions.ShidMatchers.*;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
public class ShidCodeGenVarTests {
@Test
public void expressionIsEvaluatedAndStoredAsVar() {
var node = Typed.var("x", Typed.stringLiteral("hello"));
var context = ShidCodeGen.Context.EMPTY
.addShedVal("x");
var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isShidPushString("hello"),
isShidVarStore("x__0")
));
}
}
|