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

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

Issue 582953002: Revert "Require V8 to be explicitly initialized before an Isolate is created" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | « test/cctest/test-macro-assembler-x87.cc ('k') | test/cctest/test-regexp.cc » ('j') | 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 16 matching lines...) Expand all
27 27
28 #include "src/v8.h" 28 #include "src/v8.h"
29 #include "test/cctest/cctest.h" 29 #include "test/cctest/cctest.h"
30 30
31 #include "src/base/utils/random-number-generator.h" 31 #include "src/base/utils/random-number-generator.h"
32 #include "src/isolate-inl.h" 32 #include "src/isolate-inl.h"
33 33
34 using namespace v8::internal; 34 using namespace v8::internal;
35 35
36 36
37 static const int64_t kRandomSeeds[] = {-1, 1, 42, 100, 1234567890, 987654321}; 37 static const int kMaxRuns = 12345;
38 static const int kRandomSeeds[] = {
39 -1, 1, 42, 100, 1234567890, 987654321
40 };
38 41
39 42
40 TEST(RandomSeedFlagIsUsed) { 43 TEST(RandomSeedFlagIsUsed) {
41 for (unsigned n = 0; n < arraysize(kRandomSeeds); ++n) { 44 for (unsigned n = 0; n < arraysize(kRandomSeeds); ++n) {
42 FLAG_random_seed = static_cast<int>(kRandomSeeds[n]); 45 FLAG_random_seed = kRandomSeeds[n];
43 v8::Isolate* i = v8::Isolate::New(); 46 v8::Isolate* i = v8::Isolate::New();
44 v8::base::RandomNumberGenerator& rng = 47 v8::base::RandomNumberGenerator& rng1 =
45 *reinterpret_cast<Isolate*>(i)->random_number_generator(); 48 *reinterpret_cast<Isolate*>(i)->random_number_generator();
46 CHECK_EQ(kRandomSeeds[n], rng.initial_seed()); 49 v8::base::RandomNumberGenerator rng2(kRandomSeeds[n]);
50 for (int k = 1; k <= kMaxRuns; ++k) {
51 int64_t i1, i2;
52 rng1.NextBytes(&i1, sizeof(i1));
53 rng2.NextBytes(&i2, sizeof(i2));
54 CHECK_EQ(i2, i1);
55 CHECK_EQ(rng2.NextInt(), rng1.NextInt());
56 CHECK_EQ(rng2.NextInt(k), rng1.NextInt(k));
57 CHECK_EQ(rng2.NextDouble(), rng1.NextDouble());
58 }
47 i->Dispose(); 59 i->Dispose();
48 } 60 }
49 } 61 }
OLDNEW
« no previous file with comments | « test/cctest/test-macro-assembler-x87.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698