Skip to content

Commit 7f20709

Browse files
authored
Fix missing field tests for 1.12 (#961)
1 parent 1882f72 commit 7f20709

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

test/varinfo.jl

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,12 @@ end
211211
),
212212
)
213213
@test getlogprior(vi) == lp_a + lp_b
214-
@test_throws "has no field LogLikelihood" getloglikelihood(vi)
215-
@test_throws "has no field LogLikelihood" getlogp(vi)
216-
@test_throws "has no field LogLikelihood" getlogjoint(vi)
217-
@test_throws "has no field NumProduce" get_num_produce(vi)
214+
# need regex because 1.11 and 1.12 throw different errors (in 1.12 the
215+
# missing field is surrounded by backticks)
216+
@test_throws r"has no field `?LogLikelihood" getloglikelihood(vi)
217+
@test_throws r"has no field `?LogLikelihood" getlogp(vi)
218+
@test_throws r"has no field `?LogLikelihood" getlogjoint(vi)
219+
@test_throws r"has no field `?NumProduce" get_num_produce(vi)
218220
@test begin
219221
vi = acclogprior!!(vi, 1.0)
220222
getlogprior(vi) == lp_a + lp_b + 1.0
@@ -229,20 +231,24 @@ end
229231
m, DynamicPPL.setaccs!!(deepcopy(vi), (NumProduceAccumulator(),))
230232
),
231233
)
232-
@test_throws "has no field LogPrior" getlogprior(vi)
233-
@test_throws "has no field LogLikelihood" getloglikelihood(vi)
234-
@test_throws "has no field LogPrior" getlogp(vi)
235-
@test_throws "has no field LogPrior" getlogjoint(vi)
234+
# need regex because 1.11 and 1.12 throw different errors (in 1.12 the
235+
# missing field is surrounded by backticks)
236+
@test_throws r"has no field `?LogPrior" getlogprior(vi)
237+
@test_throws r"has no field `?LogLikelihood" getloglikelihood(vi)
238+
@test_throws r"has no field `?LogPrior" getlogp(vi)
239+
@test_throws r"has no field `?LogPrior" getlogjoint(vi)
236240
@test get_num_produce(vi) == 2
237241

238242
# Test evaluating without any accumulators.
239243
vi = last(DynamicPPL.evaluate!!(m, DynamicPPL.setaccs!!(deepcopy(vi), ())))
240-
@test_throws "has no field LogPrior" getlogprior(vi)
241-
@test_throws "has no field LogLikelihood" getloglikelihood(vi)
242-
@test_throws "has no field LogPrior" getlogp(vi)
243-
@test_throws "has no field LogPrior" getlogjoint(vi)
244-
@test_throws "has no field NumProduce" get_num_produce(vi)
245-
@test_throws "has no field NumProduce" reset_num_produce!!(vi)
244+
# need regex because 1.11 and 1.12 throw different errors (in 1.12 the
245+
# missing field is surrounded by backticks)
246+
@test_throws r"has no field `?LogPrior" getlogprior(vi)
247+
@test_throws r"has no field `?LogLikelihood" getloglikelihood(vi)
248+
@test_throws r"has no field `?LogPrior" getlogp(vi)
249+
@test_throws r"has no field `?LogPrior" getlogjoint(vi)
250+
@test_throws r"has no field `?NumProduce" get_num_produce(vi)
251+
@test_throws r"has no field `?NumProduce" reset_num_produce!!(vi)
246252
end
247253

248254
@testset "flags" begin

0 commit comments

Comments
 (0)