JuliaTesting / ReferenceTests.jl

Utility package for comparing data against reference files
https://juliatesting.github.io/ReferenceTests.jl/latest/
Other
82 stars 14 forks source link

support zero-arg function references #48

Open johnnychen94 opened 4 years ago

johnnychen94 commented 4 years ago

For zero-arg functions such as f() = rand(), a useful feature is to repeat the tests several times and see if all of the results fall in the acceptable region.

I'm thinking of the following usage:

@test_reference "references/zero.txt" rand by=(x,y)->abs(x-y)<1 repeat=50

which is equivalent to

for _ in 1:50
    rst = rand()
    @test_reference "references/zero.txt" rst by=(x,y)->abs(x-y)<1
end
oxinabox commented 4 years ago

Why is this specific to zero arg functions?

foo(q) = x+rand()
@test_reference "references/zero.txt" foo(500) by=(x,y)->abs(x-y)<1 repeat=50