@@ -138,24 +138,43 @@ end
138
138
end
139
139
140
140
@testset " PrefixContext" begin
141
- ctx = @inferred PrefixContext {:f} (
142
- PrefixContext {:e} (
143
- PrefixContext {:d} (
144
- PrefixContext {:c} (
145
- PrefixContext {:b} (PrefixContext {:a} (DefaultContext ()))
141
+ @testset " prefixing" begin
142
+ ctx = @inferred PrefixContext {:f} (
143
+ PrefixContext {:e} (
144
+ PrefixContext {:d} (
145
+ PrefixContext {:c} (
146
+ PrefixContext {:b} (PrefixContext {:a} (DefaultContext ()))
147
+ ),
146
148
),
147
149
),
148
- ),
149
- )
150
- vn = VarName {:x} ()
151
- vn_prefixed = @inferred DynamicPPL. prefix (ctx, vn)
152
- @test DynamicPPL. getsym (vn_prefixed) == Symbol (" a.b.c.d.e.f.x" )
153
- @test getoptic (vn_prefixed) === getoptic (vn)
154
-
155
- vn = VarName {:x} (((1 ,),))
156
- vn_prefixed = @inferred DynamicPPL. prefix (ctx, vn)
157
- @test DynamicPPL. getsym (vn_prefixed) == Symbol (" a.b.c.d.e.f.x" )
158
- @test getoptic (vn_prefixed) === getoptic (vn)
150
+ )
151
+ vn = VarName {:x} ()
152
+ vn_prefixed = @inferred DynamicPPL. prefix (ctx, vn)
153
+ @test DynamicPPL. getsym (vn_prefixed) == Symbol (" a.b.c.d.e.f.x" )
154
+ @test getoptic (vn_prefixed) === getoptic (vn)
155
+
156
+ vn = VarName {:x} (((1 ,),))
157
+ vn_prefixed = @inferred DynamicPPL. prefix (ctx, vn)
158
+ @test DynamicPPL. getsym (vn_prefixed) == Symbol (" a.b.c.d.e.f.x" )
159
+ @test getoptic (vn_prefixed) === getoptic (vn)
160
+ end
161
+
162
+ context = DynamicPPL. PrefixContext {:prefix} (SamplingContext ())
163
+ @testset " evaluation: $(model. f) " for model in DynamicPPL. TestUtils. DEMO_MODELS
164
+ # Sample with the context.
165
+ varinfo = DynamicPPL. VarInfo ()
166
+ DynamicPPL. evaluate!! (model, varinfo, context)
167
+ # Extract the resulting symbols.
168
+ vns_varinfo_syms = Set (map (DynamicPPL. getsym, keys (varinfo)))
169
+
170
+ # Extract the ground truth symbols.
171
+ vns_syms = Set ([
172
+ Symbol (" prefix" , DynamicPPL. PREFIX_SEPARATOR, DynamicPPL. getsym (vn)) for vn in DynamicPPL. TestUtils. varnames (model)
173
+ ])
174
+
175
+ # Check that all variables are prefixed correctly.
176
+ @test vns_syms == vns_varinfo_syms
177
+ end
159
178
end
160
179
161
180
@testset " SamplingContext" begin
0 commit comments