Fix unpredictableSeed so that rndstuff can be used in @safe code

Allows:
1) canFind's tests to be @safe
2) allows the remainder of find's tests to be @safe
This commit is contained in:
Brad Roberts 2014-10-12 01:25:10 -07:00
parent 3200b08644
commit f70e1e41e4
2 changed files with 7 additions and 7 deletions

View file

@ -5520,7 +5520,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
assert(find("abc", "bc").length == 2); assert(find("abc", "bc").length == 2);
} }
unittest @safe unittest
{ {
import std.string : toUpper; import std.string : toUpper;
@ -5549,7 +5549,7 @@ unittest
assert(find!(f)(s, "hello").length == 3); assert(find!(f)(s, "hello").length == 3);
} }
unittest @safe unittest
{ {
debug(std_algorithm) scope(success) debug(std_algorithm) scope(success)
writeln("unittest @", __FILE__, ":", __LINE__, " done."); writeln("unittest @", __FILE__, ":", __LINE__, " done.");
@ -12109,7 +12109,7 @@ template canFind(alias pred="a == b")
} }
/// ///
unittest @safe unittest
{ {
assert(canFind([0, 1, 2, 3], 2) == true); assert(canFind([0, 1, 2, 3], 2) == true);
assert(canFind([0, 1, 2, 3], [1, 2], [2, 3])); assert(canFind([0, 1, 2, 3], [1, 2], [2, 3]));
@ -12122,7 +12122,7 @@ unittest
assert(canFind([0, 1, 2, 3], [1, 3], [2, 4]) == 0); assert(canFind([0, 1, 2, 3], [1, 3], [2, 4]) == 0);
} }
unittest @safe unittest
{ {
debug(std_algorithm) scope(success) debug(std_algorithm) scope(success)
writeln("unittest @", __FILE__, ":", __LINE__, " done."); writeln("unittest @", __FILE__, ":", __LINE__, " done.");
@ -12134,7 +12134,7 @@ unittest
} }
} }
unittest @safe unittest
{ {
assert(equal!(canFind!"a < b")([[1, 2, 3], [7, 8, 9]], [2, 8])); assert(equal!(canFind!"a < b")([[1, 2, 3], [7, 8, 9]], [2, 8]));
} }

View file

@ -1114,7 +1114,7 @@ auto n = rnd.front;
---- ----
*/ */
@property uint unpredictableSeed() @property uint unpredictableSeed() @trusted
{ {
static bool seeded; static bool seeded;
static MinstdRand0 rand; static MinstdRand0 rand;
@ -1128,7 +1128,7 @@ auto n = rnd.front;
return cast(uint) (TickDuration.currSystemTick.length ^ rand.front); return cast(uint) (TickDuration.currSystemTick.length ^ rand.front);
} }
unittest @safe unittest
{ {
// not much to test here // not much to test here
auto a = unpredictableSeed; auto a = unpredictableSeed;