Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added federated tests for TypeScript target #1159

Merged
merged 3 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/TypeScript/src/federated/ChainWithDelay.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Demonstration that monotonic NET hypothesis is invalid.
*
* @author Edward A. Lee
hokeun marked this conversation as resolved.
Show resolved Hide resolved
* @author Youri Su
*/
target TypeScript {
timeout: 3 msec
}
import Count from "../lib/Count.lf";
import InternalDelay from "../lib/InternalDelay.lf";
import TestCount from "../lib/TestCount.lf";

federated reactor {
c = new Count(period = 1 msec);
i = new InternalDelay(delay = 500 usec);
t = new TestCount(numInputs = 3);
c.out -> i.inp;
i.out -> t.inp;
}
hokeun marked this conversation as resolved.
Show resolved Hide resolved
43 changes: 43 additions & 0 deletions test/TypeScript/src/federated/TopLevelArtifacts.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Test whether top-level reactions, actions, and ports are handled appropriately.
*
* Currently, these artifacts are replicated on all federates.
*
* @note This just tests for the correctness of the code generation. These top-level
* artifacts might be disallowed in the future.
* @author Youri Su
*/

target TypeScript {
timeout: 1 msec
};

import Count from "../lib/Count.lf";
import TestCount from "../lib/TestCount.lf";

federated reactor {
state successes:number(0);
logical action act;
reaction (startup) {=
successes++;
=}
timer t(0, 1 sec);
reaction (t) -> act {=
successes++;
actions.act.schedule(0, null);
=}
reaction (act) {=
successes++;
=}

c = new Count();
tc = new TestCount();
c.out -> tc.inp;

reaction (shutdown) {=
if (successes != 3) {
util.requestErrorStop(`Failed to properly execute top-level reactions`);
}
console.log(`SUCCESS!`);
=}
}
17 changes: 17 additions & 0 deletions test/TypeScript/src/lib/InternalDelay.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @author Youri Su
*/
target TypeScript;
reactor InternalDelay (
delay:TimeValue(10 msec)
) {
input inp:number;
output out:number;
logical action d:number;
reaction(inp) -> d {=
actions.d.schedule(delay, inp as number);
=}
reaction(d) -> out {=
out = d;
=}
}