diff --git a/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java b/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java index 2ed0e60abe..a400ad69d3 100644 --- a/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java +++ b/core/src/test/java/org/lflang/tests/compiler/LinguaFrancaValidationTest.java @@ -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; @@ -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 + main reactor { + state foo: int(0) + } + """ + .replace("", target); + String error = + "The target does not support brace or parenthesis based initialization. Please use the assignment operator '=' instead." + .replace("", 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 + main reactor { + state foo: int{0} + } + """ + .replace("", target); + String error = + "The target does not support brace or parenthesis based initialization. Please use the assignment operator '=' instead." + .replace("", 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 {