Skip to content

Commit b4ede1a

Browse files
committed
Add tests
1 parent a097cc2 commit b4ede1a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/connectors.jl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,19 @@ end
1313
ODESystem(Equation[], t, [x], [p], defaults=Dict(x=>1.0, p=>1.0))
1414
end
1515

16-
ModelingToolkit.connect(::Type{<:Foo}, sys1, sys2) = [sys1.x ~ sys2.x]
16+
function ModelingToolkit.connect(::Type{<:Foo}, ss...)
17+
n = length(ss)-1
18+
eqs = Vector{Equation}(undef, n)
19+
for i in 1:n
20+
eqs[i] = ss[i].x ~ ss[i+1].x
21+
end
22+
eqs
23+
end
24+
1725
@named f1 = Foo()
1826
@named f2 = Foo()
27+
@named f3 = Foo()
28+
@named f4 = Foo()
1929
@named g = Goo()
2030

2131
@test isequal(connect(f1, f2), [f1.x ~ f2.x])
@@ -24,6 +34,9 @@ ModelingToolkit.connect(::Type{<:Foo}, sys1, sys2) = [sys1.x ~ sys2.x]
2434
# Note that since there're overloadings, these tests are not re-runable.
2535
ModelingToolkit.promote_connect_rule(::Type{<:Foo}, ::Type{<:Goo}) = Foo
2636
@test isequal(connect(f1, g), [f1.x ~ g.x])
37+
@test isequal(connect(f1, f2, g), [f1.x ~ f2.x; f2.x ~ g.x])
38+
@test isequal(connect(f1, f2, g, f3), [f1.x ~ f2.x; f2.x ~ g.x; g.x ~ f3.x])
39+
@test isequal(connect(f1, f2, g, f3, f4), [f1.x ~ f2.x; f2.x ~ g.x; g.x ~ f3.x; f3.x ~ f4.x])
2740
ModelingToolkit.promote_connect_rule(::Type{<:Goo}, ::Type{<:Foo}) = Foo
2841
@test isequal(connect(f1, g), [f1.x ~ g.x])
2942
# test conflict

0 commit comments

Comments
 (0)