diff --git a/test/TypeScript/src/federated/ChainWithDelay.lf b/test/TypeScript/src/federated/ChainWithDelay.lf new file mode 100644 index 0000000000..0c774a841e --- /dev/null +++ b/test/TypeScript/src/federated/ChainWithDelay.lf @@ -0,0 +1,20 @@ +/** + * Demonstration that monotonic NET hypothesis is invalid. + * + * @author Edward A. Lee + * @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; +} diff --git a/test/TypeScript/src/federated/TopLevelArtifacts.lf b/test/TypeScript/src/federated/TopLevelArtifacts.lf new file mode 100644 index 0000000000..188fdc3246 --- /dev/null +++ b/test/TypeScript/src/federated/TopLevelArtifacts.lf @@ -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!`); + =} +} diff --git a/test/TypeScript/src/lib/InternalDelay.lf b/test/TypeScript/src/lib/InternalDelay.lf new file mode 100644 index 0000000000..63ca3a9969 --- /dev/null +++ b/test/TypeScript/src/lib/InternalDelay.lf @@ -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; + =} +}