From 20a8cf1d058546a304d404bed50f33d9fcd7d29b Mon Sep 17 00:00:00 2001 From: Kagamihara Nadeshiko Date: Sat, 1 Jul 2023 00:12:11 -0700 Subject: [PATCH] Run prettier --- __tests__/Adder.test.ts | 7 +-- __tests__/CausalityGraph.test.ts | 7 +-- __tests__/InvalidMutations.ts | 7 +-- __tests__/OutputEvent.test.ts | 7 +-- __tests__/OutputGet.test.ts | 38 ++++++-------- __tests__/SimpleMutation.test.ts | 7 +-- __tests__/action.test.ts | 26 +++++----- __tests__/multiport.test.ts | 42 +++++++--------- __tests__/mutations.test.ts | 82 +++++++++++++------------------ __tests__/port.errors.test.ts | 7 +-- __tests__/reactors.test.ts | 10 ++-- src/benchmark/FacilityLocation.ts | 7 +-- src/benchmark/PingPong.ts | 10 ++-- src/benchmark/Sieve.ts | 21 ++++---- src/core/reactor.ts | 4 +- src/core/trigger.ts | 5 +- src/share/Logger.ts | 6 +-- 17 files changed, 106 insertions(+), 187 deletions(-) diff --git a/__tests__/Adder.test.ts b/__tests__/Adder.test.ts index 78bcea566..3d4848173 100644 --- a/__tests__/Adder.test.ts +++ b/__tests__/Adder.test.ts @@ -1,10 +1,5 @@ import type {IOPort} from "../src/core/internal"; -import { - App, - Reactor, - InPort, - OutPort -} from "../src/core/internal"; +import {App, Reactor, InPort, OutPort} from "../src/core/internal"; export class Adder extends Reactor { in1 = new InPort(this); diff --git a/__tests__/CausalityGraph.test.ts b/__tests__/CausalityGraph.test.ts index 4ba6a3472..93716bf8c 100644 --- a/__tests__/CausalityGraph.test.ts +++ b/__tests__/CausalityGraph.test.ts @@ -1,9 +1,4 @@ -import { - Reactor, - App, - OutPort, - InPort, -} from "../src/core/internal"; +import {Reactor, App, OutPort, InPort} from "../src/core/internal"; /* Set a port in startup to get thing going */ class Starter extends Reactor { diff --git a/__tests__/InvalidMutations.ts b/__tests__/InvalidMutations.ts index 84029dc3e..17b62f6bf 100644 --- a/__tests__/InvalidMutations.ts +++ b/__tests__/InvalidMutations.ts @@ -1,9 +1,4 @@ -import { - Reactor, - App, - OutPort, - InPort -} from "../src/core/internal"; +import {Reactor, App, OutPort, InPort} from "../src/core/internal"; class Starter extends Reactor { public out = new OutPort(this); diff --git a/__tests__/OutputEvent.test.ts b/__tests__/OutputEvent.test.ts index 887053ead..8ae0fd396 100644 --- a/__tests__/OutputEvent.test.ts +++ b/__tests__/OutputEvent.test.ts @@ -1,9 +1,4 @@ -import { - App, - Reactor, - Parameter, - TimeValue -} from "../src/core/internal"; +import {App, Reactor, Parameter, TimeValue} from "../src/core/internal"; import {SingleEvent} from "../src/share/SingleEvent"; /** diff --git a/__tests__/OutputGet.test.ts b/__tests__/OutputGet.test.ts index f361cbbe7..9ae98e4e3 100644 --- a/__tests__/OutputGet.test.ts +++ b/__tests__/OutputGet.test.ts @@ -1,10 +1,4 @@ -import { - App, - Timer, - OutPort, - TimeValue, - Log -} from "../src/core/internal"; +import {App, Timer, OutPort, TimeValue, Log} from "../src/core/internal"; class OutputGetTest extends App { o: OutPort = new OutPort(this); @@ -19,24 +13,20 @@ class OutputGetTest extends App { ) { super(timeout, true, false, success, failure); Log.global.debug(">>>>>>>>----" + this.util); - this.addReaction( - [this.t], - [this.writable(this.o)], - function (this, o) { - Log.global.debug(">>>>>>>>>>being triggered>>>>>>>>>>>"); - if (o.get() != null) { - throw new Error( - "Calling get on an output before it has been set does not return null" - ); - } - o.set(5); - if (o.get() !== 5) { - throw new Error( - "Calling get on an output after it has been set does not return the set value" - ); - } + this.addReaction([this.t], [this.writable(this.o)], function (this, o) { + Log.global.debug(">>>>>>>>>>being triggered>>>>>>>>>>>"); + if (o.get() != null) { + throw new Error( + "Calling get on an output before it has been set does not return null" + ); } - ); + o.set(5); + if (o.get() !== 5) { + throw new Error( + "Calling get on an output after it has been set does not return the set value" + ); + } + }); } } diff --git a/__tests__/SimpleMutation.test.ts b/__tests__/SimpleMutation.test.ts index ce52f6576..e85d06766 100644 --- a/__tests__/SimpleMutation.test.ts +++ b/__tests__/SimpleMutation.test.ts @@ -1,9 +1,4 @@ -import { - Reactor, - App, - OutPort, - InPort, -} from "../src/core/internal"; +import {Reactor, App, OutPort, InPort} from "../src/core/internal"; /* Set a port in startup to get thing going */ class Starter extends Reactor { diff --git a/__tests__/action.test.ts b/__tests__/action.test.ts index 58db6089b..3f13d376c 100644 --- a/__tests__/action.test.ts +++ b/__tests__/action.test.ts @@ -4,7 +4,7 @@ import { FederatePortAction, App, Origin, - TimeValue, + TimeValue } from "../src/core/internal"; let intendedTagDelay: TimeValue | undefined; @@ -27,21 +27,17 @@ class ReactorWithFederatePortAction extends App { } ); - this.addReaction( - [this.a], - [this.schedulable(this.f)], - function (this, f) { - let intendedTag: Tag | undefined; - if (intendedTagDelay === undefined) { - intendedTag = undefined; - } else { - intendedTag = startUpTag - .getLaterTag(intendedTagDelay) - .getMicroStepsLater(intendedTagMicrostepDelay); - } - f.schedule(0, 0, intendedTag); + this.addReaction([this.a], [this.schedulable(this.f)], function (this, f) { + let intendedTag: Tag | undefined; + if (intendedTagDelay === undefined) { + intendedTag = undefined; + } else { + intendedTag = startUpTag + .getLaterTag(intendedTagDelay) + .getMicroStepsLater(intendedTagMicrostepDelay); } - ); + f.schedule(0, 0, intendedTag); + }); } public setLastTagProvisional(value: boolean) { diff --git a/__tests__/multiport.test.ts b/__tests__/multiport.test.ts index 92670150a..afc974f22 100644 --- a/__tests__/multiport.test.ts +++ b/__tests__/multiport.test.ts @@ -5,7 +5,7 @@ import { OutMultiPort, IOPort, OutPort, - InPort, + InPort } from "../src/core/internal"; class TwoInTwoOut extends Reactor { inp = new InMultiPort(this, 2); @@ -47,30 +47,22 @@ class TwoInTwoOut extends Reactor { expect(this.inp.width()).toBe(2); expect(writer.width()).toBe(2); }); - this.addReaction( - [this.inp], - [this.inp], - function (this, inp) { - test("check read values", () => { - expect(inp.channel(0).get()).toBe(42); - expect(inp.get(0)).toBe(42); - expect(inp.channel(1).get()).toBe(69); - expect(inp.get(1)).toBe(69); - expect(inp.values()).toEqual([42, 69]); - }); - test("print input port names", () => { - expect(inp._getName()).toBe("inp"); - expect(inp.channel(0)._getName()).toBe("inp[0]"); - expect(inp.channel(1)._getName()).toBe("inp[1]"); - expect(inp.channel(0)._getFullyQualifiedName()).toBe( - "myApp.y.inp[0]" - ); - expect(inp.channel(1)._getFullyQualifiedName()).toBe( - "myApp.y.inp[1]" - ); - }); - } - ); + this.addReaction([this.inp], [this.inp], function (this, inp) { + test("check read values", () => { + expect(inp.channel(0).get()).toBe(42); + expect(inp.get(0)).toBe(42); + expect(inp.channel(1).get()).toBe(69); + expect(inp.get(1)).toBe(69); + expect(inp.values()).toEqual([42, 69]); + }); + test("print input port names", () => { + expect(inp._getName()).toBe("inp"); + expect(inp.channel(0)._getName()).toBe("inp[0]"); + expect(inp.channel(1)._getName()).toBe("inp[1]"); + expect(inp.channel(0)._getFullyQualifiedName()).toBe("myApp.y.inp[0]"); + expect(inp.channel(1)._getFullyQualifiedName()).toBe("myApp.y.inp[1]"); + }); + }); this.addReaction( [this.startup], [this.allWritable(this.out)], diff --git a/__tests__/mutations.test.ts b/__tests__/mutations.test.ts index 5360a57cf..71d3a2894 100644 --- a/__tests__/mutations.test.ts +++ b/__tests__/mutations.test.ts @@ -4,7 +4,7 @@ import { Timer, OutPort, InPort, - TimeValue, + TimeValue } from "../src/core/internal"; class Source extends Reactor { @@ -51,28 +51,24 @@ class Print extends Reactor { constructor(owner: Reactor) { super(owner); - this.addReaction( - [this.input], - [this.input], - function (this, input) { - const val = input.get(); - console.log("Print reacting..."); - if (val !== undefined) { - const expected = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; - for (let i = 0; i < 10; i++) { - if (val[i] != expected[i]) { - this.util.requestErrorStop( - "Expected: " + expected + " but got: " + val - ); - return; - } + this.addReaction([this.input], [this.input], function (this, input) { + const val = input.get(); + console.log("Print reacting..."); + if (val !== undefined) { + const expected = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + for (let i = 0; i < 10; i++) { + if (val[i] != expected[i]) { + this.util.requestErrorStop( + "Expected: " + expected + " but got: " + val + ); + return; } - console.log("Expected: " + expected + " and got: " + val); - } else { - this.util.requestErrorStop("Input undefined."); } + console.log("Expected: " + expected + " and got: " + val); + } else { + this.util.requestErrorStop("Input undefined."); } - ); + }); } } @@ -86,24 +82,20 @@ class Computer extends Reactor { constructor(container: Reactor) { super(container); this._connect(this.in, this.adder.input); - this.addMutation( - [this.in], - [this.in], - function (this, src) { - const vals = src.get(); - if (vals) { - let skip = true; - for (const id of vals.keys()) { - if (skip) { - skip = false; - continue; - } - const x = new AddOne(this.getReactor(), id); - this.connect(src, x.input); + this.addMutation([this.in], [this.in], function (this, src) { + const vals = src.get(); + if (vals) { + let skip = true; + for (const id of vals.keys()) { + if (skip) { + skip = false; + continue; } + const x = new AddOne(this.getReactor(), id); + this.connect(src, x.input); } } - ); + }); this.addReaction( [this.adder.output], [this.adder.output, this.writable(this.out)], @@ -142,24 +134,16 @@ class ZenoClock extends Reactor { super(owner); console.log("Creating ZenoClock " + iteration); this.tick = new Timer(this, 0, 0); - this.addReaction( - [this.tick], - [this.tick], - function (this, tick) { - console.log("Tick at " + this.util.getElapsedLogicalTime()); - } - ); + this.addReaction([this.tick], [this.tick], function (this, tick) { + console.log("Tick at " + this.util.getElapsedLogicalTime()); + }); this.addReaction([this.shutdown], [], function (this) { console.log("Shutdown reaction of reactor " + iteration); }); if (iteration < 5) { - this.addMutation( - [this.tick], - [this.tick], - function (this, tick) { - new ZenoClock(this.getReactor(), iteration + 1); - } - ); + this.addMutation([this.tick], [this.tick], function (this, tick) { + new ZenoClock(this.getReactor(), iteration + 1); + }); } else { this.util.requestStop(); } diff --git a/__tests__/port.errors.test.ts b/__tests__/port.errors.test.ts index 388e92d49..fc4ce5766 100644 --- a/__tests__/port.errors.test.ts +++ b/__tests__/port.errors.test.ts @@ -1,9 +1,4 @@ -import { - Reactor, - App, - InPort, - OutPort -} from "../src/core/internal"; +import {Reactor, App, InPort, OutPort} from "../src/core/internal"; class R1 extends Reactor { inp = new InPort(this); diff --git a/__tests__/reactors.test.ts b/__tests__/reactors.test.ts index 0b0e766a1..051308956 100644 --- a/__tests__/reactors.test.ts +++ b/__tests__/reactors.test.ts @@ -153,13 +153,9 @@ class ReactorWithAction extends App { deadlineMiss?: () => void ) { super(timeout, false, false, success, fail); - this.addReaction( - [this.t], - [this.schedulable(this.a)], - function (this, a) { - a.schedule(0, 1); - } - ); + this.addReaction([this.t], [this.schedulable(this.a)], function (this, a) { + a.schedule(0, 1); + }); } } diff --git a/src/benchmark/FacilityLocation.ts b/src/benchmark/FacilityLocation.ts index d91e50d70..d8395e652 100644 --- a/src/benchmark/FacilityLocation.ts +++ b/src/benchmark/FacilityLocation.ts @@ -197,12 +197,13 @@ export class Producer extends Reactor { ); this.addReaction( [this.startup, this.nextCustomer], - [this.schedulable(this.nextCustomer), + [ + this.schedulable(this.nextCustomer), this.numPoints, this.gridSize, this.writable(this.toConsumer), - this.itemsProduced] - , + this.itemsProduced + ], function ( this, nextCustomer, diff --git a/src/benchmark/PingPong.ts b/src/benchmark/PingPong.ts index e43696bf8..3668e7c48 100644 --- a/src/benchmark/PingPong.ts +++ b/src/benchmark/PingPong.ts @@ -64,13 +64,9 @@ export class Pong extends Reactor { constructor(parent: Reactor) { super(parent); this.server = new CalleePort(this); - this.addReaction( - [this.dummy], - [this.dummy], - function (this) { - return undefined; - } - ); + this.addReaction([this.dummy], [this.dummy], function (this) { + return undefined; + }); this.addReaction( [this.server], [this.server], diff --git a/src/benchmark/Sieve.ts b/src/benchmark/Sieve.ts index 70c89eb1c..436936e9e 100644 --- a/src/benchmark/Sieve.ts +++ b/src/benchmark/Sieve.ts @@ -1,4 +1,5 @@ -import {type WritablePort, +import { + type WritablePort, Parameter, InPort, OutPort, @@ -25,10 +26,7 @@ class Ramp extends Reactor { this.next = new Action(this, Origin.logical, period); this.addReaction( [this.startup, this.next], - [this.schedulable(this.next), - this.until, - this.writable(this.value)] - , + [this.schedulable(this.next), this.until, this.writable(this.value)], function (this, next, until, value) { const n = next.get(); if (n === undefined) { @@ -65,12 +63,13 @@ class Filter extends Reactor { this.hasChild = new State(false); this.addMutation( [this.inp], - [this.inp, - this.writable(this.out), - this.startPrime, - this.hasChild, - this.localPrimes] - , + [ + this.inp, + this.writable(this.out), + this.startPrime, + this.hasChild, + this.localPrimes + ], function (this, inp, out, prime, hasChild, localPrimes) { const p = inp.get(); if (p !== undefined) { diff --git a/src/core/reactor.ts b/src/core/reactor.ts index cdfaf9c86..f8498ef4b 100644 --- a/src/core/reactor.ts +++ b/src/core/reactor.ts @@ -788,9 +788,7 @@ export abstract class Reactor extends Component { Log.global.warn("Deadline violation occurred!"); } ): void { - const calleePorts = trigs.filter( - (trig) => trig instanceof CalleePort - ); + const calleePorts = trigs.filter((trig) => trig instanceof CalleePort); if (calleePorts.length > 0) { // This is a procedure. diff --git a/src/core/trigger.ts b/src/core/trigger.ts index 3c45f8246..501df131f 100644 --- a/src/core/trigger.ts +++ b/src/core/trigger.ts @@ -1,4 +1,6 @@ -import {Component, type Variable, +import { + Component, + type Variable, type Reactor, type Runtime, type Absent, @@ -7,7 +9,6 @@ import {Component, type Variable, type Tag } from "./internal"; - export interface TriggerManager { getContainer: () => Reactor; addReaction: (reaction: Reaction) => void; diff --git a/src/share/Logger.ts b/src/share/Logger.ts index 9c3988ea0..428822c1d 100644 --- a/src/share/Logger.ts +++ b/src/share/Logger.ts @@ -28,10 +28,6 @@ export class Logger extends Reactor { constructor(parent: Reactor, expected: unknown) { super(parent); - this.addReaction( - [this.i], - [this.i, new State(expected)], - print - ); + this.addReaction([this.i], [this.i, new State(expected)], print); } }