Skip to content

Commit

Permalink
Merge pull request #647 from JuliaLang/mh/fix_rangegen
Browse files Browse the repository at this point in the history
Add missing members to `Compat.Random`
  • Loading branch information
martinholters authored Jan 29, 2019
2 parents 64697fd + 90ad9bf commit d1651b4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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

0 comments on commit d1651b4

Please sign in to comment.