Skip to content

Commit 01624c4

Browse files
committed
Disallow the connection between input and output ports from different containers
1 parent 08fa084 commit 01624c4

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

__tests__/connection.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ describe("Check canConnect", () => {
3939
true
4040
);
4141
});
42+
43+
it("canConnect failure", () => {
44+
expect(this.canConnect(this.destination.in, this.source.out)).toBe(
45+
false
46+
);
47+
});
4248
}
4349
}
4450
var testApp = new TestApp();

__tests__/hierarchy.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,38 @@ describe("Container to Contained", () => {
4040
expect(
4141
app.container.canConnect(app.container.contained.a, app.container.a)
4242
).toBe(false);
43+
expect(
44+
app.container.canConnect(
45+
app.container.a,
46+
app.container.b
47+
)
48+
).toBe(true);
49+
expect(
50+
app.container.canConnect(
51+
app.container.contained.a,
52+
app.container.contained.b
53+
)
54+
).toBe(false);
4355
expect(
4456
app.container.canConnect(
4557
app.container.contained.b,
4658
app.container.contained.a
4759
)
4860
).toBe(true);
4961

62+
expect(
63+
app.container.canConnect(app.container.a, app.container.contained.b)
64+
).toBe(false);
5065
expect(
5166
app.container.canConnect(app.container.contained.b, app.container.a)
5267
).toBe(false);
5368

5469
expect(
5570
app.container.canConnect(app.container.b, app.container.contained.a)
5671
).toBe(false);
72+
expect(
73+
app.container.canConnect(app.container.contained.a, app.container.b)
74+
).toBe(false);
5775

5876
expect(
5977
app.container.canConnect(app.container.b, app.container.contained.b)
@@ -65,13 +83,17 @@ describe("Container to Contained", () => {
6583
expect(app.container.canConnect(app.container.contained.a, app.foo.a)).toBe(
6684
false
6785
);
86+
expect(app.container.canConnect(app.container.contained.a, app.foo.b)).toBe(
87+
false
88+
);
6889
expect(app.container.canConnect(app.foo.a, app.container.contained.a)).toBe(
6990
false
7091
);
7192
expect(app.container.canConnect(app.foo.a, app.container.contained.a)).toBe(
7293
false
7394
);
7495

96+
expect(app.container.canConnect(app.foo.a, app.container.b)).toBe(false);
7597
expect(app.container.canConnect(app.foo.a, app.container.a)).toBe(false);
7698

7799
// expect(app.container.contained).toBeDefined();

src/core/reactor.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,8 +1202,15 @@ export abstract class Reactor extends Component {
12021202
}
12031203
} else {
12041204
// IN to OUT
1205-
// FIXME: Make this direct feedthrough false after the generated code deletes it.
1206-
return true;
1205+
if (
1206+
src._isContainedBy(this) &&
1207+
dst !== undefined &&
1208+
dst._isContainedBy(this)
1209+
) {
1210+
return true;
1211+
} else {
1212+
return false;
1213+
}
12071214
}
12081215
}
12091216
}

0 commit comments

Comments
 (0)