|
59 | 59 | model = ModelOuterWorking()
|
60 | 60 | @test check_model(model; error_on_failure=true)
|
61 | 61 | end
|
| 62 | + |
| 63 | + @testset "subsumes (x then x[1])" begin |
| 64 | + @model function buggy_subsumes_demo_model() |
| 65 | + x = Vector{Float64}(undef, 2) |
| 66 | + x ~ MvNormal(zeros(2), I) |
| 67 | + x[1] ~ Normal() |
| 68 | + return nothing |
| 69 | + end |
| 70 | + buggy_model = buggy_subsumes_demo_model() |
| 71 | + |
| 72 | + @test_logs (:warn,) (:warn,) check_model(buggy_model) |
| 73 | + issuccess = check_model( |
| 74 | + buggy_model; context=SamplingContext(), record_varinfo=false |
| 75 | + ) |
| 76 | + @test !issuccess |
| 77 | + @test_throws ErrorException check_model(buggy_model; error_on_failure=true) |
| 78 | + end |
| 79 | + |
| 80 | + @testset "subsumes (x[1] then x)" begin |
| 81 | + @model function buggy_subsumes_demo_model() |
| 82 | + x = Vector{Float64}(undef, 2) |
| 83 | + x[1] ~ Normal() |
| 84 | + x ~ MvNormal(zeros(2), I) |
| 85 | + return nothing |
| 86 | + end |
| 87 | + buggy_model = buggy_subsumes_demo_model() |
| 88 | + |
| 89 | + @test_logs (:warn,) (:warn,) check_model(buggy_model) |
| 90 | + issuccess = check_model( |
| 91 | + buggy_model; context=SamplingContext(), record_varinfo=false |
| 92 | + ) |
| 93 | + @test !issuccess |
| 94 | + @test_throws ErrorException check_model(buggy_model; error_on_failure=true) |
| 95 | + end |
| 96 | + |
| 97 | + @testset "subsumes (x.a then x)" begin |
| 98 | + @model function buggy_subsumes_demo_model() |
| 99 | + x = (a=nothing,) |
| 100 | + x.a ~ Normal() |
| 101 | + x ~ Normal() |
| 102 | + return nothing |
| 103 | + end |
| 104 | + buggy_model = buggy_subsumes_demo_model() |
| 105 | + |
| 106 | + @test_logs (:warn,) (:warn,) check_model(buggy_model) |
| 107 | + issuccess = check_model( |
| 108 | + buggy_model; context=SamplingContext(), record_varinfo=false |
| 109 | + ) |
| 110 | + @test !issuccess |
| 111 | + @test_throws ErrorException check_model(buggy_model; error_on_failure=true) |
| 112 | + end |
62 | 113 | end
|
63 | 114 |
|
64 | 115 | @testset "incorrect use of condition" begin
|
|
0 commit comments