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

Side by Side Diff: test/cctest/test-random-number-generator.cc

Issue 333053002: Untangle RNG from v8 core (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils/random-number-generator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 TEST(NextDoubleRange) { 65 TEST(NextDoubleRange) {
66 for (unsigned n = 0; n < ARRAY_SIZE(kRandomSeeds); ++n) { 66 for (unsigned n = 0; n < ARRAY_SIZE(kRandomSeeds); ++n) {
67 RandomNumberGenerator rng(kRandomSeeds[n]); 67 RandomNumberGenerator rng(kRandomSeeds[n]);
68 for (int k = 0; k < kMaxRuns; ++k) { 68 for (int k = 0; k < kMaxRuns; ++k) {
69 double d = rng.NextDouble(); 69 double d = rng.NextDouble();
70 CHECK_LE(0.0, d); 70 CHECK_LE(0.0, d);
71 CHECK_LT(d, 1.0); 71 CHECK_LT(d, 1.0);
72 } 72 }
73 } 73 }
74 } 74 }
75
76
77 TEST(RandomSeedFlagIsUsed) {
Benedikt Meurer 2014/06/16 06:26:24 Please move this test in test-isolate.cc to test t
78 for (unsigned n = 0; n < ARRAY_SIZE(kRandomSeeds); ++n) {
79 FLAG_random_seed = kRandomSeeds[n];
80 RandomNumberGenerator rng1;
81 RandomNumberGenerator rng2(kRandomSeeds[n]);
82 for (int k = 1; k <= kMaxRuns; ++k) {
83 int64_t i1, i2;
84 rng1.NextBytes(&i1, sizeof(i1));
85 rng2.NextBytes(&i2, sizeof(i2));
86 CHECK_EQ(i2, i1);
87 CHECK_EQ(rng2.NextInt(), rng1.NextInt());
88 CHECK_EQ(rng2.NextInt(k), rng1.NextInt(k));
89 CHECK_EQ(rng2.NextDouble(), rng1.NextDouble());
90 }
91 }
92 }
OLDNEW
« no previous file with comments | « src/utils/random-number-generator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698