Skip to content

Commit d026437

Browse files
committed
add tests for rand
1 parent d351438 commit d026437

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/runtests.jl

+28
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,34 @@ struct IncompleteInterval <: AbstractInterval{Int} end
718718
@test clamp.([pi, 1.0, big(10.)], Ref(2..9.)) == [big(pi), 2, 9]
719719
end
720720

721+
@testset "rand" begin
722+
@test rand(1..2) isa Float64
723+
@test rand(1..2.) isa Float64
724+
@test rand(1..big(2)) isa BigFloat
725+
@test rand(1..(3//2)) isa Float64
726+
@test rand(Int32(1)..Int32(2)) isa Float64
727+
@test rand(Float32(1)..Float32(2)) isa Float32
728+
@test_throws ArgumentError rand(2..1)
729+
730+
i1 = 1..2
731+
i2 = 3e100..3e100
732+
i3 = 1..typemax(Float64)
733+
i4 = typemin(Float64)..typemax(Float64)
734+
i5 = typemin(Float64)..1
735+
for _ in 1:100
736+
rand(i1) in i1
737+
rand(i2) in i2
738+
rand(i3) in i3
739+
rand(i4) in i4
740+
rand(i5) in i5
741+
rand(i1,10) i1
742+
rand(i2,10) i2
743+
rand(i3,10) i3
744+
rand(i4,10) i4
745+
rand(i5,10) i5
746+
end
747+
end
748+
721749
@testset "IteratorSize" begin
722750
@test Base.IteratorSize(ClosedInterval) == Base.SizeUnknown()
723751
end

0 commit comments

Comments
 (0)