Skip to content

Commit d2f64fa

Browse files
committed
Add tests
1 parent 610e676 commit d2f64fa

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

.travis.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,24 @@ branches:
1212
os:
1313
- linux
1414
- osx
15-
julia:
16-
- 1.0
17-
- 1
18-
- nightly
15+
matrix:
16+
include:
17+
- julia: 1.0
18+
- julia: 1
19+
env: JULIA_NUM_THREADS=1
20+
- julia: 1
21+
env: JULIA_NUM_THREADS=2
22+
- julia: nightly
23+
env: JULIA_NUM_THREADS=1
24+
- julia: nightly
25+
env: JULIA_NUM_THREADS=2
1926
matrix:
2027
allow_failures:
2128
- julia: nightly
2229
fast_finish: true
2330
notifications:
2431
email: false
2532
after_success:
26-
- if [[ $TRAVIS_JULIA_VERSION = 1 ]] && [[ $TRAVIS_OS_NAME = linux ]]; then
33+
- if [[ $TRAVIS_JULIA_VERSION = 1 ]] && [[ $JULIA_NUM_THREADS = 1 ]] && [[ $TRAVIS_OS_NAME = linux ]]; then
2734
julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())';
2835
fi

test/compiler.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ end
215215
global sampler_ = _sampler
216216
global model_ = _model
217217
global context_ = _context
218+
global rng_ = _rng
218219
global lp = getlogp(_varinfo)
219220
return x
220221
end
@@ -226,6 +227,7 @@ end
226227
@test model_ === model
227228
@test sampler_ === SampleFromPrior()
228229
@test context_ === DefaultContext()
230+
@test rng_ isa Random.AbstractRNG
229231

230232
# disable warnings
231233
@model testmodel(x) = begin
@@ -234,6 +236,7 @@ end
234236
global sampler_ = _sampler
235237
global model_ = _model
236238
global context_ = _context
239+
global rng_ = _rng
237240
global lp = getlogp(_varinfo)
238241
return x
239242
end false

test/model.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,22 @@ Random.seed!(1234)
2626
@test ljoint lprior + llikelihood
2727
@test ljoint lp
2828
end
29+
30+
@testset "rng" begin
31+
model = gdemo_default
32+
33+
for sampler in (SampleFromPrior(), SampleFromUniform())
34+
for i in 1:10
35+
Random.seed!(100 + i)
36+
vi = VarInfo()
37+
model(Random.GLOBAL_RNG, vi, sampler)
38+
vals = DynamicPPL.getall(vi)
39+
40+
Random.seed!(100 + i)
41+
vi = VarInfo()
42+
model(Random.GLOBAL_RNG, vi, sampler)
43+
@test DynamicPPL.getall(vi) == vals
44+
end
45+
end
46+
end
2947
end

0 commit comments

Comments
 (0)