diff --git a/.github/actions/prepare-build-env/action.yml b/.github/actions/prepare-build-env/action.yml index 682be37dbb..7584d5cd27 100644 --- a/.github/actions/prepare-build-env/action.yml +++ b/.github/actions/prepare-build-env/action.yml @@ -1,5 +1,11 @@ name: Set up build environment description: Set up Java and Gradle (including caching). + +inputs: + lingua-franca-dir: + description: 'Path to the lingua-franca directory' + required: false + runs: using: "composite" steps: @@ -11,3 +17,12 @@ runs: uses: gradle/gradle-build-action@v2.8.0 with: cache-read-only: false + - name: Download Gradle and print version + working-directory: ${{ inputs.lingua-franca-dir }} + run: | + # Retry 3 times before the steps actually fails + (echo "==== Gradle Download Attempt: 1 ====" && ./gradlew --version) || \ + (sleep 30 && echo "==== Gradle Download Attempt: 2 ====" && ./gradlew --version) || \ + (sleep 30 && echo "==== Gradle Download Attempt: 3 ====" && ./gradlew --version) || \ + (echo "==== Gradle Download Failed ====" && exit 1) + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d7edf2145..da1990ca3f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,4 +35,5 @@ jobs: uses: lf-lang/epoch/.github/workflows/build.yml@main with: lingua-franca-ref: ${{ github.head_ref || github.ref_name }} + lingua-franca-repo: ${{ github.event.pull_request.head.repo.full_name }} upload-artifacts: false diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 7c2d942ef8..3a0866f164 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -18,5 +18,5 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" implementation "com.diffplug.spotless:spotless-plugin-gradle:$spotlessVersion" - implementation "gradle.plugin.com.github.johnrengelman:shadow:$shadowJarVersion" + implementation "com.github.johnrengelman:shadow:$shadowJarVersion" } diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index a8cd2581d4..a6e3b64311 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -1,6 +1,6 @@ [versions] -spotlessVersion=6.11.0 +spotlessVersion=6.21.0 spotlessLibVersion=2.30.0 -kotlinVersion=1.6.21 -shadowJarVersion=7.1.2 -spotbugsPluginVersion=5.1.3 \ No newline at end of file +kotlinVersion=1.9.0 +shadowJarVersion=8.1.1 +spotbugsPluginVersion=5.1.3 diff --git a/core/src/main/java/org/lflang/AttributeUtils.java b/core/src/main/java/org/lflang/AttributeUtils.java index 381a65396c..1ed6da44e6 100644 --- a/core/src/main/java/org/lflang/AttributeUtils.java +++ b/core/src/main/java/org/lflang/AttributeUtils.java @@ -112,9 +112,6 @@ public static Attribute findAttributeByName(EObject node, String name) { */ public static List findAttributesByName(EObject node, String name) { List attrs = getAttributes(node); - if (!attrs.isEmpty()) { - System.out.println("Fun"); - } return attrs.stream() .filter( it -> diff --git a/core/src/main/java/org/lflang/LinguaFranca.xtext b/core/src/main/java/org/lflang/LinguaFranca.xtext index b00456ce07..593b06317e 100644 --- a/core/src/main/java/org/lflang/LinguaFranca.xtext +++ b/core/src/main/java/org/lflang/LinguaFranca.xtext @@ -320,6 +320,7 @@ Expression: | ParameterReference | {CodeExpr} code=Code | BracedListExpression + | BracketListExpression ; // A list of expressions within braces. @@ -328,6 +329,13 @@ BracedListExpression: '{' {BracedListExpression} (items+=Expression (',' items+=Expression)*)? ','? '}' ; +// A list of expressions within square brackets. +// In Python and TS, this is a list literal. In Rust this could be an array but Rust +// array expressions are relatively rare so probably not worth supporting. +BracketListExpression: + '[' {BracketListExpression} (items+=Expression (',' items+=Expression)*)? ','? ']' +; + ParameterReference: parameter=[Parameter] ; diff --git a/core/src/main/java/org/lflang/Target.java b/core/src/main/java/org/lflang/Target.java index 5e9f72fea1..dc1a78d65f 100644 --- a/core/src/main/java/org/lflang/Target.java +++ b/core/src/main/java/org/lflang/Target.java @@ -485,6 +485,11 @@ public boolean allowsBracedListExpressions() { return this == C || this == CCPP || this == CPP; } + /** Allow expressions of the form {@code [a, b, c]}. */ + public boolean allowsBracketListExpressions() { + return this == Python || this == TS || this == Rust; + } + /** Return a string that demarcates the beginning of a single-line comment. */ public String getSingleLineCommentPrefix() { return this.equals(Target.Python) ? "#" : "//"; diff --git a/core/src/main/java/org/lflang/ast/IsEqual.java b/core/src/main/java/org/lflang/ast/IsEqual.java index af06923d35..9ac2a0a389 100644 --- a/core/src/main/java/org/lflang/ast/IsEqual.java +++ b/core/src/main/java/org/lflang/ast/IsEqual.java @@ -16,6 +16,7 @@ import org.lflang.lf.AttrParm; import org.lflang.lf.Attribute; import org.lflang.lf.BracedListExpression; +import org.lflang.lf.BracketListExpression; import org.lflang.lf.BuiltinTriggerRef; import org.lflang.lf.Code; import org.lflang.lf.CodeExpr; @@ -465,6 +466,13 @@ public Boolean caseBracedListExpression(BracedListExpression object) { .conclusion; } + @Override + public Boolean caseBracketListExpression(BracketListExpression object) { + return new ComparisonMachine<>(object, BracketListExpression.class) + .listsEquivalent(BracketListExpression::getItems) + .conclusion; + } + @Override public Boolean caseParameterReference(ParameterReference object) { return new ComparisonMachine<>(object, ParameterReference.class) diff --git a/core/src/main/java/org/lflang/ast/ToLf.java b/core/src/main/java/org/lflang/ast/ToLf.java index b91ea5499c..dd8096a5e3 100644 --- a/core/src/main/java/org/lflang/ast/ToLf.java +++ b/core/src/main/java/org/lflang/ast/ToLf.java @@ -30,6 +30,7 @@ import org.lflang.lf.AttrParm; import org.lflang.lf.Attribute; import org.lflang.lf.BracedListExpression; +import org.lflang.lf.BracketListExpression; import org.lflang.lf.BuiltinTriggerRef; import org.lflang.lf.Code; import org.lflang.lf.CodeExpr; @@ -873,6 +874,14 @@ public MalleableString caseBracedListExpression(BracedListExpression object) { return bracedListExpression(object.getItems()); } + @Override + public MalleableString caseBracketListExpression(BracketListExpression object) { + if (object.getItems().isEmpty()) { + return MalleableString.anyOf("[]"); + } + return list(", ", "[", "]", false, false, true, object.getItems()); + } + /** * Represent a braced list expression. Do not invoke on expressions that may have comments * attached. diff --git a/core/src/main/java/org/lflang/ast/ToText.java b/core/src/main/java/org/lflang/ast/ToText.java index 6845fde4e7..515eb29fe5 100644 --- a/core/src/main/java/org/lflang/ast/ToText.java +++ b/core/src/main/java/org/lflang/ast/ToText.java @@ -6,6 +6,7 @@ import org.eclipse.xtext.nodemodel.util.NodeModelUtils; import org.lflang.lf.ArraySpec; import org.lflang.lf.BracedListExpression; +import org.lflang.lf.BracketListExpression; import org.lflang.lf.Code; import org.lflang.lf.CodeExpr; import org.lflang.lf.Host; @@ -80,6 +81,11 @@ public String caseBracedListExpression(BracedListExpression object) { return new ToLf().caseBracedListExpression(object).toString(); } + @Override + public String caseBracketListExpression(BracketListExpression object) { + return new ToLf().caseBracketListExpression(object).toString(); + } + @Override public String caseHost(Host host) { return new ToLf().caseHost(host).toString(); diff --git a/core/src/main/java/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java b/core/src/main/java/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java index b51822c9a5..fff1ccf873 100644 --- a/core/src/main/java/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java +++ b/core/src/main/java/org/lflang/diagram/synthesis/LinguaFrancaSynthesis.java @@ -237,8 +237,6 @@ public class LinguaFrancaSynthesis extends AbstractDiagramSynthesis { SynthesisOption.createCheckOption("Multiport Widths", false).setCategory(APPEARANCE); public static final SynthesisOption SHOW_REACTION_CODE = SynthesisOption.createCheckOption("Reaction Code", false).setCategory(APPEARANCE); - public static final SynthesisOption SHOW_REACTION_LEVEL = - SynthesisOption.createCheckOption("Reaction Level", false).setCategory(APPEARANCE); public static final SynthesisOption SHOW_REACTION_ORDER_EDGES = SynthesisOption.createCheckOption("Reaction Order Edges", false).setCategory(APPEARANCE); public static final SynthesisOption SHOW_REACTOR_HOST = @@ -257,6 +255,9 @@ public class LinguaFrancaSynthesis extends AbstractDiagramSynthesis { SynthesisOption.createRangeOption("Reactor Parameter/Variable Columns", 1, 10, 1) .setCategory(APPEARANCE); + public static final SynthesisOption DEFAULT_EXPAND_ALL = + SynthesisOption.createCheckOption("Expand reactors by default", false); + public static final SynthesisOption FIXED_PORT_SIDE = SynthesisOption.createCheckOption("Fixed Port Sides", true).setCategory(LAYOUT); public static final SynthesisOption SPACING = @@ -273,6 +274,7 @@ public class LinguaFrancaSynthesis extends AbstractDiagramSynthesis { public List getDisplayedSynthesisOptions() { return List.of( SHOW_ALL_REACTORS, + DEFAULT_EXPAND_ALL, MemorizingExpandCollapseAction.MEMORIZE_EXPANSION_STATES, CYCLE_DETECTION, APPEARANCE, @@ -287,7 +289,6 @@ public List getDisplayedSynthesisOptions() { SHOW_PORT_NAMES, SHOW_MULTIPORT_WIDTH, SHOW_REACTION_CODE, - SHOW_REACTION_LEVEL, SHOW_REACTION_ORDER_EDGES, SHOW_REACTOR_HOST, SHOW_INSTANCE_NAMES, @@ -1019,18 +1020,16 @@ private Collection transformReactorNetwork( TriggerInstance reset = null; // Transform instances - int index = 0; for (ReactorInstance child : reactorInstance.children) { Boolean expansionState = MemorizingExpandCollapseAction.getExpansionState(child); Collection rNodes = createReactorNode( child, - expansionState != null ? expansionState : false, + expansionState != null ? expansionState : getBooleanValue(DEFAULT_EXPAND_ALL), inputPorts, outputPorts, allReactorNodes); nodes.addAll(rNodes); - index++; } // Create timers diff --git a/core/src/main/java/org/lflang/diagram/synthesis/styles/LinguaFrancaShapeExtensions.java b/core/src/main/java/org/lflang/diagram/synthesis/styles/LinguaFrancaShapeExtensions.java index b8ee69fa1c..37e82250ea 100644 --- a/core/src/main/java/org/lflang/diagram/synthesis/styles/LinguaFrancaShapeExtensions.java +++ b/core/src/main/java/org/lflang/diagram/synthesis/styles/LinguaFrancaShapeExtensions.java @@ -72,7 +72,6 @@ import org.eclipse.elk.graph.properties.Property; import org.eclipse.xtext.xbase.lib.Extension; import org.eclipse.xtext.xbase.lib.Functions.Function1; -import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.eclipse.xtext.xbase.lib.Pair; import org.eclipse.xtext.xbase.lib.StringExtensions; import org.lflang.ast.ASTUtils; @@ -424,26 +423,10 @@ public KPolygon addReactionFigure(KNode node, ReactionInstance reaction) { DiagramSyntheses.suppressSelectability(textToAdd); } - // optional reaction level - if (getBooleanValue(LinguaFrancaSynthesis.SHOW_REACTION_LEVEL)) { - // Force calculation of levels for reactions. This calculation - // will only be done once. Note that if this fails due to a causality loop, - // then some reactions will have level -1. - try { - String levels = IterableExtensions.join(reaction.getLevels(), ", "); - KText levelsText = - _kContainerRenderingExtensions.addText(contentContainer, ("level: " + levels)); - _kRenderingExtensions.setFontBold(levelsText, false); - _linguaFrancaStyleExtensions.noSelectionStyle(levelsText); - DiagramSyntheses.suppressSelectability(levelsText); - } catch (Exception ex) { - // If the graph has cycles, the above fails. Continue without showing levels. - } - } - // optional code content boolean hasCode = getBooleanValue(LinguaFrancaSynthesis.SHOW_REACTION_CODE) + && reaction.getDefinition().getCode() != null && !StringExtensions.isNullOrEmpty(reaction.getDefinition().getCode().getBody()); if (hasCode) { KText hasCodeText = diff --git a/core/src/main/java/org/lflang/generator/LfExpressionVisitor.java b/core/src/main/java/org/lflang/generator/LfExpressionVisitor.java index 15f0e8ddad..c50f805209 100644 --- a/core/src/main/java/org/lflang/generator/LfExpressionVisitor.java +++ b/core/src/main/java/org/lflang/generator/LfExpressionVisitor.java @@ -25,6 +25,7 @@ package org.lflang.generator; import org.lflang.lf.BracedListExpression; +import org.lflang.lf.BracketListExpression; import org.lflang.lf.Code; import org.lflang.lf.CodeExpr; import org.lflang.lf.Expression; @@ -44,6 +45,8 @@ public interface LfExpressionVisitor { R visitBracedListExpr(BracedListExpression expr, P param); + R visitBracketListExpr(BracketListExpression expr, P param); + R visitTimeLiteral(Time expr, P param); R visitCodeExpr(CodeExpr expr, P param); @@ -66,6 +69,8 @@ static R dispatch( return visitor.visitLiteral((Literal) e, arg); } else if (e instanceof BracedListExpression) { return visitor.visitBracedListExpr((BracedListExpression) e, arg); + } else if (e instanceof BracketListExpression) { + return visitor.visitBracketListExpr((BracketListExpression) e, arg); } else if (e instanceof Time) { return visitor.visitTimeLiteral((Time) e, arg); } else if (e instanceof CodeExpr) { @@ -106,6 +111,11 @@ public R visitCodeExpr(CodeExpr expr, P param) { public R visitParameterRef(ParameterReference expr, P param) { return visitExpression(expr, param); } + + @Override + public R visitBracketListExpr(BracketListExpression expr, P param) { + return visitExpression(expr, param); + } } /** @@ -147,6 +157,15 @@ public Expression visitParameterRef(ParameterReference expr, P param) { return clone; } + @Override + public Expression visitBracketListExpr(BracketListExpression expr, P param) { + BracketListExpression clone = LfFactory.eINSTANCE.createBracketListExpression(); + for (Expression item : expr.getItems()) { + clone.getItems().add(dispatch(item, param, this)); + } + return clone; + } + @Override public Expression visitCodeExpr(CodeExpr expr, P param) { CodeExpr codeExpr = LfFactory.eINSTANCE.createCodeExpr(); diff --git a/core/src/main/java/org/lflang/generator/TargetTypes.java b/core/src/main/java/org/lflang/generator/TargetTypes.java index 968a641ed3..65552edc59 100644 --- a/core/src/main/java/org/lflang/generator/TargetTypes.java +++ b/core/src/main/java/org/lflang/generator/TargetTypes.java @@ -8,6 +8,7 @@ import org.lflang.ast.ASTUtils; import org.lflang.lf.Action; import org.lflang.lf.BracedListExpression; +import org.lflang.lf.BracketListExpression; import org.lflang.lf.CodeExpr; import org.lflang.lf.Expression; import org.lflang.lf.Initializer; @@ -60,6 +61,14 @@ default String getTargetBracedListExpr(BracedListExpression expr, InferredType t .collect(Collectors.joining(",", "{", "}")); } + /** Translate the bracket list expression into target language syntax. */ + default String getTargetBracketListExpr(BracketListExpression expr, InferredType typeOrNull) { + InferredType t = typeOrNull == null ? InferredType.undefined() : typeOrNull; + return expr.getItems().stream() + .map(e -> getTargetExpr(e, t)) + .collect(Collectors.joining(", ", "[", "]")); + } + /** Return an "unknown" type which is used as a default when a type cannot be inferred. */ String getTargetUndefinedType(); @@ -224,6 +233,8 @@ default String getTargetExpr(Expression expr, InferredType type) { return ASTUtils.toText(((CodeExpr) expr).getCode()); } else if (expr instanceof BracedListExpression) { return getTargetBracedListExpr((BracedListExpression) expr, type); + } else if (expr instanceof BracketListExpression) { + return getTargetBracketListExpr((BracketListExpression) expr, type); } else { throw new IllegalStateException("Invalid value " + expr); } diff --git a/core/src/main/java/org/lflang/validation/LFValidator.java b/core/src/main/java/org/lflang/validation/LFValidator.java index 6bfd26bf08..dd36693d8e 100644 --- a/core/src/main/java/org/lflang/validation/LFValidator.java +++ b/core/src/main/java/org/lflang/validation/LFValidator.java @@ -73,6 +73,7 @@ import org.lflang.lf.Assignment; import org.lflang.lf.Attribute; import org.lflang.lf.BracedListExpression; +import org.lflang.lf.BracketListExpression; import org.lflang.lf.BuiltinTrigger; import org.lflang.lf.BuiltinTriggerRef; import org.lflang.lf.Connection; @@ -194,6 +195,15 @@ public void checkBracedExpression(BracedListExpression expr) { } } + @Check(CheckType.FAST) + public void checkBracketExpression(BracketListExpression expr) { + if (!target.allowsBracketListExpressions()) { + var message = + "Bracketed expression lists are not a valid expression for the " + target + " target."; + error(message, Literals.BRACKET_LIST_EXPRESSION.eContainmentFeature()); + } + } + @Check(CheckType.FAST) public void checkAssignment(Assignment assignment) { diff --git a/core/src/testFixtures/java/org/lflang/tests/LFTest.java b/core/src/testFixtures/java/org/lflang/tests/LFTest.java index e99fee4b54..1fa4184237 100644 --- a/core/src/testFixtures/java/org/lflang/tests/LFTest.java +++ b/core/src/testFixtures/java/org/lflang/tests/LFTest.java @@ -39,6 +39,12 @@ public class LFTest implements Comparable { /** String builder for collecting issues encountered during test execution. */ private final StringBuilder issues = new StringBuilder(); + /** Reference to System.out for restoring the default output. */ + private static final PrintStream out = System.out; + + /** Reference to System.err for restoring the default output. */ + private static final PrintStream err = System.err; + private long executionTimeNanoseconds; /** @@ -71,11 +77,11 @@ public void redirectOutputs() { } /** End output redirection. */ - public void restoreOutputs() { + public static void restoreOutputs() { System.out.flush(); System.err.flush(); - System.setOut(System.out); - System.setErr(System.err); + System.setOut(out); + System.setErr(err); } /** @@ -130,7 +136,7 @@ public boolean hasPassed() { return result == Result.TEST_PASS; } - /** Compile a string that contains all collected errors and return it. */ + /** Print a report of all the collected errors. */ public void reportErrors() { if (this.hasFailed()) { System.out.println( diff --git a/core/src/testFixtures/java/org/lflang/tests/TestBase.java b/core/src/testFixtures/java/org/lflang/tests/TestBase.java index ee0d72ff02..04a699068c 100644 --- a/core/src/testFixtures/java/org/lflang/tests/TestBase.java +++ b/core/src/testFixtures/java/org/lflang/tests/TestBase.java @@ -328,7 +328,7 @@ private static void checkAndReportFailures(Set tests) { var passed = tests.stream().filter(LFTest::hasPassed).toList(); var s = new StringBuffer(); s.append(THIN_LINE); - s.append("Passing: ").append(passed.size()).append("/").append(tests.size()).append("%n"); + s.append(String.format("Passing: %d/%d%n", passed.size(), tests.size())); s.append(THIN_LINE); passed.forEach( test -> diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2c3425d49e..93ac3e13b9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionSha256Sum=591855b517fc635b9e04de1d05d5e76ada3f89f5fc76f87978d1b245b4f69225 +distributionUrl=https://services.gradle.org/distributions/gradle-8.3-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/lsp/build.gradle b/lsp/build.gradle index 772f618db1..65215162b7 100644 --- a/lsp/build.gradle +++ b/lsp/build.gradle @@ -10,6 +10,13 @@ dependencies { exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt.*' exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt' } + + // This dependency ensures correct animations and bookkeeping during updates + // See https://github.com/lf-lang/vscode-lingua-franca/issues/103#issuecomment-1731023470 + implementation ("de.cau.cs.kieler.klighd:de.cau.cs.kieler.klighd.incremental:$klighdVersion") { + exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt.*' + exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt' + } } application { diff --git a/test/Python/src/ArrayAsParameter.lf b/test/Python/src/ArrayAsParameter.lf index b794008a7c..58b4cb50e3 100644 --- a/test/Python/src/ArrayAsParameter.lf +++ b/test/Python/src/ArrayAsParameter.lf @@ -1,7 +1,7 @@ # Source has an array as a parameter, the elements of which it passes to Print. target Python -reactor Source(sequence(0, 1, 2)) { +reactor Source(sequence = [0, 1, 2]) { output out state count = 0 logical action next @@ -36,7 +36,7 @@ reactor Print { } main reactor ArrayAsParameter { - s = new Source(sequence(1, 2, 3, 4)) + s = new Source(sequence = [1, 2, 3, 4]) p = new Print() s.out -> p._in } diff --git a/test/Python/src/modal_models/util/TraceTesting.lf b/test/Python/src/modal_models/util/TraceTesting.lf index 0d5053b844..027b1ccb19 100644 --- a/test/Python/src/modal_models/util/TraceTesting.lf +++ b/test/Python/src/modal_models/util/TraceTesting.lf @@ -1,12 +1,12 @@ /** Utility reactor to record and test execution traces. */ target Python -reactor TraceTesting(events_size=0, trace = {= [] =}, training=False) { +reactor TraceTesting(events_size=0, trace=[], training=False) { input[events_size] events state last_reaction_time = 0 state trace_idx = 0 - state recorded_events = {= [] =} + state recorded_events = [] state recorded_events_next = 0 reaction(startup) {= diff --git a/test/Rust/src/ArrayAsParameter.lf b/test/Rust/src/ArrayAsParameter.lf new file mode 100644 index 0000000000..2692512273 --- /dev/null +++ b/test/Rust/src/ArrayAsParameter.lf @@ -0,0 +1,36 @@ +// Source has an array as a parameter, the elements of which it passes to Print. +target Rust + +reactor Source(sequence: {= [i32; 3] =} = [0, 1, 2]) { + output out: i32 + state count: usize = 0 + state seq = sequence + logical action next + + reaction(startup, next) -> out, next {= + ctx.set(out, self.seq[self.count]); + self.count += 1; + if self.count < self.seq.len() { + ctx.schedule(next, Asap); + } + =} +} + +reactor Print { + input x: i32 + state count: usize = 0 + + reaction(x) {= + let expected = [2, 3, 4]; + let x = ctx.get(x).unwrap(); + println!("Received: {}.", x); + assert_eq!(x, expected[self.count]); + self.count += 1; + =} +} + +main reactor ArrayAsParameter { + s = new Source(sequence = [2, 3, 4]) + p = new Print() + s.out -> p.x +} diff --git a/test/TypeScript/src/ArrayAsParameter.lf b/test/TypeScript/src/ArrayAsParameter.lf index ef9ba9f414..10ef7a5c32 100644 --- a/test/TypeScript/src/ArrayAsParameter.lf +++ b/test/TypeScript/src/ArrayAsParameter.lf @@ -1,7 +1,7 @@ // Source has an array as a parameter, the elements of which it passes to Print. target TypeScript -reactor Source(sequence: {= Array =} = {= [0, 1, 2] =}) { +reactor Source(sequence: Array = [0, 1, 2]) { output out: number state count: number = 0 logical action next @@ -29,7 +29,7 @@ reactor Print { } main reactor ArrayAsParameter { - s = new Source(sequence = {= [1, 2, 3, 4] =}) + s = new Source(sequence = [1, 2, 3, 4]) p = new Print() s.out -> p.x } diff --git a/test/TypeScript/src/MovingAverage.lf b/test/TypeScript/src/MovingAverage.lf index f99e436ab7..dfe550f612 100644 --- a/test/TypeScript/src/MovingAverage.lf +++ b/test/TypeScript/src/MovingAverage.lf @@ -17,7 +17,7 @@ reactor Source { } reactor MovingAverageImpl { - state delay_line: {= Array =} = {= [0.0, 0.0, 0.0] =} + state delay_line: Array = [0.0, 0.0, 0.0] state index: number = 0 input x: number output out: number