Skip to content

Conversation

@n8sh
Copy link
Member

@n8sh n8sh commented Apr 3, 2018

Rationale in review comment by @wilzbach #6410 (comment):

Use a fixed seed and a fixed engine, everything else might lead to random coverage changes.

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.

@dlang-bot
Copy link
Contributor

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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

Auto-close Bugzilla Severity Description
18715 minor Non-documented unittests should not use unpredictableSeed or default Random alias

Testing this PR locally

If 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"

@wilzbach
Copy link
Contributor

wilzbach commented Apr 3, 2018

Note: I have already done some derandomization of Phobos myself (see the PRs below) and there were some folks who wanted unpredictableSeed to stay where it's used:

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)));
Copy link
Contributor

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
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)));
Copy link
Contributor

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
static foreach (Type; std.meta.AliasSeq!(Mt19937, Mt19937_64))
{{
auto gen1 = Type(unpredictableSeed);
auto gen1 = Type(123_456_789); gen1.popFront();
Copy link
Contributor

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.

(from https://dlang.org/dstyle.html#whitespace)

@n8sh n8sh force-pushed the remove-unpredictableseed-from-unittests branch from bb7238f to 17058dd Compare April 3, 2018 21:27
@n8sh n8sh force-pushed the remove-unpredictableseed-from-unittests branch from 17058dd to c1d1c0e Compare April 4, 2018 22:08
@dlang-bot dlang-bot merged commit c1fcea4 into dlang:master Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants