@@ -1088,7 +1088,9 @@ TestParentContext() = TestParentContext(DefaultContext())
10881088DynamicPPL. NodeTrait (:: TestParentContext ) = DynamicPPL. IsParent ()
10891089DynamicPPL. childcontext (context:: TestParentContext ) = context. context
10901090DynamicPPL. setchildcontext (:: TestParentContext , child) = TestParentContext (child)
1091- Base. show (io:: IO , c:: TestParentContext ) = print (io, " TestParentContext(" , DynamicPPL. childcontext (c), " )" )
1091+ function Base. show (io:: IO , c:: TestParentContext )
1092+ return print (io, " TestParentContext(" , DynamicPPL. childcontext (c), " )" )
1093+ end
10921094
10931095"""
10941096 test_context(context::AbstractContext, model::Model)
@@ -1103,19 +1105,27 @@ function test_context(context::DynamicPPL.AbstractContext, model::DynamicPPL.Mod
11031105 # `NodeTrait`.
11041106 node_trait = DynamicPPL. NodeTrait (context)
11051107 # Throw error immediately if it it's missing a `NodeTrait` implementation.
1106- node_trait isa Union{DynamicPPL. IsLeaf, DynamicPPL. IsParent} || throw (ValueError (" Invalid NodeTrait: $node_trait " ))
1108+ node_trait isa Union{DynamicPPL. IsLeaf,DynamicPPL. IsParent} ||
1109+ throw (ValueError (" Invalid NodeTrait: $node_trait " ))
11071110
11081111 # The interface methods.
11091112 if node_trait isa DynamicPPL. IsParent
11101113 # `childcontext` and `setchildcontext`
11111114 # With new child context
11121115 childcontext_new = TestParentContext ()
1113- @test DynamicPPL. childcontext (DynamicPPL. setchildcontext (context, childcontext_new)) == childcontext_new
1116+ @test DynamicPPL. childcontext (
1117+ DynamicPPL. setchildcontext (context, childcontext_new)
1118+ ) == childcontext_new
11141119 end
11151120
11161121 # To see change, let's make sure we're using a different leaf context than the current.
1117- leafcontext_new = DynamicPPL. leafcontext (context) isa DefaultContext ? PriorContext () : DefaultContext ()
1118- @test DynamicPPL. leafcontext (DynamicPPL. setleafcontext (context, leafcontext_new)) == leafcontext_new
1122+ leafcontext_new = if DynamicPPL. leafcontext (context) isa DefaultContext
1123+ PriorContext ()
1124+ else
1125+ DefaultContext ()
1126+ end
1127+ @test DynamicPPL. leafcontext (DynamicPPL. setleafcontext (context, leafcontext_new)) ==
1128+ leafcontext_new
11191129
11201130 # Make sure that the we can evaluate the model with the context (i.e. that none of the tilde-functions are incorrectly overloaded).
11211131 # The tilde-pipeline contains two different paths: with `SamplingContext` as a parent, and without it.
0 commit comments