Skip to content

Commit

Permalink
document that srand() returns the passed RNG
Browse files Browse the repository at this point in the history
  • Loading branch information
rfourquet committed Apr 1, 2017
1 parent bd84fa1 commit ad66758
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ end
## srand()

"""
srand([rng=GLOBAL_RNG], [seed])
srand([rng=GLOBAL_RNG], [seed]) -> rng
Reseed the random number generator. If a `seed` is provided, the RNG will give a
reproducible sequence of numbers, otherwise Julia will get entropy from the system. For
Expand Down
15 changes: 15 additions & 0 deletions test/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,18 @@ let seed = rand(UInt32, 10)
resize!(seed, 4)
@test r.seed != seed
end

# srand(rng, ...) returns rng (#21248)
let g = Base.Random.GLOBAL_RNG,
m = MersenneTwister(0)
@test srand() === g
@test srand(rand(UInt)) === g
@test srand(rand(UInt32, rand(1:10))) === g
@test srand(@__FILE__) === g
@test srand(@__FILE__, rand(1:10)) === g
@test srand(m) === m
@test srand(m, rand(UInt)) === m
@test srand(m, rand(UInt32, rand(1:10))) === m
@test srand(m, rand(1:10)) === m
@test srand(m, @__FILE__, rand(1:10)) === m
end

0 comments on commit ad66758

Please sign in to comment.