Skip to content

Commit

Permalink
add unit test checking that paren and brace initialization are disall…
Browse files Browse the repository at this point in the history
…owed
  • Loading branch information
cmnrd committed Mar 7, 2024
1 parent 1c8fca1 commit 1459b52
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.lflang.TimeValue;
import org.lflang.lf.LfPackage;
import org.lflang.lf.Model;
Expand Down Expand Up @@ -458,6 +460,42 @@ public void disallowUnderscoreReactorInstantiation() throws Exception {
+ " definitions, and reactor instantiation) may not start with \"__\": __x");
}

@ParameterizedTest
@ValueSource(strings = {"C", "CCpp", "Rust", "TypeScript", "Python"})
public void disallowParenthesisInitialization(String target) throws Exception {
String testCase =
"""
target <target>
main reactor {
state foo: int(0)
}
"""
.replace("<target>", target);
String error =
"The <target> target does not support brace or parenthesis based initialization. Please use the assignment operator '=' instead."
.replace("<target>", target);
validator.assertError(
parseWithoutError(testCase), LfPackage.eINSTANCE.getInitializer(), null, error);
}

@ParameterizedTest
@ValueSource(strings = {"C", "CCpp", "Rust", "TypeScript", "Python"})
public void disallowBraceInitialization(String target) throws Exception {
String testCase =
"""
target <target>
main reactor {
state foo: int{0}
}
"""
.replace("<target>", target);
String error =
"The <target> target does not support brace or parenthesis based initialization. Please use the assignment operator '=' instead."
.replace("<target>", target);
validator.assertError(
parseWithoutError(testCase), LfPackage.eINSTANCE.getInitializer(), null, error);
}

/** Disallow connection to port that is effect of reaction. */
@Test
public void connectionToEffectPort() throws Exception {
Expand Down

0 comments on commit 1459b52

Please sign in to comment.