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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // Test most significant bits. | 355 // Test most significant bits. |
356 x = V8_2PART_UINT64_C(0xE0000000, 00000000); | 356 x = V8_2PART_UINT64_C(0xE0000000, 00000000); |
357 CHECK(x == UpperBits::encode(7)); | 357 CHECK(x == UpperBits::encode(7)); |
358 CHECK_EQ(7, UpperBits::decode(x)); | 358 CHECK_EQ(7, UpperBits::decode(x)); |
359 | 359 |
360 // Test the 32/64-bit boundary bits. | 360 // Test the 32/64-bit boundary bits. |
361 x = V8_2PART_UINT64_C(0x00000001, 80000000); | 361 x = V8_2PART_UINT64_C(0x00000001, 80000000); |
362 CHECK(x == MiddleBits::encode(3)); | 362 CHECK(x == MiddleBits::encode(3)); |
363 CHECK_EQ(3, MiddleBits::decode(x)); | 363 CHECK_EQ(3, MiddleBits::decode(x)); |
364 } | 364 } |
| 365 |
| 366 |
| 367 static void CheckNonArrayIndex(bool expected, const char* chars) { |
| 368 auto isolate = CcTest::i_isolate(); |
| 369 auto string = isolate->factory()->NewStringFromAsciiChecked(chars); |
| 370 CHECK_EQ(expected, IsNonArrayIndexInteger(*string)); |
| 371 } |
| 372 |
| 373 |
| 374 TEST(NonArrayIndexParsing) { |
| 375 auto isolate = CcTest::i_isolate(); |
| 376 HandleScope scope(isolate); |
| 377 CheckNonArrayIndex(false, "-"); |
| 378 CheckNonArrayIndex(false, "0"); |
| 379 CheckNonArrayIndex(false, "01"); |
| 380 CheckNonArrayIndex(false, "-01"); |
| 381 CheckNonArrayIndex(false, "4294967295"); |
| 382 CheckNonArrayIndex(false, "429496.7295"); |
| 383 CheckNonArrayIndex(false, "43s3"); |
| 384 CheckNonArrayIndex(true, "-0"); |
| 385 CheckNonArrayIndex(true, "-1"); |
| 386 CheckNonArrayIndex(true, "4294967296"); |
| 387 CheckNonArrayIndex(true, "-4294967296"); |
| 388 CheckNonArrayIndex( |
| 389 true, |
| 390 "429496729642949672964294967296429496729642949672964294967296" |
| 391 "429496729642949672964294967296429496729642949672964294967296" |
| 392 "429496729642949672964294967296429496729642949672964294967296" |
| 393 "429496729642949672964294967296429496729642949672964294967296" |
| 394 "429496729642949672964294967296429496729642949672964294967296" |
| 395 "429496729642949672964294967296429496729642949672964294967296" |
| 396 "429496729642949672964294967296429496729642949672964294967296" |
| 397 "429496729642949672964294967296429496729642949672964294967296" |
| 398 "429496729642949672964294967296429496729642949672964294967296" |
| 399 "429496729642949672964294967296429496729642949672964294967296" |
| 400 "429496729642949672964294967296429496729642949672964294967296" |
| 401 "429496729642949672964294967296429496729642949672964294967296" |
| 402 "429496729642949672964294967296429496729642949672964294967296"); |
| 403 CheckNonArrayIndex( |
| 404 true, |
| 405 "-429496729642949672964294967296429496729642949672964294967296" |
| 406 "429496729642949672964294967296429496729642949672964294967296" |
| 407 "429496729642949672964294967296429496729642949672964294967296" |
| 408 "429496729642949672964294967296429496729642949672964294967296" |
| 409 "429496729642949672964294967296429496729642949672964294967296" |
| 410 "429496729642949672964294967296429496729642949672964294967296" |
| 411 "429496729642949672964294967296429496729642949672964294967296" |
| 412 "429496729642949672964294967296429496729642949672964294967296" |
| 413 "429496729642949672964294967296429496729642949672964294967296" |
| 414 "429496729642949672964294967296429496729642949672964294967296" |
| 415 "429496729642949672964294967296429496729642949672964294967296" |
| 416 "429496729642949672964294967296429496729642949672964294967296" |
| 417 "429496729642949672964294967296429496729642949672964294967296"); |
| 418 } |
OLD | NEW |