Skip to content

Commit

Permalink
unit tests for #569
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrignon committed Apr 4, 2020
1 parent 88a34fa commit 912f4ba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import source.syntax.SpecialFunctions;
import source.syntax.StatementsWithNoBlocks;
import source.syntax.SuperInvocation;
import source.syntax.UnreachableCode;
import source.syntax.ValidIndexedAccesses;

public class SyntaxTests extends AbstractTest {
Expand All @@ -77,6 +78,14 @@ public void testKeywords() {
}, getSourceFile(Keywords.class));
}

@Test
public void testUnreachable() {
eval((logHandler, r) -> {
logHandler.assertNoProblems();
assertEquals("OUI", r.get("reachableExecuted"));
}, getSourceFile(UnreachableCode.class));
}

@Test
public void testStatementsWithNoBlocks() {
eval((logHandler, result) -> {
Expand Down
17 changes: 17 additions & 0 deletions transpiler/src/test/java/source/syntax/UnreachableCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package source.syntax;

import static jsweet.util.Lang.$export;

public class UnreachableCode {

public static void main(String[] args) {
String str = null;
if (true) {
str = "OUI";
} else {
str = "NON";
}

$export("reachableExecuted", str);
}
}

0 comments on commit 912f4ba

Please sign in to comment.