| OLD | NEW |
| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 222 } |
| 223 | 223 |
| 224 | 224 |
| 225 static uint32_t PseudoRandom(uint32_t i, uint32_t j) { | 225 static uint32_t PseudoRandom(uint32_t i, uint32_t j) { |
| 226 return ~(~((i * 781) ^ (j * 329))); | 226 return ~(~((i * 781) ^ (j * 329))); |
| 227 } | 227 } |
| 228 | 228 |
| 229 | 229 |
| 230 TEST(StringHash) { | 230 TEST(StringHash) { |
| 231 if (env.IsEmpty()) env = v8::Context::New(); | 231 if (env.IsEmpty()) env = v8::Context::New(); |
| 232 for (int a = 0; a < String::kMaxOneByteCharCode; a++) { | 232 for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) { |
| 233 // Numbers are hashed differently. | 233 // Numbers are hashed differently. |
| 234 if (a >= '0' && a <= '9') continue; | 234 if (a >= '0' && a <= '9') continue; |
| 235 for (int b = 0; b < String::kMaxOneByteCharCode; b++) { | 235 for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) { |
| 236 if (b >= '0' && b <= '9') continue; | 236 if (b >= '0' && b <= '9') continue; |
| 237 check_twochars(static_cast<uint8_t>(a), static_cast<uint8_t>(b)); | 237 check_twochars(a, b); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 check(i::Vector<const char>("*", 1)); | 240 check(i::Vector<const char>("*", 1)); |
| 241 check(i::Vector<const char>(".zZ", 3)); | 241 check(i::Vector<const char>(".zZ", 3)); |
| 242 check(i::Vector<const char>("muc", 3)); | 242 check(i::Vector<const char>("muc", 3)); |
| 243 check(i::Vector<const char>("(>'_')>", 7)); | 243 check(i::Vector<const char>("(>'_')>", 7)); |
| 244 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21)); | 244 check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21)); |
| 245 } | 245 } |
| 246 | 246 |
| 247 | 247 |
| 248 TEST(NumberHash) { | 248 TEST(NumberHash) { |
| 249 if (env.IsEmpty()) env = v8::Context::New(); | 249 if (env.IsEmpty()) env = v8::Context::New(); |
| 250 | 250 |
| 251 // Some specific numbers | 251 // Some specific numbers |
| 252 for (uint32_t key = 0; key < 42; key += 7) { | 252 for (uint32_t key = 0; key < 42; key += 7) { |
| 253 check(key); | 253 check(key); |
| 254 } | 254 } |
| 255 | 255 |
| 256 // Some pseudo-random numbers | 256 // Some pseudo-random numbers |
| 257 static const uint32_t kLimit = 1000; | 257 static const uint32_t kLimit = 1000; |
| 258 for (uint32_t i = 0; i < 5; i++) { | 258 for (uint32_t i = 0; i < 5; i++) { |
| 259 for (uint32_t j = 0; j < 5; j++) { | 259 for (uint32_t j = 0; j < 5; j++) { |
| 260 check(PseudoRandom(i, j) % kLimit); | 260 check(PseudoRandom(i, j) % kLimit); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 #undef __ | 265 #undef __ |
| OLD | NEW |