Skip to content

Commit

Permalink
#357: added compound if-statement unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dbenn committed Jul 21, 2024
1 parent 949aab0 commit 6686a91
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/org/aavso/tools/vstar/vela/VeLaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,35 @@ public void testIfThenElse() {
}
}

public void testCompoundIfThenElse() {
String prog = "if 3 > 2 then if 2 > 2 then 1 else 2";

Optional<Operand> result = vela.program(prog);

if (result.isPresent()) {
assertEquals(2, result.get().intVal());
} else {
fail();
}
}

public void testIfThenElseWithBlocks() {
String prog = "";
prog += "if 2 > 3 then {\n";
prog += " 42.42\n";
prog += "} else {\n";
prog += " if 1 = 1 and 2 > 0 then 21.21 else 2\n";
prog += "}";

Optional<Operand> result = vela.program(prog);

if (result.isPresent()) {
assertTrue(Tolerance.areClose(21.21, result.get().doubleVal(), DELTA, true));
} else {
fail();
}
}

// Functions

public void testFuncParameterless1() {
Expand Down

0 comments on commit 6686a91

Please sign in to comment.