-
-
Notifications
You must be signed in to change notification settings - Fork 740
Issue 18715 - Non-documented unittests should not use unpredictableSeed or default Random alias #6414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
//infinite Range | ||
gen.seed(map!((a) => unpredictableSeed)(repeat(0))); | ||
gen.seed(map!((a) => 123_456_789U)(repeat(0))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
123_456_789U.repeat
?
std/random.d
Outdated
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
123_456_789U.repeat(624)
?
std/random.d
Outdated
@@ -1020,7 +1020,7 @@ alias Mt19937_64 = MersenneTwisterEngine!(ulong, 64, 312, 156, 31, | |||
// Check .save works | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.