Skip to content

Commit c43b3e9

Browse files
test: test analysis points
1 parent bc2c128 commit c43b3e9

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

test/analysis_points.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using ModelingToolkit, ModelingToolkitStandardLibrary
2+
using Test
3+
using ModelingToolkit: t_nounits as t, D_nounits as D
4+
5+
@testset "AnalysisPoint is lowered to `connect`" begin
6+
@named P = FirstOrder(k = 1, T = 1)
7+
@named C = Gain(; k = -1)
8+
9+
ap = AnalysisPoint(:plant_input)
10+
eqs = [connect(P.output, C.input)
11+
connect(C.output, ap, P.input)]
12+
sys_ap = ODESystem(eqs, t, systems = [P, C], name = :hej)
13+
sys_ap2 = @test_nowarn expand_connections(sys)
14+
15+
@test all(eq -> !(eq.lhs isa AnalysisPoint), equations(sys_ap2))
16+
17+
eqs = [connect(P.output, C.input)
18+
connect(C.output, P.input)]
19+
sys_normal = ODESystem(eqs, t, systems = [P, C], name = :hej)
20+
sys_normal2 = @test_nowarn expand_connections(sys)
21+
22+
@test isequal(sys_ap2, sys_normal2)
23+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ end
8484
@safetestset "print_tree" include("print_tree.jl")
8585
@safetestset "Constraints Test" include("constraints.jl")
8686
@safetestset "IfLifting Test" include("if_lifting.jl")
87+
@safetestset "Analysis Points Test" include("analysis_points.jl")
8788
end
8889
end
8990

0 commit comments

Comments
 (0)