Skip to content

Commit

Permalink
Add test to ensure rand! is allocation-free (JuliaLang#27060)
Browse files Browse the repository at this point in the history
Adds a test to close JuliaLang#14006.
  • Loading branch information
mbauman authored May 11, 2018
1 parent 749afcb commit c43d3b0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stdlib/Random/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,13 @@ end
@test rand(RNG, SamplerRangeFast(r)) r
end

@testset "rand! is allocation-free" begin
for A in (Array{Int}(undef, 20), Array{Float64}(undef, 5, 4), BitArray(undef, 20), BitArray(undef, 50, 40))
rand!(A)
@test @allocated(rand!(A)) == 0
end
end

@testset "eltype for UniformBits" begin
@test eltype(Random.UInt52()) == UInt64
@test eltype(Random.UInt52(UInt128)) == UInt128
Expand Down

0 comments on commit c43d3b0

Please sign in to comment.