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

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

Issue 582953002: Revert "Require V8 to be explicitly initialized before an Isolate is created" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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-random-number-generator.cc ('k') | test/cctest/test-serialize.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #include "src/x87/macro-assembler-x87.h" 78 #include "src/x87/macro-assembler-x87.h"
79 #include "src/x87/regexp-macro-assembler-x87.h" 79 #include "src/x87/regexp-macro-assembler-x87.h"
80 #endif 80 #endif
81 #endif // V8_INTERPRETED_REGEXP 81 #endif // V8_INTERPRETED_REGEXP
82 #include "test/cctest/cctest.h" 82 #include "test/cctest/cctest.h"
83 83
84 using namespace v8::internal; 84 using namespace v8::internal;
85 85
86 86
87 static bool CheckParse(const char* input) { 87 static bool CheckParse(const char* input) {
88 V8::Initialize(NULL);
88 v8::HandleScope scope(CcTest::isolate()); 89 v8::HandleScope scope(CcTest::isolate());
89 Zone zone(CcTest::i_isolate()); 90 Zone zone(CcTest::i_isolate());
90 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); 91 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
91 RegExpCompileData result; 92 RegExpCompileData result;
92 return v8::internal::RegExpParser::ParseRegExp( 93 return v8::internal::RegExpParser::ParseRegExp(
93 &reader, false, &result, &zone); 94 &reader, false, &result, &zone);
94 } 95 }
95 96
96 97
97 static void CheckParseEq(const char* input, const char* expected) { 98 static void CheckParseEq(const char* input, const char* expected) {
99 V8::Initialize(NULL);
98 v8::HandleScope scope(CcTest::isolate()); 100 v8::HandleScope scope(CcTest::isolate());
99 Zone zone(CcTest::i_isolate()); 101 Zone zone(CcTest::i_isolate());
100 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); 102 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
101 RegExpCompileData result; 103 RegExpCompileData result;
102 CHECK(v8::internal::RegExpParser::ParseRegExp( 104 CHECK(v8::internal::RegExpParser::ParseRegExp(
103 &reader, false, &result, &zone)); 105 &reader, false, &result, &zone));
104 CHECK(result.tree != NULL); 106 CHECK(result.tree != NULL);
105 CHECK(result.error.is_null()); 107 CHECK(result.error.is_null());
106 OStringStream os; 108 OStringStream os;
107 result.tree->Print(os, &zone); 109 result.tree->Print(os, &zone);
108 CHECK_EQ(expected, os.c_str()); 110 CHECK_EQ(expected, os.c_str());
109 } 111 }
110 112
111 113
112 static bool CheckSimple(const char* input) { 114 static bool CheckSimple(const char* input) {
115 V8::Initialize(NULL);
113 v8::HandleScope scope(CcTest::isolate()); 116 v8::HandleScope scope(CcTest::isolate());
114 Zone zone(CcTest::i_isolate()); 117 Zone zone(CcTest::i_isolate());
115 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); 118 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
116 RegExpCompileData result; 119 RegExpCompileData result;
117 CHECK(v8::internal::RegExpParser::ParseRegExp( 120 CHECK(v8::internal::RegExpParser::ParseRegExp(
118 &reader, false, &result, &zone)); 121 &reader, false, &result, &zone));
119 CHECK(result.tree != NULL); 122 CHECK(result.tree != NULL);
120 CHECK(result.error.is_null()); 123 CHECK(result.error.is_null());
121 return result.simple; 124 return result.simple;
122 } 125 }
123 126
124 struct MinMaxPair { 127 struct MinMaxPair {
125 int min_match; 128 int min_match;
126 int max_match; 129 int max_match;
127 }; 130 };
128 131
129 132
130 static MinMaxPair CheckMinMaxMatch(const char* input) { 133 static MinMaxPair CheckMinMaxMatch(const char* input) {
134 V8::Initialize(NULL);
131 v8::HandleScope scope(CcTest::isolate()); 135 v8::HandleScope scope(CcTest::isolate());
132 Zone zone(CcTest::i_isolate()); 136 Zone zone(CcTest::i_isolate());
133 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); 137 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
134 RegExpCompileData result; 138 RegExpCompileData result;
135 CHECK(v8::internal::RegExpParser::ParseRegExp( 139 CHECK(v8::internal::RegExpParser::ParseRegExp(
136 &reader, false, &result, &zone)); 140 &reader, false, &result, &zone));
137 CHECK(result.tree != NULL); 141 CHECK(result.tree != NULL);
138 CHECK(result.error.is_null()); 142 CHECK(result.error.is_null());
139 int min_match = result.tree->min_match(); 143 int min_match = result.tree->min_match();
140 int max_match = result.tree->max_match(); 144 int max_match = result.tree->max_match();
141 MinMaxPair pair = { min_match, max_match }; 145 MinMaxPair pair = { min_match, max_match };
142 return pair; 146 return pair;
143 } 147 }
144 148
145 149
146 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) 150 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input))
147 #define CHECK_SIMPLE(input, simple) CHECK_EQ(simple, CheckSimple(input)); 151 #define CHECK_SIMPLE(input, simple) CHECK_EQ(simple, CheckSimple(input));
148 #define CHECK_MIN_MAX(input, min, max) \ 152 #define CHECK_MIN_MAX(input, min, max) \
149 { MinMaxPair min_max = CheckMinMaxMatch(input); \ 153 { MinMaxPair min_max = CheckMinMaxMatch(input); \
150 CHECK_EQ(min, min_max.min_match); \ 154 CHECK_EQ(min, min_max.min_match); \
151 CHECK_EQ(max, min_max.max_match); \ 155 CHECK_EQ(max, min_max.max_match); \
152 } 156 }
153 157
154 TEST(Parser) { 158 TEST(Parser) {
159 V8::Initialize(NULL);
160
155 CHECK_PARSE_ERROR("?"); 161 CHECK_PARSE_ERROR("?");
156 162
157 CheckParseEq("abc", "'abc'"); 163 CheckParseEq("abc", "'abc'");
158 CheckParseEq("", "%"); 164 CheckParseEq("", "%");
159 CheckParseEq("abc|def", "(| 'abc' 'def')"); 165 CheckParseEq("abc|def", "(| 'abc' 'def')");
160 CheckParseEq("abc|def|ghi", "(| 'abc' 'def' 'ghi')"); 166 CheckParseEq("abc|def|ghi", "(| 'abc' 'def' 'ghi')");
161 CheckParseEq("^xxx$", "(: @^i 'xxx' @$i)"); 167 CheckParseEq("^xxx$", "(: @^i 'xxx' @$i)");
162 CheckParseEq("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')"); 168 CheckParseEq("ab\\b\\d\\bcd", "(: 'ab' @b [0-9] @b 'cd')");
163 CheckParseEq("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])"); 169 CheckParseEq("\\w|\\d", "(| [0-9 A-Z _ a-z] [0-9])");
164 CheckParseEq("a*", "(# 0 - g 'a')"); 170 CheckParseEq("a*", "(# 0 - g 'a')");
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 400
395 TEST(ParserRegression) { 401 TEST(ParserRegression) {
396 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])"); 402 CheckParseEq("[A-Z$-][x]", "(! [A-Z $ -] [x])");
397 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); 403 CheckParseEq("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')");
398 CheckParseEq("{", "'{'"); 404 CheckParseEq("{", "'{'");
399 CheckParseEq("a|", "(| 'a' %)"); 405 CheckParseEq("a|", "(| 'a' %)");
400 } 406 }
401 407
402 static void ExpectError(const char* input, 408 static void ExpectError(const char* input,
403 const char* expected) { 409 const char* expected) {
410 V8::Initialize(NULL);
404 v8::HandleScope scope(CcTest::isolate()); 411 v8::HandleScope scope(CcTest::isolate());
405 Zone zone(CcTest::i_isolate()); 412 Zone zone(CcTest::i_isolate());
406 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); 413 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input));
407 RegExpCompileData result; 414 RegExpCompileData result;
408 CHECK(!v8::internal::RegExpParser::ParseRegExp( 415 CHECK(!v8::internal::RegExpParser::ParseRegExp(
409 &reader, false, &result, &zone)); 416 &reader, false, &result, &zone));
410 CHECK(result.tree == NULL); 417 CHECK(result.tree == NULL);
411 CHECK(!result.error.is_null()); 418 CHECK(!result.error.is_null());
412 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); 419 SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS);
413 CHECK_EQ(expected, str.get()); 420 CHECK_EQ(expected, str.get());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 for (int j = 0; !in_class && j < ranges->length(); j++) { 487 for (int j = 0; !in_class && j < ranges->length(); j++) {
481 CharacterRange& range = ranges->at(j); 488 CharacterRange& range = ranges->at(j);
482 in_class = (range.from() <= i && i <= range.to()); 489 in_class = (range.from() <= i && i <= range.to());
483 } 490 }
484 CHECK_EQ(pred(i), in_class); 491 CHECK_EQ(pred(i), in_class);
485 } 492 }
486 } 493 }
487 494
488 495
489 TEST(CharacterClassEscapes) { 496 TEST(CharacterClassEscapes) {
497 v8::internal::V8::Initialize(NULL);
490 TestCharacterClassEscapes('.', IsRegExpNewline); 498 TestCharacterClassEscapes('.', IsRegExpNewline);
491 TestCharacterClassEscapes('d', IsDigit); 499 TestCharacterClassEscapes('d', IsDigit);
492 TestCharacterClassEscapes('D', NotDigit); 500 TestCharacterClassEscapes('D', NotDigit);
493 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator); 501 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator);
494 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor); 502 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor);
495 TestCharacterClassEscapes('w', IsRegExpWord); 503 TestCharacterClassEscapes('w', IsRegExpWord);
496 TestCharacterClassEscapes('W', NotWord); 504 TestCharacterClassEscapes('W', NotWord);
497 } 505 }
498 506
499 507
500 static RegExpNode* Compile(const char* input, bool multiline, bool is_one_byte, 508 static RegExpNode* Compile(const char* input, bool multiline, bool is_one_byte,
501 Zone* zone) { 509 Zone* zone) {
510 V8::Initialize(NULL);
502 Isolate* isolate = CcTest::i_isolate(); 511 Isolate* isolate = CcTest::i_isolate();
503 FlatStringReader reader(isolate, CStrVector(input)); 512 FlatStringReader reader(isolate, CStrVector(input));
504 RegExpCompileData compile_data; 513 RegExpCompileData compile_data;
505 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, 514 if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline,
506 &compile_data, zone)) 515 &compile_data, zone))
507 return NULL; 516 return NULL;
508 Handle<String> pattern = isolate->factory()-> 517 Handle<String> pattern = isolate->factory()->
509 NewStringFromUtf8(CStrVector(input)).ToHandleChecked(); 518 NewStringFromUtf8(CStrVector(input)).ToHandleChecked();
510 Handle<String> sample_subject = 519 Handle<String> sample_subject =
511 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); 520 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 557
549 const int TestConfig::kNoKey = 0; 558 const int TestConfig::kNoKey = 0;
550 559
551 560
552 static unsigned PseudoRandom(int i, int j) { 561 static unsigned PseudoRandom(int i, int j) {
553 return ~(~((i * 781) ^ (j * 329))); 562 return ~(~((i * 781) ^ (j * 329)));
554 } 563 }
555 564
556 565
557 TEST(SplayTreeSimple) { 566 TEST(SplayTreeSimple) {
567 v8::internal::V8::Initialize(NULL);
558 static const unsigned kLimit = 1000; 568 static const unsigned kLimit = 1000;
559 Zone zone(CcTest::i_isolate()); 569 Zone zone(CcTest::i_isolate());
560 ZoneSplayTree<TestConfig> tree(&zone); 570 ZoneSplayTree<TestConfig> tree(&zone);
561 bool seen[kLimit]; 571 bool seen[kLimit];
562 for (unsigned i = 0; i < kLimit; i++) seen[i] = false; 572 for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
563 #define CHECK_MAPS_EQUAL() do { \ 573 #define CHECK_MAPS_EQUAL() do { \
564 for (unsigned k = 0; k < kLimit; k++) \ 574 for (unsigned k = 0; k < kLimit; k++) \
565 CHECK_EQ(seen[k], tree.Find(k, &loc)); \ 575 CHECK_EQ(seen[k], tree.Find(k, &loc)); \
566 } while (false) 576 } while (false)
567 for (int i = 0; i < 50; i++) { 577 for (int i = 0; i < 50; i++) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 CHECK(tree.FindLeastGreaterThan(val, &loc)); 610 CHECK(tree.FindLeastGreaterThan(val, &loc));
601 CHECK_EQ(loc.key(), val); 611 CHECK_EQ(loc.key(), val);
602 break; 612 break;
603 } 613 }
604 } 614 }
605 } 615 }
606 } 616 }
607 617
608 618
609 TEST(DispatchTableConstruction) { 619 TEST(DispatchTableConstruction) {
620 v8::internal::V8::Initialize(NULL);
610 // Initialize test data. 621 // Initialize test data.
611 static const int kLimit = 1000; 622 static const int kLimit = 1000;
612 static const int kRangeCount = 8; 623 static const int kRangeCount = 8;
613 static const int kRangeSize = 16; 624 static const int kRangeSize = 16;
614 uc16 ranges[kRangeCount][2 * kRangeSize]; 625 uc16 ranges[kRangeCount][2 * kRangeSize];
615 for (int i = 0; i < kRangeCount; i++) { 626 for (int i = 0; i < kRangeCount; i++) {
616 Vector<uc16> range(ranges[i], 2 * kRangeSize); 627 Vector<uc16> range(ranges[i], 2 * kRangeSize);
617 for (int j = 0; j < 2 * kRangeSize; j++) { 628 for (int j = 0; j < 2 * kRangeSize; j++) {
618 range[j] = PseudoRandom(i + 25, j + 87) % kLimit; 629 range[j] = PseudoRandom(i + 25, j + 87) % kLimit;
619 } 630 }
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); 1355 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result);
1345 CHECK_EQ(0, captures[0]); 1356 CHECK_EQ(0, captures[0]);
1346 CHECK_EQ(42, captures[1]); 1357 CHECK_EQ(42, captures[1]);
1347 1358
1348 isolate->clear_pending_exception(); 1359 isolate->clear_pending_exception();
1349 } 1360 }
1350 1361
1351 #else // V8_INTERPRETED_REGEXP 1362 #else // V8_INTERPRETED_REGEXP
1352 1363
1353 TEST(MacroAssembler) { 1364 TEST(MacroAssembler) {
1365 V8::Initialize(NULL);
1354 byte codes[1024]; 1366 byte codes[1024];
1355 Zone zone(CcTest::i_isolate()); 1367 Zone zone(CcTest::i_isolate());
1356 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone); 1368 RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone);
1357 // ^f(o)o. 1369 // ^f(o)o.
1358 Label start, fail, backtrack; 1370 Label start, fail, backtrack;
1359 1371
1360 m.SetRegister(4, 42); 1372 m.SetRegister(4, 42);
1361 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck); 1373 m.PushRegister(4, RegExpMacroAssembler::kNoStackLimitCheck);
1362 m.AdvanceRegister(4, 42); 1374 m.AdvanceRegister(4, 42);
1363 m.GoTo(&start); 1375 m.GoTo(&start);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 Vector<const uc16>(str2, 6)).ToHandleChecked(); 1421 Vector<const uc16>(str2, 6)).ToHandleChecked();
1410 1422
1411 CHECK(!IrregexpInterpreter::Match(isolate, array, f2_16, captures, 0)); 1423 CHECK(!IrregexpInterpreter::Match(isolate, array, f2_16, captures, 0));
1412 CHECK_EQ(42, captures[0]); 1424 CHECK_EQ(42, captures[0]);
1413 } 1425 }
1414 1426
1415 #endif // V8_INTERPRETED_REGEXP 1427 #endif // V8_INTERPRETED_REGEXP
1416 1428
1417 1429
1418 TEST(AddInverseToTable) { 1430 TEST(AddInverseToTable) {
1431 v8::internal::V8::Initialize(NULL);
1419 static const int kLimit = 1000; 1432 static const int kLimit = 1000;
1420 static const int kRangeCount = 16; 1433 static const int kRangeCount = 16;
1421 for (int t = 0; t < 10; t++) { 1434 for (int t = 0; t < 10; t++) {
1422 Zone zone(CcTest::i_isolate()); 1435 Zone zone(CcTest::i_isolate());
1423 ZoneList<CharacterRange>* ranges = 1436 ZoneList<CharacterRange>* ranges =
1424 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone); 1437 new(&zone) ZoneList<CharacterRange>(kRangeCount, &zone);
1425 for (int i = 0; i < kRangeCount; i++) { 1438 for (int i = 0; i < kRangeCount; i++) {
1426 int from = PseudoRandom(t + 87, i + 25) % kLimit; 1439 int from = PseudoRandom(t + 87, i + 25) % kLimit;
1427 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20)); 1440 int to = from + (PseudoRandom(i + 87, t + 25) % (kLimit / 20));
1428 if (to > kLimit) to = kLimit; 1441 if (to > kLimit) to = kLimit;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 1581
1569 static void TestSimpleRangeCaseIndependence(CharacterRange input, 1582 static void TestSimpleRangeCaseIndependence(CharacterRange input,
1570 CharacterRange expected) { 1583 CharacterRange expected) {
1571 EmbeddedVector<CharacterRange, 1> vector; 1584 EmbeddedVector<CharacterRange, 1> vector;
1572 vector[0] = expected; 1585 vector[0] = expected;
1573 TestRangeCaseIndependence(input, vector); 1586 TestRangeCaseIndependence(input, vector);
1574 } 1587 }
1575 1588
1576 1589
1577 TEST(CharacterRangeCaseIndependence) { 1590 TEST(CharacterRangeCaseIndependence) {
1591 v8::internal::V8::Initialize(NULL);
1578 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('a'), 1592 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('a'),
1579 CharacterRange::Singleton('A')); 1593 CharacterRange::Singleton('A'));
1580 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('z'), 1594 TestSimpleRangeCaseIndependence(CharacterRange::Singleton('z'),
1581 CharacterRange::Singleton('Z')); 1595 CharacterRange::Singleton('Z'));
1582 TestSimpleRangeCaseIndependence(CharacterRange('a', 'z'), 1596 TestSimpleRangeCaseIndependence(CharacterRange('a', 'z'),
1583 CharacterRange('A', 'Z')); 1597 CharacterRange('A', 'Z'));
1584 TestSimpleRangeCaseIndependence(CharacterRange('c', 'f'), 1598 TestSimpleRangeCaseIndependence(CharacterRange('c', 'f'),
1585 CharacterRange('C', 'F')); 1599 CharacterRange('C', 'F'));
1586 TestSimpleRangeCaseIndependence(CharacterRange('a', 'b'), 1600 TestSimpleRangeCaseIndependence(CharacterRange('a', 'b'),
1587 CharacterRange('A', 'B')); 1601 CharacterRange('A', 'B'));
(...skipping 21 matching lines...) Expand all
1609 for (int i = 0; i < ranges->length(); i++) { 1623 for (int i = 0; i < ranges->length(); i++) {
1610 CharacterRange range = ranges->at(i); 1624 CharacterRange range = ranges->at(i);
1611 if (range.from() <= c && c <= range.to()) 1625 if (range.from() <= c && c <= range.to())
1612 return true; 1626 return true;
1613 } 1627 }
1614 return false; 1628 return false;
1615 } 1629 }
1616 1630
1617 1631
1618 TEST(CharClassDifference) { 1632 TEST(CharClassDifference) {
1633 v8::internal::V8::Initialize(NULL);
1619 Zone zone(CcTest::i_isolate()); 1634 Zone zone(CcTest::i_isolate());
1620 ZoneList<CharacterRange>* base = 1635 ZoneList<CharacterRange>* base =
1621 new(&zone) ZoneList<CharacterRange>(1, &zone); 1636 new(&zone) ZoneList<CharacterRange>(1, &zone);
1622 base->Add(CharacterRange::Everything(), &zone); 1637 base->Add(CharacterRange::Everything(), &zone);
1623 Vector<const int> overlay = CharacterRange::GetWordBounds(); 1638 Vector<const int> overlay = CharacterRange::GetWordBounds();
1624 ZoneList<CharacterRange>* included = NULL; 1639 ZoneList<CharacterRange>* included = NULL;
1625 ZoneList<CharacterRange>* excluded = NULL; 1640 ZoneList<CharacterRange>* excluded = NULL;
1626 CharacterRange::Split(base, overlay, &included, &excluded, &zone); 1641 CharacterRange::Split(base, overlay, &included, &excluded, &zone);
1627 for (int i = 0; i < (1 << 16); i++) { 1642 for (int i = 0; i < (1 << 16); i++) {
1628 bool in_base = InClass(i, base); 1643 bool in_base = InClass(i, base);
1629 if (in_base) { 1644 if (in_base) {
1630 bool in_overlay = false; 1645 bool in_overlay = false;
1631 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { 1646 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) {
1632 if (overlay[j] <= i && i < overlay[j+1]) 1647 if (overlay[j] <= i && i < overlay[j+1])
1633 in_overlay = true; 1648 in_overlay = true;
1634 } 1649 }
1635 CHECK_EQ(in_overlay, InClass(i, included)); 1650 CHECK_EQ(in_overlay, InClass(i, included));
1636 CHECK_EQ(!in_overlay, InClass(i, excluded)); 1651 CHECK_EQ(!in_overlay, InClass(i, excluded));
1637 } else { 1652 } else {
1638 CHECK(!InClass(i, included)); 1653 CHECK(!InClass(i, included));
1639 CHECK(!InClass(i, excluded)); 1654 CHECK(!InClass(i, excluded));
1640 } 1655 }
1641 } 1656 }
1642 } 1657 }
1643 1658
1644 1659
1645 TEST(CanonicalizeCharacterSets) { 1660 TEST(CanonicalizeCharacterSets) {
1661 v8::internal::V8::Initialize(NULL);
1646 Zone zone(CcTest::i_isolate()); 1662 Zone zone(CcTest::i_isolate());
1647 ZoneList<CharacterRange>* list = 1663 ZoneList<CharacterRange>* list =
1648 new(&zone) ZoneList<CharacterRange>(4, &zone); 1664 new(&zone) ZoneList<CharacterRange>(4, &zone);
1649 CharacterSet set(list); 1665 CharacterSet set(list);
1650 1666
1651 list->Add(CharacterRange(10, 20), &zone); 1667 list->Add(CharacterRange(10, 20), &zone);
1652 list->Add(CharacterRange(30, 40), &zone); 1668 list->Add(CharacterRange(30, 40), &zone);
1653 list->Add(CharacterRange(50, 60), &zone); 1669 list->Add(CharacterRange(50, 60), &zone);
1654 set.Canonicalize(); 1670 set.Canonicalize();
1655 DCHECK_EQ(3, list->length()); 1671 DCHECK_EQ(3, list->length());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 list->Add(CharacterRange(21, 30), &zone); 1713 list->Add(CharacterRange(21, 30), &zone);
1698 list->Add(CharacterRange(20, 20), &zone); 1714 list->Add(CharacterRange(20, 20), &zone);
1699 set.Canonicalize(); 1715 set.Canonicalize();
1700 DCHECK_EQ(1, list->length()); 1716 DCHECK_EQ(1, list->length());
1701 DCHECK_EQ(10, list->at(0).from()); 1717 DCHECK_EQ(10, list->at(0).from());
1702 DCHECK_EQ(30, list->at(0).to()); 1718 DCHECK_EQ(30, list->at(0).to());
1703 } 1719 }
1704 1720
1705 1721
1706 TEST(CharacterRangeMerge) { 1722 TEST(CharacterRangeMerge) {
1723 v8::internal::V8::Initialize(NULL);
1707 Zone zone(CcTest::i_isolate()); 1724 Zone zone(CcTest::i_isolate());
1708 ZoneList<CharacterRange> l1(4, &zone); 1725 ZoneList<CharacterRange> l1(4, &zone);
1709 ZoneList<CharacterRange> l2(4, &zone); 1726 ZoneList<CharacterRange> l2(4, &zone);
1710 // Create all combinations of intersections of ranges, both singletons and 1727 // Create all combinations of intersections of ranges, both singletons and
1711 // longer. 1728 // longer.
1712 1729
1713 int offset = 0; 1730 int offset = 0;
1714 1731
1715 // The five kinds of singleton intersections: 1732 // The five kinds of singleton intersections:
1716 // X 1733 // X
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 DCHECK(CharacterRange::IsCanonical(&l1)); 1801 DCHECK(CharacterRange::IsCanonical(&l1));
1785 DCHECK(CharacterRange::IsCanonical(&l2)); 1802 DCHECK(CharacterRange::IsCanonical(&l2));
1786 1803
1787 ZoneList<CharacterRange> first_only(4, &zone); 1804 ZoneList<CharacterRange> first_only(4, &zone);
1788 ZoneList<CharacterRange> second_only(4, &zone); 1805 ZoneList<CharacterRange> second_only(4, &zone);
1789 ZoneList<CharacterRange> both(4, &zone); 1806 ZoneList<CharacterRange> both(4, &zone);
1790 } 1807 }
1791 1808
1792 1809
1793 TEST(Graph) { 1810 TEST(Graph) {
1811 V8::Initialize(NULL);
1794 Execute("\\b\\w+\\b", false, true, true); 1812 Execute("\\b\\w+\\b", false, true, true);
1795 } 1813 }
OLDNEW
« no previous file with comments | « test/cctest/test-random-number-generator.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698