From 9ea0bda22ab8110eea10fea7438101586781a391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=9C=A0=EB=A6=AC?= Date: Wed, 11 May 2022 22:48:36 +0900 Subject: [PATCH 1/3] ts tests for federated execution: ChainWithDelay, TopLevelArtifacts, InternalDelay(lib) --- .../src/federated/ChainWithDelay.lf | 19 +++++++++ .../src/federated/TopLevelArtifacts.lf | 42 +++++++++++++++++++ test/TypeScript/src/lib/InternalDelay.lf | 14 +++++++ 3 files changed, 75 insertions(+) create mode 100644 test/TypeScript/src/federated/ChainWithDelay.lf create mode 100644 test/TypeScript/src/federated/TopLevelArtifacts.lf create mode 100644 test/TypeScript/src/lib/InternalDelay.lf diff --git a/test/TypeScript/src/federated/ChainWithDelay.lf b/test/TypeScript/src/federated/ChainWithDelay.lf new file mode 100644 index 0000000000..b184a582ad --- /dev/null +++ b/test/TypeScript/src/federated/ChainWithDelay.lf @@ -0,0 +1,19 @@ +/** + * Demonstration that monotonic NET hypothesis is invalid. + * + * @author Edward A. Lee + */ + 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..3c3ce86a39 --- /dev/null +++ b/test/TypeScript/src/federated/TopLevelArtifacts.lf @@ -0,0 +1,42 @@ +/** + * 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. + */ + + 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!`); + =} +} \ No newline at end of file diff --git a/test/TypeScript/src/lib/InternalDelay.lf b/test/TypeScript/src/lib/InternalDelay.lf new file mode 100644 index 0000000000..e1b49a997e --- /dev/null +++ b/test/TypeScript/src/lib/InternalDelay.lf @@ -0,0 +1,14 @@ +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; + =} +} \ No newline at end of file From 649865f55728968de2be6e48201c28b413c76873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=9C=A0=EB=A6=AC?= Date: Mon, 16 May 2022 10:56:39 +0900 Subject: [PATCH 2/3] TypeScript test codes for federated execution(name added) --- test/TypeScript/src/federated/ChainWithDelay.lf | 1 + test/TypeScript/src/federated/TopLevelArtifacts.lf | 1 + test/TypeScript/src/lib/InternalDelay.lf | 3 +++ 3 files changed, 5 insertions(+) diff --git a/test/TypeScript/src/federated/ChainWithDelay.lf b/test/TypeScript/src/federated/ChainWithDelay.lf index b184a582ad..0c774a841e 100644 --- a/test/TypeScript/src/federated/ChainWithDelay.lf +++ b/test/TypeScript/src/federated/ChainWithDelay.lf @@ -2,6 +2,7 @@ * Demonstration that monotonic NET hypothesis is invalid. * * @author Edward A. Lee + * @author Youri Su */ target TypeScript { timeout: 3 msec diff --git a/test/TypeScript/src/federated/TopLevelArtifacts.lf b/test/TypeScript/src/federated/TopLevelArtifacts.lf index 3c3ce86a39..bee5b79a2f 100644 --- a/test/TypeScript/src/federated/TopLevelArtifacts.lf +++ b/test/TypeScript/src/federated/TopLevelArtifacts.lf @@ -5,6 +5,7 @@ * * @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 { diff --git a/test/TypeScript/src/lib/InternalDelay.lf b/test/TypeScript/src/lib/InternalDelay.lf index e1b49a997e..12014584c4 100644 --- a/test/TypeScript/src/lib/InternalDelay.lf +++ b/test/TypeScript/src/lib/InternalDelay.lf @@ -1,3 +1,6 @@ +/** +@author Youri Su +*/ target TypeScript; reactor InternalDelay ( delay:TimeValue(10 msec) From ce22c4dc4a0aa86a5385ac8ba2d9b9abc3a96182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9C=EC=9C=A0=EB=A6=AC?= Date: Mon, 16 May 2022 14:17:02 +0900 Subject: [PATCH 3/3] indentation and newlines added --- test/TypeScript/src/federated/TopLevelArtifacts.lf | 2 +- test/TypeScript/src/lib/InternalDelay.lf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/TypeScript/src/federated/TopLevelArtifacts.lf b/test/TypeScript/src/federated/TopLevelArtifacts.lf index bee5b79a2f..188fdc3246 100644 --- a/test/TypeScript/src/federated/TopLevelArtifacts.lf +++ b/test/TypeScript/src/federated/TopLevelArtifacts.lf @@ -40,4 +40,4 @@ } console.log(`SUCCESS!`); =} -} \ No newline at end of file +} diff --git a/test/TypeScript/src/lib/InternalDelay.lf b/test/TypeScript/src/lib/InternalDelay.lf index 12014584c4..63ca3a9969 100644 --- a/test/TypeScript/src/lib/InternalDelay.lf +++ b/test/TypeScript/src/lib/InternalDelay.lf @@ -1,6 +1,6 @@ /** -@author Youri Su -*/ + * @author Youri Su + */ target TypeScript; reactor InternalDelay ( delay:TimeValue(10 msec) @@ -14,4 +14,4 @@ reactor InternalDelay ( reaction(d) -> out {= out = d; =} -} \ No newline at end of file +}