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

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

Issue 1038313004: fix special index parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: NaN test Created 5 years, 8 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
« no previous file with comments | « src/lookup.cc ('k') | test/mjsunit/harmony/typedarrays.js » ('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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 365
366 366
367 static void CheckNonArrayIndex(bool expected, const char* chars) { 367 static void CheckNonArrayIndex(bool expected, const char* chars) {
368 auto isolate = CcTest::i_isolate(); 368 auto isolate = CcTest::i_isolate();
369 auto string = isolate->factory()->NewStringFromAsciiChecked(chars); 369 auto string = isolate->factory()->NewStringFromAsciiChecked(chars);
370 CHECK_EQ(expected, IsNonArrayIndexInteger(*string)); 370 CHECK_EQ(expected, IsSpecialIndex(isolate->unicode_cache(), *string));
371 } 371 }
372 372
373 373
374 TEST(NonArrayIndexParsing) { 374 TEST(SpecialIndexParsing) {
375 auto isolate = CcTest::i_isolate(); 375 auto isolate = CcTest::i_isolate();
376 HandleScope scope(isolate); 376 HandleScope scope(isolate);
377 CheckNonArrayIndex(false, ""); 377 CheckNonArrayIndex(false, "");
378 CheckNonArrayIndex(false, "-"); 378 CheckNonArrayIndex(false, "-");
379 CheckNonArrayIndex(false, "0"); 379 CheckNonArrayIndex(true, "0");
380 CheckNonArrayIndex(true, "-0");
380 CheckNonArrayIndex(false, "01"); 381 CheckNonArrayIndex(false, "01");
381 CheckNonArrayIndex(false, "-01"); 382 CheckNonArrayIndex(false, "-01");
382 CheckNonArrayIndex(false, "4294967295"); 383 CheckNonArrayIndex(true, "0.5");
383 CheckNonArrayIndex(false, "429496.7295"); 384 CheckNonArrayIndex(true, "-0.5");
385 CheckNonArrayIndex(true, "1");
386 CheckNonArrayIndex(true, "-1");
387 CheckNonArrayIndex(true, "10");
388 CheckNonArrayIndex(true, "-10");
389 CheckNonArrayIndex(true, "NaN");
390 CheckNonArrayIndex(true, "Infinity");
391 CheckNonArrayIndex(true, "-Infinity");
392 CheckNonArrayIndex(true, "4294967295");
393 CheckNonArrayIndex(true, "429496.7295");
394 CheckNonArrayIndex(true, "1.3333333333333333");
395 CheckNonArrayIndex(false, "1.3333333333333339");
396 CheckNonArrayIndex(true, "1.333333333333331e+222");
397 CheckNonArrayIndex(true, "-1.3333333333333211e+222");
398 CheckNonArrayIndex(false, "-1.3333333333333311e+222");
399 CheckNonArrayIndex(true, "429496.7295");
384 CheckNonArrayIndex(false, "43s3"); 400 CheckNonArrayIndex(false, "43s3");
385 CheckNonArrayIndex(true, "-0");
386 CheckNonArrayIndex(true, "-1");
387 CheckNonArrayIndex(true, "4294967296"); 401 CheckNonArrayIndex(true, "4294967296");
388 CheckNonArrayIndex(true, "-4294967296"); 402 CheckNonArrayIndex(true, "-4294967296");
389 CheckNonArrayIndex( 403 CheckNonArrayIndex(true, "999999999999999");
390 true, 404 CheckNonArrayIndex(false, "9999999999999999");
391 "429496729642949672964294967296429496729642949672964294967296" 405 CheckNonArrayIndex(true, "-999999999999999");
392 "429496729642949672964294967296429496729642949672964294967296" 406 CheckNonArrayIndex(false, "-9999999999999999");
393 "429496729642949672964294967296429496729642949672964294967296" 407 CheckNonArrayIndex(false, "42949672964294967296429496729694966");
394 "429496729642949672964294967296429496729642949672964294967296"
395 "429496729642949672964294967296429496729642949672964294967296"
396 "429496729642949672964294967296429496729642949672964294967296"
397 "429496729642949672964294967296429496729642949672964294967296"
398 "429496729642949672964294967296429496729642949672964294967296"
399 "429496729642949672964294967296429496729642949672964294967296"
400 "429496729642949672964294967296429496729642949672964294967296"
401 "429496729642949672964294967296429496729642949672964294967296"
402 "429496729642949672964294967296429496729642949672964294967296"
403 "429496729642949672964294967296429496729642949672964294967296");
404 CheckNonArrayIndex(
405 true,
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 "429496729642949672964294967296429496729642949672964294967296");
419 } 408 }
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | test/mjsunit/harmony/typedarrays.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698