Issue 18715 - Non-documented unittests should not use unpredictableSeed or default Random alias#6414
Conversation
|
Thanks for your pull request and interest in making D better, @n8sh! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + phobos#6414" |
|
Note: I have already done some derandomization of Phobos myself (see the PRs below) and there were some folks who wanted
Imho we have only made bad experiences with random data (hello failing CIs), so I am obviously in favor of this. |
std/random.d
Outdated
| gen.seed(map!((a) => 123_456_789U)(repeat(0, 624))); | ||
| //infinite Range | ||
| gen.seed(map!((a) => unpredictableSeed)(repeat(0))); | ||
| gen.seed(map!((a) => 123_456_789U)(repeat(0))); |
std/random.d
Outdated
| assertThrown(gen.seed(map!((a) => 123_456_789U)(repeat(0, 623)))); | ||
|
|
||
| gen.seed(map!((a) => unpredictableSeed)(repeat(0, 624))); | ||
| gen.seed(map!((a) => 123_456_789U)(repeat(0, 624))); |
There was a problem hiding this comment.
123_456_789U.repeat(624) ?
std/random.d
Outdated
| static foreach (Type; std.meta.AliasSeq!(Mt19937, Mt19937_64)) | ||
| {{ | ||
| auto gen1 = Type(unpredictableSeed); | ||
| auto gen1 = Type(123_456_789); gen1.popFront(); |
There was a problem hiding this comment.
Better move the popFront into a newline, people don't like this short style:
One statement per line.
bb7238f to
17058dd
Compare
…ed or default Random alias
17058dd to
c1d1c0e
Compare
Rationale in review comment by @wilzbach #6410 (comment):
This PR applies this across Phobos. Exceptions are made for public unittests that may be meant to demonstrate use of unpredictableSeed and/or the default Random.