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

Side by Side Diff: test/cctest/test-hashing.cc

Issue 24265002: bulk replace v8::Isolate::GetCurrent in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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-declarative-accessors.cc ('k') | test/cctest/test-heap.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 check(i::Vector<const uint8_t>(ab, 2)); 223 check(i::Vector<const uint8_t>(ab, 2));
224 } 224 }
225 225
226 226
227 static uint32_t PseudoRandom(uint32_t i, uint32_t j) { 227 static uint32_t PseudoRandom(uint32_t i, uint32_t j) {
228 return ~(~((i * 781) ^ (j * 329))); 228 return ~(~((i * 781) ^ (j * 329)));
229 } 229 }
230 230
231 231
232 TEST(StringHash) { 232 TEST(StringHash) {
233 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 233 v8::Isolate* isolate = CcTest::isolate();
234 v8::HandleScope handle_scope(isolate); 234 v8::HandleScope handle_scope(isolate);
235 v8::Context::Scope context_scope(v8::Context::New(isolate)); 235 v8::Context::Scope context_scope(v8::Context::New(isolate));
236 236
237 for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) { 237 for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) {
238 // Numbers are hashed differently. 238 // Numbers are hashed differently.
239 if (a >= '0' && a <= '9') continue; 239 if (a >= '0' && a <= '9') continue;
240 for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) { 240 for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) {
241 if (b >= '0' && b <= '9') continue; 241 if (b >= '0' && b <= '9') continue;
242 check_twochars(a, b); 242 check_twochars(a, b);
243 } 243 }
244 } 244 }
245 check(i::Vector<const char>("*", 1)); 245 check(i::Vector<const char>("*", 1));
246 check(i::Vector<const char>(".zZ", 3)); 246 check(i::Vector<const char>(".zZ", 3));
247 check(i::Vector<const char>("muc", 3)); 247 check(i::Vector<const char>("muc", 3));
248 check(i::Vector<const char>("(>'_')>", 7)); 248 check(i::Vector<const char>("(>'_')>", 7));
249 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21)); 249 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21));
250 } 250 }
251 251
252 252
253 TEST(NumberHash) { 253 TEST(NumberHash) {
254 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 254 v8::Isolate* isolate = CcTest::isolate();
255 v8::HandleScope handle_scope(isolate); 255 v8::HandleScope handle_scope(isolate);
256 v8::Context::Scope context_scope(v8::Context::New(isolate)); 256 v8::Context::Scope context_scope(v8::Context::New(isolate));
257 257
258 // Some specific numbers 258 // Some specific numbers
259 for (uint32_t key = 0; key < 42; key += 7) { 259 for (uint32_t key = 0; key < 42; key += 7) {
260 check(key); 260 check(key);
261 } 261 }
262 262
263 // Some pseudo-random numbers 263 // Some pseudo-random numbers
264 static const uint32_t kLimit = 1000; 264 static const uint32_t kLimit = 1000;
265 for (uint32_t i = 0; i < 5; i++) { 265 for (uint32_t i = 0; i < 5; i++) {
266 for (uint32_t j = 0; j < 5; j++) { 266 for (uint32_t j = 0; j < 5; j++) {
267 check(PseudoRandom(i, j) % kLimit); 267 check(PseudoRandom(i, j) % kLimit);
268 } 268 }
269 } 269 }
270 } 270 }
271 271
272 #undef __ 272 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-declarative-accessors.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698