From bae0e9a336cd4a766e559f08043064b192180dc4 Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 28 Jan 2019 11:31:47 +0100 Subject: [PATCH 1/2] Ensure `Random.RangeGenerator` and `Random.GLOBAL_RNG` are defined --- src/Compat.jl | 8 ++++++-- test/runtests.jl | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Compat.jl b/src/Compat.jl index 1c5e20dc8..cf70b3ae3 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -632,12 +632,16 @@ 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)...) @@ -654,7 +658,7 @@ else gentype(args...) = eltype(args...) - export $(random_fields...) + export $(exported_random_fields...) end end diff --git a/test/runtests.jl b/test/runtests.jl index 7e290d7ef..8e215e843 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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)) From 90ad9bf18c45a51223c279693a246f8049a957df Mon Sep 17 00:00:00 2001 From: Martin Holters Date: Mon, 28 Jan 2019 14:11:55 +0100 Subject: [PATCH 2/2] Provide `Random.uuid1`, `uuid4`, `uuid_version` on Julia before `UUIDs` --- src/Compat.jl | 6 ++++++ src/deprecated.jl | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Compat.jl b/src/Compat.jl index cf70b3ae3..7553d0085 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -646,6 +646,8 @@ else 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 @@ -654,6 +656,10 @@ 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...) diff --git a/src/deprecated.jl b/src/deprecated.jl index d38c7bdc0..45c42bd9f 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -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.*)