blob: 8d3735f6e23321ba631fca2e15e2184e2403143f (
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.isShidDiscard;
import static org.shedlang.compiler.shid.instructions.ShidMatchers.isShidPushString;
import static org.zwobble.precisely.AssertThat.assertThat;
import static org.zwobble.precisely.Matchers.isSequence;
public class ShidCodeGenExpressionStatementTests {
@Test
public void expressionIsEvaluatedAndTheResultDiscarded() {
var node = Typed.expressionStatement(Typed.stringLiteral("hello"));
var context = ShidCodeGen.Context.EMPTY;
var result = ShidCodeGen.compileFunctionStatement(node, context);
assertThat(result.instructions(), isSequence(
isShidPushString("hello"),
isShidDiscard()
));
}
}
|