Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
axmmisaka committed Jul 1, 2023
1 parent 38b12a4 commit 20a8cf1
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 187 deletions.
7 changes: 1 addition & 6 deletions __tests__/Adder.test.ts
Original file line number Diff line number Diff line change
@@ -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<number>(this);
Expand Down
7 changes: 1 addition & 6 deletions __tests__/CausalityGraph.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions __tests__/InvalidMutations.ts
Original file line number Diff line number Diff line change
@@ -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<number>(this);
Expand Down
7 changes: 1 addition & 6 deletions __tests__/OutputEvent.test.ts
Original file line number Diff line number Diff line change
@@ -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";

/**
Expand Down
38 changes: 14 additions & 24 deletions __tests__/OutputGet.test.ts
Original file line number Diff line number Diff line change
@@ -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<number> = new OutPort<number>(this);
Expand All @@ -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"
);
}
});
}
}

Expand Down
7 changes: 1 addition & 6 deletions __tests__/SimpleMutation.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
26 changes: 11 additions & 15 deletions __tests__/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
FederatePortAction,
App,
Origin,
TimeValue,
TimeValue
} from "../src/core/internal";

let intendedTagDelay: TimeValue | undefined;
Expand All @@ -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) {
Expand Down
42 changes: 17 additions & 25 deletions __tests__/multiport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
OutMultiPort,
IOPort,
OutPort,
InPort,
InPort
} from "../src/core/internal";
class TwoInTwoOut extends Reactor {
inp = new InMultiPort<number>(this, 2);
Expand Down Expand Up @@ -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)],
Expand Down
82 changes: 33 additions & 49 deletions __tests__/mutations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Timer,
OutPort,
InPort,
TimeValue,
TimeValue
} from "../src/core/internal";

class Source extends Reactor {
Expand Down Expand Up @@ -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.");
}
);
});
}
}

Expand All @@ -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)],
Expand Down Expand Up @@ -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();
}
Expand Down
7 changes: 1 addition & 6 deletions __tests__/port.errors.test.ts
Original file line number Diff line number Diff line change
@@ -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<number>(this);
Expand Down
10 changes: 3 additions & 7 deletions __tests__/reactors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/benchmark/FacilityLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 3 additions & 7 deletions src/benchmark/PingPong.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Loading

0 comments on commit 20a8cf1

Please sign in to comment.