Skip to content

Commit 96afc18

Browse files
committed
Add values_as_in_model tests
1 parent a76d55d commit 96afc18

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/model.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,27 @@ const GDEMO_DEFAULT = DynamicPPL.TestUtils.demo_assume_observe_literal()
429429
end
430430
end
431431
end
432+
433+
@testset "Prefixing" begin
434+
@model inner() = x ~ Normal()
435+
436+
@model function outer_auto_prefix()
437+
a ~ to_submodel(inner(), true)
438+
b ~ to_submodel(inner(), true)
439+
return nothing
440+
end
441+
@model function outer_manual_prefix()
442+
a ~ to_submodel(prefix(inner(), :a), false)
443+
b ~ to_submodel(prefix(inner(), :b), false)
444+
return nothing
445+
end
446+
447+
for model in (outer_auto_prefix(), outer_manual_prefix())
448+
vi = VarInfo(model)
449+
vns = Set(keys(values_as_in_model(model, false, vi)))
450+
@test vns == Set([@varname(var"a.x"), @varname(var"b.x")])
451+
end
452+
end
432453
end
433454

434455
@testset "Erroneous model call" begin

0 commit comments

Comments
 (0)