Skip to content

Commit

Permalink
Merge pull request #1091 from lf-lang/add-top-level-reactor-port-check
Browse files Browse the repository at this point in the history
Add validation tests for ports in main or federated reactor
  • Loading branch information
housengw authored Apr 12, 2022
2 parents b60189e + 7a53572 commit 0825c08
Showing 1 changed file with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,86 @@ public void testUnnamedReactor() throws Exception {
"Reactor must be named.");
}

@Test
public void testMainHasInput() throws Exception {
// Java 17:
// String testCase = """
// target C;
// main reactor {
// input x:int;
// }
// """
// Java 11:
String testCase = String.join(System.getProperty("line.separator"),
"target C;",
"main reactor {",
" input x:int;",
"}"
);
validator.assertError(parseWithoutError(testCase), LfPackage.eINSTANCE.getInput(), null,
"Main reactor cannot have inputs.");
}

@Test
public void testFederatedHasInput() throws Exception {
// Java 17:
// String testCase = """
// target C;
// federated reactor {
// input x:int;
// }
// """
// Java 11:
String testCase = String.join(System.getProperty("line.separator"),
"target C;",
"federated reactor {",
" input x:int;",
"}"
);
validator.assertError(parseWithoutError(testCase), LfPackage.eINSTANCE.getInput(), null,
"Main reactor cannot have inputs.");
}

@Test
public void testMainHasOutput() throws Exception {
// Java 17:
// String testCase = """
// target C;
// main reactor {
// output x:int;
// }
// """
// Java 11:
String testCase = String.join(System.getProperty("line.separator"),
"target C;",
"main reactor {",
" output x:int;",
"}"
);
validator.assertError(parseWithoutError(testCase), LfPackage.eINSTANCE.getOutput(), null,
"Main reactor cannot have outputs.");
}

@Test
public void testFederatedHasOutput() throws Exception {
// Java 17:
// String testCase = """
// target C;
// federated reactor {
// output x:int;
// }
// """
// Java 11:
String testCase = String.join(System.getProperty("line.separator"),
"target C;",
"federated reactor {",
" output x:int;",
"}"
);
validator.assertError(parseWithoutError(testCase), LfPackage.eINSTANCE.getOutput(), null,
"Main reactor cannot have outputs.");
}

@Test
public void testMultipleMainReactor() throws Exception {
// Java 17:
Expand Down

0 comments on commit 0825c08

Please sign in to comment.