Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Unified Diff: test/cctest/test-types.cc

Issue 231443002: Improve reproducibility of test runs. (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Address nit Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/test-strtod.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-types.cc
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
index 3448a841bde55b9aadbf59b365f06364207792fc..7b727c71d9f9004e1568a4597d22c1ccb1f23a7b 100644
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -29,6 +29,7 @@
#include "cctest.h"
#include "types.h"
+#include "utils/random-number-generator.h"
using namespace v8::internal;
@@ -112,6 +113,8 @@ class Types {
objects.push_back(array);
}
+ RandomNumberGenerator rng;
+
TypeHandle Representation;
TypeHandle Semantic;
TypeHandle None;
@@ -180,14 +183,14 @@ class Types {
}
TypeHandle Fuzz(int depth = 5) {
- switch (rand() % (depth == 0 ? 3 : 20)) {
+ switch (rng.NextInt(depth == 0 ? 3 : 20)) {
case 0: { // bitset
int n = 0
#define COUNT_BITSET_TYPES(type, value) + 1
BITSET_TYPE_LIST(COUNT_BITSET_TYPES)
#undef COUNT_BITSET_TYPES
;
- int i = rand() % n;
+ int i = rng.NextInt(n);
#define PICK_BITSET_TYPE(type, value) \
if (i-- == 0) return Type::type(region_);
BITSET_TYPE_LIST(PICK_BITSET_TYPE)
@@ -195,13 +198,13 @@ class Types {
UNREACHABLE();
}
case 1: // class
- switch (rand() % 2) {
+ switch (rng.NextInt(2)) {
case 0: return ObjectClass;
case 1: return ArrayClass;
}
UNREACHABLE();
case 2: // constant
- switch (rand() % 6) {
+ switch (rng.NextInt(6)) {
case 0: return SmiConstant;
case 1: return Signed32Constant;
case 2: return ObjectConstant1;
@@ -211,7 +214,7 @@ class Types {
}
UNREACHABLE();
default: { // union
- int n = rand() % 10;
+ int n = rng.NextInt(10);
TypeHandle type = None;
for (int i = 0; i < n; ++i) {
type = Type::Union(type, Fuzz(depth - 1), region_);
« no previous file with comments | « test/cctest/test-strtod.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698