From 807f0c8904be14c9088ebc41ade885ffac142b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 4 Dec 2015 14:34:20 +0100 Subject: Correct rand:export_seed/0 when there is no prior seed According to the documentation, rand:export_seed/0 should return 'undefined' if the seed has not been intialized. However, it will create and return a seed. That means that the following code will not work as expected: case rand:export_seed() of undefined -> rand:seen({1,2,3}); _ -> ok end, rand:uniform(Range) --- lib/stdlib/test/rand_SUITE.erl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/stdlib/test') diff --git a/lib/stdlib/test/rand_SUITE.erl b/lib/stdlib/test/rand_SUITE.erl index 111bf620de..03b5ce1a25 100644 --- a/lib/stdlib/test/rand_SUITE.erl +++ b/lib/stdlib/test/rand_SUITE.erl @@ -126,6 +126,9 @@ seed_1(Alg) -> false = (S1 =:= rand:seed_s(Alg)), %% Negative integers works _ = rand:seed_s(Alg, {-1,-1,-1}), + %% Check that export_seed/1 returns 'undefined' if there is no seed + erase(rand_seed), + undefined = rand:export_seed(), %% Other term do not work {'EXIT', _} = (catch rand:seed_s(foobar, os:timestamp())), -- cgit v1.2.3