Skip to content

Commit b197cf0

Browse files
authored
use Random.seed! (#52)
1 parent ed2033c commit b197cf0

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/testtools.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Test Tools
22
# ==========
33

4-
if VERSION > v"0.7-"
4+
if VERSION v"0.7.0-rc1"
55
import Test
6-
import Random: srand, randstring
6+
import Random: seed!, randstring
77
else
88
import Base.Test
9+
const seed! = srand
910
end
1011

1112
TEST_RANDOM_SEED = 12345
1213

1314
function test_roundtrip_read(encoder, decoder)
14-
srand(TEST_RANDOM_SEED)
15+
seed!(TEST_RANDOM_SEED)
1516
for n in vcat(0:30, sort!(rand(500:100_000, 30))), alpha in (0x00:0xff, 0x00:0x0f)
1617
data = rand(alpha, n)
1718
file = IOBuffer(data)
@@ -22,7 +23,7 @@ function test_roundtrip_read(encoder, decoder)
2223
end
2324

2425
function test_roundtrip_write(encoder, decoder)
25-
srand(TEST_RANDOM_SEED)
26+
seed!(TEST_RANDOM_SEED)
2627
for n in vcat(0:30, sort!(rand(500:100_000, 30))), alpha in (0x00:0xff, 0x00:0x0f)
2728
data = rand(alpha, n)
2829
file = IOBuffer()
@@ -34,7 +35,7 @@ function test_roundtrip_write(encoder, decoder)
3435
end
3536

3637
function test_roundtrip_transcode(encode, decode)
37-
srand(TEST_RANDOM_SEED)
38+
seed!(TEST_RANDOM_SEED)
3839
encoder = encode()
3940
decoder = decode()
4041
for n in vcat(0:30, sort!(rand(500:100_000, 30))), alpha in (0x00:0xff, 0x00:0x0f)
@@ -47,7 +48,7 @@ function test_roundtrip_transcode(encode, decode)
4748
end
4849

4950
function test_roundtrip_lines(encoder, decoder)
50-
srand(TEST_RANDOM_SEED)
51+
seed!(TEST_RANDOM_SEED)
5152
lines = String[]
5253
buf = IOBuffer()
5354
stream = encoder(buf)
@@ -77,7 +78,7 @@ function test_roundtrip_fileio(Encoder, Decoder)
7778
end
7879

7980
function test_chunked_read(Encoder, Decoder)
80-
srand(TEST_RANDOM_SEED)
81+
seed!(TEST_RANDOM_SEED)
8182
alpha = b"色即是空"
8283
encoder = Encoder()
8384
initialize(encoder)
@@ -103,7 +104,7 @@ function test_chunked_read(Encoder, Decoder)
103104
end
104105

105106
function test_chunked_write(Encoder, Decoder)
106-
srand(TEST_RANDOM_SEED)
107+
seed!(TEST_RANDOM_SEED)
107108
alpha = b"空即是色"
108109
encoder = Encoder()
109110
initialize(encoder)

test/runtests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
using TranscodingStreams
22
using Compat
3-
if VERSION > v"0.7-"
3+
if VERSION v"0.7.0-rc1"
44
using Test
5+
using Pkg
56
else
67
using Base.Test
78
end

0 commit comments

Comments
 (0)