Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing members to Compat.Random #647

Merged
merged 2 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,22 @@ end
if VERSION >= v"0.7.0-beta.234"
import Random
else
const random_fields = [
const exported_random_fields = [
:AbstractRNG, :MersenneTwister, :RandomDevice, :bitrand, :rand, :rand!,
:randcycle, :randexp, :randexp!, :randjump, :randn!,
:randperm, :randstring, :randsubseq, :randsubseq!, :shuffle,
:shuffle!
]
const unexported_random_fields = [
:GLOBAL_RNG, :RangeGenerator
]
const random_fields = [exported_random_fields; unexported_random_fields]
@eval module Random
if VERSION < v"0.7.0-DEV.3406"
$((:(using Base.Random: $f) for f in random_fields)...)
const seed! = Base.Random.srand
# these should be deprecated in favor of Compat.UUIDs.*
using Base.Random: uuid1, uuid4, uuid_version
else
$((:(using Random: $f) for f in random_fields)...)
import Random
Expand All @@ -650,11 +656,15 @@ else
else
using Random: seed!
end
if VERSION < v"0.7.0-DEV.3666"
# these should be deprecated in favor of Compat.UUIDs.*
using Random: uuid1, uuid4, uuid_version
end
end

gentype(args...) = eltype(args...)

export $(random_fields...)
export $(exported_random_fields...)
end
end

Expand Down
1 change: 1 addition & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ Base.@deprecate_binding promote_eltype_op Base.promote_eltype_op
# to be deprecated:

# * `range(start, stop)` (without either `length` nor `step` given)
# * Compat.Random.uuid1, uuid4, uuid_version (in favour of Compat.UUIDs.*)
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,7 @@ Random.seed!(1)
rng = MersenneTwister(0)
Random.seed!(rng, 1)
@test rand(rng) ≈ 0.23603334566204692
@test 0 < rand(Random.GLOBAL_RNG, Random.RangeGenerator(1:3)) < 4

# 0.7.0-beta2.169
@test floatmin(Float16) == @eval $(Core.Intrinsics.bitcast(Float16, 0x0400))
Expand Down