Skip to content

Commit 56f8fd2

Browse files
committed
Add new unit and integration tests (fc63776)
1 parent 7c9aef7 commit 56f8fd2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

liquidjava-verifier/src/test/java/liquidjava/ast/opt/TestOptimizationInt.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import static org.junit.Assert.assertEquals;
2+
import static org.junit.Assert.assertNotNull;
23

34
import org.junit.Test;
45

56
import liquidjava.rj_language.ast.BinaryExpression;
67
import liquidjava.rj_language.ast.LiteralInt;
78
import liquidjava.rj_language.opt.ConstantFolding;
89
import liquidjava.rj_language.opt.derivation_node.ValDerivationNode;
10+
import liquidjava.rj_language.ast.Var;
911

1012
public class TestOptimizationInt {
1113
@Test
@@ -15,4 +17,20 @@ public void testIntegerAddFold() {
1517
ValDerivationNode r = ConstantFolding.fold(new ValDerivationNode(b, null));
1618
assertEquals(new LiteralInt(5), r.getValue());
1719
}
20+
21+
@Test
22+
public void testNoFoldWhenNonLiteral() {
23+
BinaryExpression b = new BinaryExpression(new LiteralInt(1), "+", new Var("x"));
24+
ValDerivationNode r = ConstantFolding.fold(new ValDerivationNode(b, null));
25+
assertNotNull(r);
26+
}
27+
28+
@Test
29+
public void testIntegerSubFold() {
30+
BinaryExpression b = new BinaryExpression(new LiteralInt(5), "-", new LiteralInt(2));
31+
ValDerivationNode r = ConstantFolding.fold(new ValDerivationNode(b, null));
32+
assertEquals(new LiteralInt(3), r.getValue());
33+
}
34+
35+
1836
}

0 commit comments

Comments
 (0)