Skip to content

Commit 3b557b7

Browse files
committed
@rand: more tests for definitions in a module
1 parent 5f12518 commit 3b557b7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/runtests.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,3 +632,20 @@ Base.eltype(::Type{DieT{T}}) where {T} = T
632632
T(typemin(T) + rand(typemin(T):typemax(T)))
633633
@test rand(d) isa Bool
634634
end
635+
636+
module TestAtRand
637+
# only using RandomExtensions, not Random, to check we don't depend on
638+
# some imported names like e.g. SamplerTrivial
639+
using RandomExtensions, Test
640+
641+
struct Die n end
642+
643+
@testset "@rand in module" begin
644+
@rand rand(d::Die) = d.n # SamplerTrivial
645+
@test rand(Die(123)) == 123
646+
@test rand(RandomDevice(), Die(123)) == 123
647+
@rand rand(d::Die) = rand(1:d.n) # SamplerSimple
648+
@test rand(Die(1)) == 1
649+
@test rand(RandomDevice(), Die(1)) == 1
650+
end
651+
end # module

0 commit comments

Comments
 (0)