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

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

Issue 2493002: - Remove [static] from methods in Zone and associated helpers. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 years, 6 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 for (int j = 0; !in_class && j < ranges->length(); j++) { 452 for (int j = 0; !in_class && j < ranges->length(); j++) {
453 CharacterRange& range = ranges->at(j); 453 CharacterRange& range = ranges->at(j);
454 in_class = (range.from() <= i && i <= range.to()); 454 in_class = (range.from() <= i && i <= range.to());
455 } 455 }
456 CHECK_EQ(pred(i), in_class); 456 CHECK_EQ(pred(i), in_class);
457 } 457 }
458 } 458 }
459 459
460 460
461 TEST(CharacterClassEscapes) { 461 TEST(CharacterClassEscapes) {
462 v8::internal::V8::Initialize(NULL);
462 TestCharacterClassEscapes('.', IsRegExpNewline); 463 TestCharacterClassEscapes('.', IsRegExpNewline);
463 TestCharacterClassEscapes('d', IsDigit); 464 TestCharacterClassEscapes('d', IsDigit);
464 TestCharacterClassEscapes('D', NotDigit); 465 TestCharacterClassEscapes('D', NotDigit);
465 TestCharacterClassEscapes('s', IsWhiteSpace); 466 TestCharacterClassEscapes('s', IsWhiteSpace);
466 TestCharacterClassEscapes('S', NotWhiteSpace); 467 TestCharacterClassEscapes('S', NotWhiteSpace);
467 TestCharacterClassEscapes('w', IsRegExpWord); 468 TestCharacterClassEscapes('w', IsRegExpWord);
468 TestCharacterClassEscapes('W', NotWord); 469 TestCharacterClassEscapes('W', NotWord);
469 } 470 }
470 471
471 472
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 const int TestConfig::kNoKey = 0; 519 const int TestConfig::kNoKey = 0;
519 const int TestConfig::kNoValue = 0; 520 const int TestConfig::kNoValue = 0;
520 521
521 522
522 static unsigned PseudoRandom(int i, int j) { 523 static unsigned PseudoRandom(int i, int j) {
523 return ~(~((i * 781) ^ (j * 329))); 524 return ~(~((i * 781) ^ (j * 329)));
524 } 525 }
525 526
526 527
527 TEST(SplayTreeSimple) { 528 TEST(SplayTreeSimple) {
529 v8::internal::V8::Initialize(NULL);
528 static const unsigned kLimit = 1000; 530 static const unsigned kLimit = 1000;
529 ZoneScope zone_scope(DELETE_ON_EXIT); 531 ZoneScope zone_scope(DELETE_ON_EXIT);
530 ZoneSplayTree<TestConfig> tree; 532 ZoneSplayTree<TestConfig> tree;
531 bool seen[kLimit]; 533 bool seen[kLimit];
532 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; 534 for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
533 #define CHECK_MAPS_EQUAL() do { \ 535 #define CHECK_MAPS_EQUAL() do { \
534 for (unsigned k = 0; k < kLimit; k++) \ 536 for (unsigned k = 0; k < kLimit; k++) \
535 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ 537 CHECK_EQ(seen[k], tree.Find(k, &loc)); \
536 } while (false) 538 } while (false)
537 for (int i = 0; i < 50; i++) { 539 for (int i = 0; i < 50; i++) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 CHECK(tree.FindLeastGreaterThan(val, &loc)); 572 CHECK(tree.FindLeastGreaterThan(val, &loc));
571 CHECK_EQ(loc.key(), val); 573 CHECK_EQ(loc.key(), val);
572 break; 574 break;
573 } 575 }
574 } 576 }
575 } 577 }
576 } 578 }
577 579
578 580
579 TEST(DispatchTableConstruction) { 581 TEST(DispatchTableConstruction) {
582 v8::internal::V8::Initialize(NULL);
580 // Initialize test data. 583 // Initialize test data.
581 static const int kLimit = 1000; 584 static const int kLimit = 1000;
582 static const int kRangeCount = 8; 585 static const int kRangeCount = 8;
583 static const int kRangeSize = 16; 586 static const int kRangeSize = 16;
584 uc16 ranges[kRangeCount][2 * kRangeSize]; 587 uc16 ranges[kRangeCount][2 * kRangeSize];
585 for (int i = 0; i < kRangeCount; i++) { 588 for (int i = 0; i < kRangeCount; i++) {
586 Vector<uc16> range(ranges[i], 2 * kRangeSize); 589 Vector<uc16> range(ranges[i], 2 * kRangeSize);
587 for (int j = 0; j < 2 * kRangeSize; j++) { 590 for (int j = 0; j < 2 * kRangeSize; j++) {
588 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; 591 range[j] = PseudoRandom(i + 25, j + 87) % kLimit;
589 } 592 }
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); 1332 Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6));
1330 1333
1331 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); 1334 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0));
1332 CHECK_EQ(42, captures[0]); 1335 CHECK_EQ(42, captures[0]);
1333 } 1336 }
1334 1337
1335 #endif // V8_INTERPRETED_REGEXP 1338 #endif // V8_INTERPRETED_REGEXP
1336 1339
1337 1340
1338 TEST(AddInverseToTable) { 1341 TEST(AddInverseToTable) {
1342 v8::internal::V8::Initialize(NULL);
1339 static const int kLimit = 1000; 1343 static const int kLimit = 1000;
1340 static const int kRangeCount = 16; 1344 static const int kRangeCount = 16;
1341 for (int t = 0; t < 10; t++) { 1345 for (int t = 0; t < 10; t++) {
1342 ZoneScope zone_scope(DELETE_ON_EXIT); 1346 ZoneScope zone_scope(DELETE_ON_EXIT);
1343 ZoneList<CharacterRange>* ranges = 1347 ZoneList<CharacterRange>* ranges =
1344 new ZoneList<CharacterRange>(kRangeCount); 1348 new ZoneList<CharacterRange>(kRangeCount);
1345 for (int i = 0; i < kRangeCount; i++) { 1349 for (int i = 0; i < kRangeCount; i++) {
1346 int from = PseudoRandom(t + 87, i + 25) % kLimit; 1350 int from = PseudoRandom(t + 87, i + 25) % kLimit;
1347 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); 1351 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20));
1348 if (to > kLimit) to = kLimit; 1352 if (to > kLimit) to = kLimit;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1508
1505 static void TestSimpleRangeCaseIndependence(CharacterRange input, 1509 static void TestSimpleRangeCaseIndependence(CharacterRange input,
1506 CharacterRange expected) { 1510 CharacterRange expected) {
1507 EmbeddedVector<CharacterRange, 1> vector; 1511 EmbeddedVector<CharacterRange, 1> vector;
1508 vector[0] = expected; 1512 vector[0] = expected;
1509 TestRangeCaseIndependence(input, vector); 1513 TestRangeCaseIndependence(input, vector);
1510 } 1514 }
1511 1515
1512 1516
1513 TEST(CharacterRangeCaseIndependence) { 1517 TEST(CharacterRangeCaseIndependence) {
1518 v8::internal::V8::Initialize(NULL);
1514 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('a'), 1519 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('a'),
1515 CharacterRange::Singleton('A')); 1520 CharacterRange::Singleton('A'));
1516 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('z'), 1521 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('z'),
1517 CharacterRange::Singleton('Z')); 1522 CharacterRange::Singleton('Z'));
1518 TestSimpleRangeCaseIndependence(CharacterRange('a', 'z'), 1523 TestSimpleRangeCaseIndependence(CharacterRange('a', 'z'),
1519 CharacterRange('A', 'Z')); 1524 CharacterRange('A', 'Z'));
1520 TestSimpleRangeCaseIndependence(CharacterRange('c', 'f'), 1525 TestSimpleRangeCaseIndependence(CharacterRange('c', 'f'),
1521 CharacterRange('C', 'F')); 1526 CharacterRange('C', 'F'));
1522 TestSimpleRangeCaseIndependence(CharacterRange('a', 'b'), 1527 TestSimpleRangeCaseIndependence(CharacterRange('a', 'b'),
1523 CharacterRange('A', 'B')); 1528 CharacterRange('A', 'B'));
(...skipping 21 matching lines...) Expand all
1545 for (int i = 0; i < ranges->length(); i++) { 1550 for (int i = 0; i < ranges->length(); i++) {
1546 CharacterRange range = ranges->at(i); 1551 CharacterRange range = ranges->at(i);
1547 if (range.from() <= c && c <= range.to()) 1552 if (range.from() <= c && c <= range.to())
1548 return true; 1553 return true;
1549 } 1554 }
1550 return false; 1555 return false;
1551 } 1556 }
1552 1557
1553 1558
1554 TEST(CharClassDifference) { 1559 TEST(CharClassDifference) {
1560 v8::internal::V8::Initialize(NULL);
1555 ZoneScope zone_scope(DELETE_ON_EXIT); 1561 ZoneScope zone_scope(DELETE_ON_EXIT);
1556 ZoneList<CharacterRange>* base = new ZoneList<CharacterRange>(1); 1562 ZoneList<CharacterRange>* base = new ZoneList<CharacterRange>(1);
1557 base->Add(CharacterRange::Everything()); 1563 base->Add(CharacterRange::Everything());
1558 Vector<const uc16> overlay = CharacterRange::GetWordBounds(); 1564 Vector<const uc16> overlay = CharacterRange::GetWordBounds();
1559 ZoneList<CharacterRange>* included = NULL; 1565 ZoneList<CharacterRange>* included = NULL;
1560 ZoneList<CharacterRange>* excluded = NULL; 1566 ZoneList<CharacterRange>* excluded = NULL;
1561 CharacterRange::Split(base, overlay, &included, &excluded); 1567 CharacterRange::Split(base, overlay, &included, &excluded);
1562 for (int i = 0; i < (1 << 16); i++) { 1568 for (int i = 0; i < (1 << 16); i++) {
1563 bool in_base = InClass(i, base); 1569 bool in_base = InClass(i, base);
1564 if (in_base) { 1570 if (in_base) {
1565 bool in_overlay = false; 1571 bool in_overlay = false;
1566 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { 1572 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) {
1567 if (overlay[j] <= i && i <= overlay[j+1]) 1573 if (overlay[j] <= i && i <= overlay[j+1])
1568 in_overlay = true; 1574 in_overlay = true;
1569 } 1575 }
1570 CHECK_EQ(in_overlay, InClass(i, included)); 1576 CHECK_EQ(in_overlay, InClass(i, included));
1571 CHECK_EQ(!in_overlay, InClass(i, excluded)); 1577 CHECK_EQ(!in_overlay, InClass(i, excluded));
1572 } else { 1578 } else {
1573 CHECK(!InClass(i, included)); 1579 CHECK(!InClass(i, included));
1574 CHECK(!InClass(i, excluded)); 1580 CHECK(!InClass(i, excluded));
1575 } 1581 }
1576 } 1582 }
1577 } 1583 }
1578 1584
1579 1585
1580 TEST(CanonicalizeCharacterSets) { 1586 TEST(CanonicalizeCharacterSets) {
1587 v8::internal::V8::Initialize(NULL);
1581 ZoneScope scope(DELETE_ON_EXIT); 1588 ZoneScope scope(DELETE_ON_EXIT);
1582 ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(4); 1589 ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(4);
1583 CharacterSet set(list); 1590 CharacterSet set(list);
1584 1591
1585 list->Add(CharacterRange(10, 20)); 1592 list->Add(CharacterRange(10, 20));
1586 list->Add(CharacterRange(30, 40)); 1593 list->Add(CharacterRange(30, 40));
1587 list->Add(CharacterRange(50, 60)); 1594 list->Add(CharacterRange(50, 60));
1588 set.Canonicalize(); 1595 set.Canonicalize();
1589 ASSERT_EQ(3, list->length()); 1596 ASSERT_EQ(3, list->length());
1590 ASSERT_EQ(10, list->at(0).from()); 1597 ASSERT_EQ(10, list->at(0).from());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 for (int i = 0; i < set->length(); i++) { 1648 for (int i = 0; i < set->length(); i++) {
1642 CharacterRange range = set->at(i); 1649 CharacterRange range = set->at(i);
1643 if (range.from() <= value && value <= range.to()) { 1650 if (range.from() <= value && value <= range.to()) {
1644 return true; 1651 return true;
1645 } 1652 }
1646 } 1653 }
1647 return false; 1654 return false;
1648 } 1655 }
1649 1656
1650 TEST(CharacterRangeMerge) { 1657 TEST(CharacterRangeMerge) {
1658 v8::internal::V8::Initialize(NULL);
1651 ZoneScope zone_scope(DELETE_ON_EXIT); 1659 ZoneScope zone_scope(DELETE_ON_EXIT);
1652 ZoneList<CharacterRange> l1(4); 1660 ZoneList<CharacterRange> l1(4);
1653 ZoneList<CharacterRange> l2(4); 1661 ZoneList<CharacterRange> l2(4);
1654 // Create all combinations of intersections of ranges, both singletons and 1662 // Create all combinations of intersections of ranges, both singletons and
1655 // longer. 1663 // longer.
1656 1664
1657 int offset = 0; 1665 int offset = 0;
1658 1666
1659 // The five kinds of singleton intersections: 1667 // The five kinds of singleton intersections:
1660 // X 1668 // X
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 bool in_second = CharacterInSet(&l2, i); 1800 bool in_second = CharacterInSet(&l2, i);
1793 CHECK((in_first || in_second) == CharacterInSet(&all, i)); 1801 CHECK((in_first || in_second) == CharacterInSet(&all, i));
1794 } 1802 }
1795 } 1803 }
1796 1804
1797 1805
1798 TEST(Graph) { 1806 TEST(Graph) {
1799 V8::Initialize(NULL); 1807 V8::Initialize(NULL);
1800 Execute("\\b\\w+\\b", false, true, true); 1808 Execute("\\b\\w+\\b", false, true, true);
1801 } 1809 }
OLDNEW
« src/zone-inl.h ('K') | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698