Skip to content

Commit d0b419e

Browse files
test: update tests to new ImperativeAffect internals
1 parent 085faba commit d0b419e

File tree

1 file changed

+26
-51
lines changed

1 file changed

+26
-51
lines changed

test/symbolic_events.jl

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -96,111 +96,87 @@ end
9696
m = ModelingToolkit.ImperativeAffect(fmfa)
9797
@test m isa ModelingToolkit.ImperativeAffect
9898
@test m.f == fmfa
99-
@test m.obs == []
100-
@test m.obs_syms == []
101-
@test m.modified == []
102-
@test m.mod_syms == []
99+
@test m.observed == (;)
100+
@test m.modified == (;)
103101
@test m.ctx === nothing
104102

105103
m = ModelingToolkit.ImperativeAffect(fmfa, (;))
106104
@test m isa ModelingToolkit.ImperativeAffect
107105
@test m.f == fmfa
108-
@test m.obs == []
109-
@test m.obs_syms == []
110-
@test m.modified == []
111-
@test m.mod_syms == []
106+
@test m.observed == (;)
107+
@test m.modified == (;)
112108
@test m.ctx === nothing
113109

114110
m = ModelingToolkit.ImperativeAffect(fmfa, (; x))
115111
@test m isa ModelingToolkit.ImperativeAffect
116112
@test m.f == fmfa
117-
@test isequal(m.obs, [])
118-
@test m.obs_syms == []
119-
@test isequal(m.modified, [x])
120-
@test m.mod_syms == [:x]
113+
@test m.observed == (;)
114+
@test m.modified == (; x)
121115
@test m.ctx === nothing
122116

123117
m = ModelingToolkit.ImperativeAffect(fmfa, (; y = x))
124118
@test m isa ModelingToolkit.ImperativeAffect
125119
@test m.f == fmfa
126-
@test isequal(m.obs, [])
127-
@test m.obs_syms == []
128-
@test isequal(m.modified, [x])
129-
@test m.mod_syms == [:y]
120+
@test m.observed == (;)
121+
@test m.modified == (; y = x)
130122
@test m.ctx === nothing
131123

132124
m = ModelingToolkit.ImperativeAffect(fmfa; observed = (; y = x))
133125
@test m isa ModelingToolkit.ImperativeAffect
134126
@test m.f == fmfa
135-
@test isequal(m.obs, [x])
136-
@test m.obs_syms == [:y]
137-
@test m.modified == []
138-
@test m.mod_syms == []
127+
@test m.observed == (; y = x)
128+
@test m.modified == (;)
139129
@test m.ctx === nothing
140130

141131
m = ModelingToolkit.ImperativeAffect(fmfa; modified = (; x))
142132
@test m isa ModelingToolkit.ImperativeAffect
143133
@test m.f == fmfa
144-
@test isequal(m.obs, [])
145-
@test m.obs_syms == []
146-
@test isequal(m.modified, [x])
147-
@test m.mod_syms == [:x]
134+
@test m.observed == (;)
135+
@test m.modified == (; x)
148136
@test m.ctx === nothing
149137

150138
m = ModelingToolkit.ImperativeAffect(fmfa; modified = (; y = x))
151139
@test m isa ModelingToolkit.ImperativeAffect
152140
@test m.f == fmfa
153-
@test isequal(m.obs, [])
154-
@test m.obs_syms == []
155-
@test isequal(m.modified, [x])
156-
@test m.mod_syms == [:y]
141+
@test m.observed == (;)
142+
@test m.modified == (; y = x)
157143
@test m.ctx === nothing
158144

159145
m = ModelingToolkit.ImperativeAffect(fmfa, (; x), (; x))
160146
@test m isa ModelingToolkit.ImperativeAffect
161147
@test m.f == fmfa
162-
@test isequal(m.obs, [x])
163-
@test m.obs_syms == [:x]
164-
@test isequal(m.modified, [x])
165-
@test m.mod_syms == [:x]
148+
@test m.observed == (; x)
149+
@test m.modified == (; x)
166150
@test m.ctx === nothing
167151

168152
m = ModelingToolkit.ImperativeAffect(fmfa, (; y = x), (; y = x))
169153
@test m isa ModelingToolkit.ImperativeAffect
170154
@test m.f == fmfa
171-
@test isequal(m.obs, [x])
172-
@test m.obs_syms == [:y]
173-
@test isequal(m.modified, [x])
174-
@test m.mod_syms == [:y]
155+
@test m.observed == (; y = x)
156+
@test m.modified == (; y = x)
175157
@test m.ctx === nothing
176158

177159
m = ModelingToolkit.ImperativeAffect(
178160
fmfa; modified = (; y = x), observed = (; y = x))
179161
@test m isa ModelingToolkit.ImperativeAffect
180162
@test m.f == fmfa
181-
@test isequal(m.obs, [x])
182-
@test m.obs_syms == [:y]
183-
@test isequal(m.modified, [x])
184-
@test m.mod_syms == [:y]
163+
@test m.observed == (; y = x)
164+
@test m.modified == (; y = x)
185165
@test m.ctx === nothing
186166

187167
m = ModelingToolkit.ImperativeAffect(
188168
fmfa; modified = (; y = x), observed = (; y = x), ctx = 3)
189169
@test m isa ModelingToolkit.ImperativeAffect
190170
@test m.f == fmfa
191-
@test isequal(m.obs, [x])
192-
@test m.obs_syms == [:y]
193-
@test isequal(m.modified, [x])
194-
@test m.mod_syms == [:y]
171+
@test m.observed == (; y = x)
172+
@test m.modified == (; y = x)
195173
@test m.ctx === 3
196174

197175
m = ModelingToolkit.ImperativeAffect(fmfa, (; x), (; x), 3)
198176
@test m isa ModelingToolkit.ImperativeAffect
199177
@test m.f == fmfa
200-
@test isequal(m.obs, [x])
201-
@test m.obs_syms == [:x]
202-
@test isequal(m.modified, [x])
203-
@test m.mod_syms == [:x]
178+
@test m.observed == (; x)
179+
@test m.modified == (; x)
204180
@test m.ctx === 3
205181
end
206182

@@ -966,8 +942,7 @@ end
966942
end)
967943
@named sys = System(eqs, t, [temp], params; continuous_events = [furnace_off])
968944
ss = mtkcompile(sys)
969-
@test_logs (:warn,
970-
"The symbols Any[:furnace_on] are declared as both observed and modified; this is a code smell because it becomes easy to confuse them and assign/not assign a value.") prob=ODEProblem(
945+
@test_warn "The symbols [:furnace_on] are declared as both observed and modified; this is a code smell because it becomes easy to confuse them and assign/not assign a value." prob=ODEProblem(
971946
ss, [temp => 0.0, furnace_on => true], (0.0, 100.0))
972947

973948
@variables tempsq(t) # trivially eliminated
@@ -1010,7 +985,7 @@ end
1010985
ss = mtkcompile(sys)
1011986
prob = ODEProblem(
1012987
ss, [temp => 0.0, furnace_on => true], (0.0, 100.0))
1013-
@test_throws "Tried to write back to" solve(prob, Tsit5())
988+
@test_throws "Invalid name" solve(prob, Tsit5())
1014989
end
1015990

1016991
@testset "Quadrature" begin

0 commit comments

Comments
 (0)