|
4 | 4 | Timer, |
5 | 5 | OutPort, |
6 | 6 | InPort, |
7 | | - TimeValue |
| 7 | + TimeValue, |
| 8 | + IOPort |
8 | 9 | } from "../src/core/internal"; |
9 | 10 |
|
10 | 11 | class Source extends Reactor { |
@@ -189,3 +190,60 @@ describe("Creating reactors at runtime", function () { |
189 | 190 | // }); |
190 | 191 |
|
191 | 192 | // }); |
| 193 | +describe("Test the result from refactor-canconnect: referencing ConnectablePort should not introduce any change in the causality graph", () => { |
| 194 | + class InnocentReactor extends Reactor { |
| 195 | + public inp = new InPort<never>(this); |
| 196 | + public outp = new OutPort<never>(this); |
| 197 | + public cip = new InPort<never>(this); |
| 198 | + public oip = new OutPort<never>(this); |
| 199 | + public child = new (class InnocentChild extends Reactor { |
| 200 | + public oip = new OutPort<never>(this); |
| 201 | + constructor(parent: InnocentReactor) { |
| 202 | + super(parent); |
| 203 | + } |
| 204 | + })(this); |
| 205 | + |
| 206 | + constructor(parent: TestApp) { |
| 207 | + super(parent); |
| 208 | + |
| 209 | + this.addMutation( |
| 210 | + [this.startup], |
| 211 | + [ |
| 212 | + this.inp, |
| 213 | + this.writable(this.outp), |
| 214 | + this.cip.asConnectable(), |
| 215 | + this.oip.asConnectable(), |
| 216 | + this.child.oip.asConnectable() |
| 217 | + ], |
| 218 | + function (this, a0, a1, a2, a3, a4) { |
| 219 | + // This is current failing as we disallow direct feedthrough. Nevertheless I'm unsure why that is the case as of now? |
| 220 | + // this.connect(a2, a3); |
| 221 | + this.connect(a2, a4); |
| 222 | + } |
| 223 | + ); |
| 224 | + } |
| 225 | + } |
| 226 | + |
| 227 | + class TestApp extends App { |
| 228 | + public child = new InnocentReactor(this); |
| 229 | + constructor(done: () => void) { |
| 230 | + super(undefined, undefined, undefined, () => { |
| 231 | + const mut = this.child["_mutations"][1]; // M0 is the shutdown mutation; M1 is our mutation |
| 232 | + const pg = this._getPrecedenceGraph(); |
| 233 | + // child.oip should be an island in the causality graph |
| 234 | + expect(pg.getUpstreamNeighbors(this.child.oip).size).toBe(0); |
| 235 | + expect(pg.getDownstreamNeighbors(this.child.oip).size).toBe(0); |
| 236 | + // The only dependency child.child.oip should have is child.cip |
| 237 | + expect(pg.getUpstreamNeighbors(this.child.child.oip).size).toBe(1); |
| 238 | + expect( |
| 239 | + pg.getUpstreamNeighbors(this.child.child.oip).has(this.child.cip) |
| 240 | + ).toBeTruthy(); |
| 241 | + done(); |
| 242 | + }); |
| 243 | + } |
| 244 | + } |
| 245 | + test("test dependencies", (done) => { |
| 246 | + const tapp = new TestApp(done); |
| 247 | + tapp._start(); |
| 248 | + }); |
| 249 | +}); |
0 commit comments