OLD | NEW |
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 using namespace v8::internal; | 90 using namespace v8::internal; |
91 | 91 |
92 | 92 |
93 static bool CheckParse(const char* input) { | 93 static bool CheckParse(const char* input) { |
94 v8::HandleScope scope(CcTest::isolate()); | 94 v8::HandleScope scope(CcTest::isolate()); |
95 Zone zone; | 95 Zone zone; |
96 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 96 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
97 RegExpCompileData result; | 97 RegExpCompileData result; |
98 return v8::internal::RegExpParser::ParseRegExp( | 98 return v8::internal::RegExpParser::ParseRegExp( |
99 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result); | 99 CcTest::i_isolate(), &zone, &reader, false, false, &result); |
100 } | 100 } |
101 | 101 |
102 | 102 |
103 static void CheckParseEq(const char* input, const char* expected, | 103 static void CheckParseEq(const char* input, const char* expected, |
104 bool unicode = false) { | 104 bool unicode = false) { |
105 v8::HandleScope scope(CcTest::isolate()); | 105 v8::HandleScope scope(CcTest::isolate()); |
106 Zone zone; | 106 Zone zone; |
107 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 107 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
108 RegExpCompileData result; | 108 RegExpCompileData result; |
109 JSRegExp::Flags flags = JSRegExp::kNone; | 109 CHECK(v8::internal::RegExpParser::ParseRegExp( |
110 if (unicode) flags |= JSRegExp::kUnicode; | 110 CcTest::i_isolate(), &zone, &reader, false, unicode, &result)); |
111 CHECK(v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), &zone, | |
112 &reader, flags, &result)); | |
113 CHECK(result.tree != NULL); | 111 CHECK(result.tree != NULL); |
114 CHECK(result.error.is_null()); | 112 CHECK(result.error.is_null()); |
115 std::ostringstream os; | 113 std::ostringstream os; |
116 result.tree->Print(os, &zone); | 114 result.tree->Print(os, &zone); |
117 if (strcmp(expected, os.str().c_str()) != 0) { | 115 if (strcmp(expected, os.str().c_str()) != 0) { |
118 printf("%s | %s\n", expected, os.str().c_str()); | 116 printf("%s | %s\n", expected, os.str().c_str()); |
119 } | 117 } |
120 CHECK_EQ(0, strcmp(expected, os.str().c_str())); | 118 CHECK_EQ(0, strcmp(expected, os.str().c_str())); |
121 } | 119 } |
122 | 120 |
123 | 121 |
124 static bool CheckSimple(const char* input) { | 122 static bool CheckSimple(const char* input) { |
125 v8::HandleScope scope(CcTest::isolate()); | 123 v8::HandleScope scope(CcTest::isolate()); |
126 Zone zone; | 124 Zone zone; |
127 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 125 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
128 RegExpCompileData result; | 126 RegExpCompileData result; |
129 CHECK(v8::internal::RegExpParser::ParseRegExp( | 127 CHECK(v8::internal::RegExpParser::ParseRegExp( |
130 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 128 CcTest::i_isolate(), &zone, &reader, false, false, &result)); |
131 CHECK(result.tree != NULL); | 129 CHECK(result.tree != NULL); |
132 CHECK(result.error.is_null()); | 130 CHECK(result.error.is_null()); |
133 return result.simple; | 131 return result.simple; |
134 } | 132 } |
135 | 133 |
136 struct MinMaxPair { | 134 struct MinMaxPair { |
137 int min_match; | 135 int min_match; |
138 int max_match; | 136 int max_match; |
139 }; | 137 }; |
140 | 138 |
141 | 139 |
142 static MinMaxPair CheckMinMaxMatch(const char* input) { | 140 static MinMaxPair CheckMinMaxMatch(const char* input) { |
143 v8::HandleScope scope(CcTest::isolate()); | 141 v8::HandleScope scope(CcTest::isolate()); |
144 Zone zone; | 142 Zone zone; |
145 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 143 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
146 RegExpCompileData result; | 144 RegExpCompileData result; |
147 CHECK(v8::internal::RegExpParser::ParseRegExp( | 145 CHECK(v8::internal::RegExpParser::ParseRegExp( |
148 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 146 CcTest::i_isolate(), &zone, &reader, false, false, &result)); |
149 CHECK(result.tree != NULL); | 147 CHECK(result.tree != NULL); |
150 CHECK(result.error.is_null()); | 148 CHECK(result.error.is_null()); |
151 int min_match = result.tree->min_match(); | 149 int min_match = result.tree->min_match(); |
152 int max_match = result.tree->max_match(); | 150 int max_match = result.tree->max_match(); |
153 MinMaxPair pair = { min_match, max_match }; | 151 MinMaxPair pair = { min_match, max_match }; |
154 return pair; | 152 return pair; |
155 } | 153 } |
156 | 154 |
157 | 155 |
158 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) | 156 #define CHECK_PARSE_ERROR(input) CHECK(!CheckParse(input)) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')"); | 199 CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')"); |
202 if (lookbehind) { | 200 if (lookbehind) { |
203 CheckParseEq("foo(?<=bar)baz", "(: 'foo' (<- + 'bar') 'baz')"); | 201 CheckParseEq("foo(?<=bar)baz", "(: 'foo' (<- + 'bar') 'baz')"); |
204 CheckParseEq("foo(?<!bar)baz", "(: 'foo' (<- - 'bar') 'baz')"); | 202 CheckParseEq("foo(?<!bar)baz", "(: 'foo' (<- - 'bar') 'baz')"); |
205 } else { | 203 } else { |
206 CHECK_PARSE_ERROR("foo(?<=bar)baz"); | 204 CHECK_PARSE_ERROR("foo(?<=bar)baz"); |
207 CHECK_PARSE_ERROR("foo(?<!bar)baz"); | 205 CHECK_PARSE_ERROR("foo(?<!bar)baz"); |
208 } | 206 } |
209 CheckParseEq("()", "(^ %)"); | 207 CheckParseEq("()", "(^ %)"); |
210 CheckParseEq("(?=)", "(-> + %)"); | 208 CheckParseEq("(?=)", "(-> + %)"); |
211 CheckParseEq("[]", "^[\\x00-\\u{10ffff}]"); // Doesn't compile on windows | 209 CheckParseEq("[]", "^[\\x00-\\uffff]"); // Doesn't compile on windows |
212 CheckParseEq("[^]", "[\\x00-\\u{10ffff}]"); // \uffff isn't in codepage 1252 | 210 CheckParseEq("[^]", "[\\x00-\\uffff]"); // \uffff isn't in codepage 1252 |
213 CheckParseEq("[x]", "[x]"); | 211 CheckParseEq("[x]", "[x]"); |
214 CheckParseEq("[xyz]", "[x y z]"); | 212 CheckParseEq("[xyz]", "[x y z]"); |
215 CheckParseEq("[a-zA-Z0-9]", "[a-z A-Z 0-9]"); | 213 CheckParseEq("[a-zA-Z0-9]", "[a-z A-Z 0-9]"); |
216 CheckParseEq("[-123]", "[- 1 2 3]"); | 214 CheckParseEq("[-123]", "[- 1 2 3]"); |
217 CheckParseEq("[^123]", "^[1 2 3]"); | 215 CheckParseEq("[^123]", "^[1 2 3]"); |
218 CheckParseEq("]", "']'"); | 216 CheckParseEq("]", "']'"); |
219 CheckParseEq("}", "'}'"); | 217 CheckParseEq("}", "'}'"); |
220 CheckParseEq("[a-b-c]", "[a-b - c]"); | 218 CheckParseEq("[a-b-c]", "[a-b - c]"); |
221 CheckParseEq("[\\d]", "[0-9]"); | 219 CheckParseEq("[\\d]", "[0-9]"); |
222 CheckParseEq("[x\\dz]", "[x 0-9 z]"); | 220 CheckParseEq("[x\\dz]", "[x 0-9 z]"); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 309 |
312 // Unicode regexps | 310 // Unicode regexps |
313 CheckParseEq("\\u{12345}", "'\\ud808\\udf45'", true); | 311 CheckParseEq("\\u{12345}", "'\\ud808\\udf45'", true); |
314 CheckParseEq("\\u{12345}\\u{23456}", "(! '\\ud808\\udf45' '\\ud84d\\udc56')", | 312 CheckParseEq("\\u{12345}\\u{23456}", "(! '\\ud808\\udf45' '\\ud84d\\udc56')", |
315 true); | 313 true); |
316 CheckParseEq("\\u{12345}|\\u{23456}", "(| '\\ud808\\udf45' '\\ud84d\\udc56')", | 314 CheckParseEq("\\u{12345}|\\u{23456}", "(| '\\ud808\\udf45' '\\ud84d\\udc56')", |
317 true); | 315 true); |
318 CheckParseEq("\\u{12345}{3}", "(# 3 3 g '\\ud808\\udf45')", true); | 316 CheckParseEq("\\u{12345}{3}", "(# 3 3 g '\\ud808\\udf45')", true); |
319 CheckParseEq("\\u{12345}*", "(# 0 - g '\\ud808\\udf45')", true); | 317 CheckParseEq("\\u{12345}*", "(# 0 - g '\\ud808\\udf45')", true); |
320 | 318 |
321 CheckParseEq("\\ud808\\udf45*", "(# 0 - g '\\ud808\\udf45')", true); | |
322 CheckParseEq("[\\ud808\\udf45-\\ud809\\udccc]", "[\\u{012345}-\\u{0124cc}]", | |
323 true); | |
324 | |
325 CHECK_SIMPLE("", false); | 319 CHECK_SIMPLE("", false); |
326 CHECK_SIMPLE("a", true); | 320 CHECK_SIMPLE("a", true); |
327 CHECK_SIMPLE("a|b", false); | 321 CHECK_SIMPLE("a|b", false); |
328 CHECK_SIMPLE("a\\n", false); | 322 CHECK_SIMPLE("a\\n", false); |
329 CHECK_SIMPLE("^a", false); | 323 CHECK_SIMPLE("^a", false); |
330 CHECK_SIMPLE("a$", false); | 324 CHECK_SIMPLE("a$", false); |
331 CHECK_SIMPLE("a\\b!", false); | 325 CHECK_SIMPLE("a\\b!", false); |
332 CHECK_SIMPLE("a\\Bb", false); | 326 CHECK_SIMPLE("a\\Bb", false); |
333 CHECK_SIMPLE("a*", false); | 327 CHECK_SIMPLE("a*", false); |
334 CHECK_SIMPLE("a*?", false); | 328 CHECK_SIMPLE("a*?", false); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 CheckParseEq("a|", "(| 'a' %)"); | 447 CheckParseEq("a|", "(| 'a' %)"); |
454 } | 448 } |
455 | 449 |
456 static void ExpectError(const char* input, | 450 static void ExpectError(const char* input, |
457 const char* expected) { | 451 const char* expected) { |
458 v8::HandleScope scope(CcTest::isolate()); | 452 v8::HandleScope scope(CcTest::isolate()); |
459 Zone zone; | 453 Zone zone; |
460 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 454 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
461 RegExpCompileData result; | 455 RegExpCompileData result; |
462 CHECK(!v8::internal::RegExpParser::ParseRegExp( | 456 CHECK(!v8::internal::RegExpParser::ParseRegExp( |
463 CcTest::i_isolate(), &zone, &reader, JSRegExp::kNone, &result)); | 457 CcTest::i_isolate(), &zone, &reader, false, false, &result)); |
464 CHECK(result.tree == NULL); | 458 CHECK(result.tree == NULL); |
465 CHECK(!result.error.is_null()); | 459 CHECK(!result.error.is_null()); |
466 v8::base::SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); | 460 v8::base::SmartArrayPointer<char> str = result.error->ToCString(ALLOW_NULLS); |
467 CHECK_EQ(0, strcmp(expected, str.get())); | 461 CHECK_EQ(0, strcmp(expected, str.get())); |
468 } | 462 } |
469 | 463 |
470 | 464 |
471 TEST(Errors) { | 465 TEST(Errors) { |
472 const char* kEndBackslash = "\\ at end of pattern"; | 466 const char* kEndBackslash = "\\ at end of pattern"; |
473 ExpectError("\\", kEndBackslash); | 467 ExpectError("\\", kEndBackslash); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 static bool NotWord(uc16 c) { | 516 static bool NotWord(uc16 c) { |
523 return !IsRegExpWord(c); | 517 return !IsRegExpWord(c); |
524 } | 518 } |
525 | 519 |
526 | 520 |
527 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { | 521 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { |
528 Zone zone; | 522 Zone zone; |
529 ZoneList<CharacterRange>* ranges = | 523 ZoneList<CharacterRange>* ranges = |
530 new(&zone) ZoneList<CharacterRange>(2, &zone); | 524 new(&zone) ZoneList<CharacterRange>(2, &zone); |
531 CharacterRange::AddClassEscape(c, ranges, &zone); | 525 CharacterRange::AddClassEscape(c, ranges, &zone); |
532 for (uc32 i = 0; i < (1 << 16); i++) { | 526 for (unsigned i = 0; i < (1 << 16); i++) { |
533 bool in_class = false; | 527 bool in_class = false; |
534 for (int j = 0; !in_class && j < ranges->length(); j++) { | 528 for (int j = 0; !in_class && j < ranges->length(); j++) { |
535 CharacterRange& range = ranges->at(j); | 529 CharacterRange& range = ranges->at(j); |
536 in_class = (range.from() <= i && i <= range.to()); | 530 in_class = (range.from() <= i && i <= range.to()); |
537 } | 531 } |
538 CHECK_EQ(pred(i), in_class); | 532 CHECK_EQ(pred(i), in_class); |
539 } | 533 } |
540 } | 534 } |
541 | 535 |
542 | 536 |
543 TEST(CharacterClassEscapes) { | 537 TEST(CharacterClassEscapes) { |
544 TestCharacterClassEscapes('.', IsRegExpNewline); | 538 TestCharacterClassEscapes('.', IsRegExpNewline); |
545 TestCharacterClassEscapes('d', IsDigit); | 539 TestCharacterClassEscapes('d', IsDigit); |
546 TestCharacterClassEscapes('D', NotDigit); | 540 TestCharacterClassEscapes('D', NotDigit); |
547 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator); | 541 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator); |
548 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor); | 542 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor); |
549 TestCharacterClassEscapes('w', IsRegExpWord); | 543 TestCharacterClassEscapes('w', IsRegExpWord); |
550 TestCharacterClassEscapes('W', NotWord); | 544 TestCharacterClassEscapes('W', NotWord); |
551 } | 545 } |
552 | 546 |
553 | 547 |
554 static RegExpNode* Compile(const char* input, bool multiline, bool unicode, | 548 static RegExpNode* Compile(const char* input, bool multiline, bool unicode, |
555 bool is_one_byte, Zone* zone) { | 549 bool is_one_byte, Zone* zone) { |
556 Isolate* isolate = CcTest::i_isolate(); | 550 Isolate* isolate = CcTest::i_isolate(); |
557 FlatStringReader reader(isolate, CStrVector(input)); | 551 FlatStringReader reader(isolate, CStrVector(input)); |
558 RegExpCompileData compile_data; | 552 RegExpCompileData compile_data; |
559 JSRegExp::Flags flags = JSRegExp::kNone; | |
560 if (multiline) flags = JSRegExp::kMultiline; | |
561 if (unicode) flags = JSRegExp::kUnicode; | |
562 if (!v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), zone, | 553 if (!v8::internal::RegExpParser::ParseRegExp(CcTest::i_isolate(), zone, |
563 &reader, flags, &compile_data)) | 554 &reader, multiline, unicode, |
| 555 &compile_data)) |
564 return NULL; | 556 return NULL; |
565 Handle<String> pattern = isolate->factory() | 557 Handle<String> pattern = isolate->factory() |
566 ->NewStringFromUtf8(CStrVector(input)) | 558 ->NewStringFromUtf8(CStrVector(input)) |
567 .ToHandleChecked(); | 559 .ToHandleChecked(); |
568 Handle<String> sample_subject = | 560 Handle<String> sample_subject = |
569 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); | 561 isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); |
570 RegExpEngine::Compile(isolate, zone, &compile_data, flags, pattern, | 562 RegExpEngine::Compile(isolate, zone, &compile_data, false, false, multiline, |
571 sample_subject, is_one_byte); | 563 false, pattern, sample_subject, is_one_byte); |
572 return compile_data.node; | 564 return compile_data.node; |
573 } | 565 } |
574 | 566 |
575 | 567 |
576 static void Execute(const char* input, bool multiline, bool unicode, | 568 static void Execute(const char* input, bool multiline, bool unicode, |
577 bool is_one_byte, bool dot_output = false) { | 569 bool is_one_byte, bool dot_output = false) { |
578 v8::HandleScope scope(CcTest::isolate()); | 570 v8::HandleScope scope(CcTest::isolate()); |
579 Zone zone; | 571 Zone zone; |
580 RegExpNode* node = Compile(input, multiline, unicode, is_one_byte, &zone); | 572 RegExpNode* node = Compile(input, multiline, unicode, is_one_byte, &zone); |
581 USE(node); | 573 USE(node); |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 TestSimpleRangeCaseIndependence(isolate, CharacterRange('A' - 1, 'Z' + 1), | 1662 TestSimpleRangeCaseIndependence(isolate, CharacterRange('A' - 1, 'Z' + 1), |
1671 CharacterRange('a', 'z')); | 1663 CharacterRange('a', 'z')); |
1672 // Here we need to add [l-z] to complete the case independence of | 1664 // Here we need to add [l-z] to complete the case independence of |
1673 // [A-Za-z] but we expect [a-z] to be added since we always add a | 1665 // [A-Za-z] but we expect [a-z] to be added since we always add a |
1674 // whole block at a time. | 1666 // whole block at a time. |
1675 TestSimpleRangeCaseIndependence(isolate, CharacterRange('A', 'k'), | 1667 TestSimpleRangeCaseIndependence(isolate, CharacterRange('A', 'k'), |
1676 CharacterRange('a', 'z')); | 1668 CharacterRange('a', 'z')); |
1677 } | 1669 } |
1678 | 1670 |
1679 | 1671 |
1680 static bool InClass(uc32 c, ZoneList<CharacterRange>* ranges) { | 1672 static bool InClass(uc16 c, ZoneList<CharacterRange>* ranges) { |
1681 if (ranges == NULL) | 1673 if (ranges == NULL) |
1682 return false; | 1674 return false; |
1683 for (int i = 0; i < ranges->length(); i++) { | 1675 for (int i = 0; i < ranges->length(); i++) { |
1684 CharacterRange range = ranges->at(i); | 1676 CharacterRange range = ranges->at(i); |
1685 if (range.from() <= c && c <= range.to()) | 1677 if (range.from() <= c && c <= range.to()) |
1686 return true; | 1678 return true; |
1687 } | 1679 } |
1688 return false; | 1680 return false; |
1689 } | 1681 } |
1690 | 1682 |
1691 | 1683 |
1692 TEST(UnicodeRangeSplitter) { | 1684 TEST(CharClassDifference) { |
1693 Zone zone; | 1685 Zone zone; |
1694 ZoneList<CharacterRange>* base = | 1686 ZoneList<CharacterRange>* base = |
1695 new(&zone) ZoneList<CharacterRange>(1, &zone); | 1687 new(&zone) ZoneList<CharacterRange>(1, &zone); |
1696 base->Add(CharacterRange::Everything(), &zone); | 1688 base->Add(CharacterRange::Everything(), &zone); |
1697 UnicodeRangeSplitter splitter(&zone, base); | 1689 Vector<const int> overlay = CharacterRange::GetWordBounds(); |
1698 // BMP | 1690 ZoneList<CharacterRange>* included = NULL; |
1699 for (uc32 c = 0; c < 0xd800; c++) { | 1691 ZoneList<CharacterRange>* excluded = NULL; |
1700 CHECK(InClass(c, splitter.bmp())); | 1692 CharacterRange::Split(base, overlay, &included, &excluded, &zone); |
1701 CHECK(!InClass(c, splitter.lead_surrogates())); | 1693 for (int i = 0; i < (1 << 16); i++) { |
1702 CHECK(!InClass(c, splitter.trail_surrogates())); | 1694 bool in_base = InClass(i, base); |
1703 CHECK(!InClass(c, splitter.non_bmp())); | 1695 if (in_base) { |
1704 } | 1696 bool in_overlay = false; |
1705 // Lead surrogates | 1697 for (int j = 0; !in_overlay && j < overlay.length(); j += 2) { |
1706 for (uc32 c = 0xd800; c < 0xdbff; c++) { | 1698 if (overlay[j] <= i && i < overlay[j+1]) |
1707 CHECK(!InClass(c, splitter.bmp())); | 1699 in_overlay = true; |
1708 CHECK(InClass(c, splitter.lead_surrogates())); | 1700 } |
1709 CHECK(!InClass(c, splitter.trail_surrogates())); | 1701 CHECK_EQ(in_overlay, InClass(i, included)); |
1710 CHECK(!InClass(c, splitter.non_bmp())); | 1702 CHECK_EQ(!in_overlay, InClass(i, excluded)); |
1711 } | 1703 } else { |
1712 // Trail surrogates | 1704 CHECK(!InClass(i, included)); |
1713 for (uc32 c = 0xdc00; c < 0xdfff; c++) { | 1705 CHECK(!InClass(i, excluded)); |
1714 CHECK(!InClass(c, splitter.bmp())); | 1706 } |
1715 CHECK(!InClass(c, splitter.lead_surrogates())); | |
1716 CHECK(InClass(c, splitter.trail_surrogates())); | |
1717 CHECK(!InClass(c, splitter.non_bmp())); | |
1718 } | |
1719 // BMP | |
1720 for (uc32 c = 0xe000; c < 0xffff; c++) { | |
1721 CHECK(InClass(c, splitter.bmp())); | |
1722 CHECK(!InClass(c, splitter.lead_surrogates())); | |
1723 CHECK(!InClass(c, splitter.trail_surrogates())); | |
1724 CHECK(!InClass(c, splitter.non_bmp())); | |
1725 } | |
1726 // Non-BMP | |
1727 for (uc32 c = 0x10000; c < 0x10ffff; c++) { | |
1728 CHECK(!InClass(c, splitter.bmp())); | |
1729 CHECK(!InClass(c, splitter.lead_surrogates())); | |
1730 CHECK(!InClass(c, splitter.trail_surrogates())); | |
1731 CHECK(InClass(c, splitter.non_bmp())); | |
1732 } | 1707 } |
1733 } | 1708 } |
1734 | 1709 |
1735 | 1710 |
1736 TEST(CanonicalizeCharacterSets) { | 1711 TEST(CanonicalizeCharacterSets) { |
1737 Zone zone; | 1712 Zone zone; |
1738 ZoneList<CharacterRange>* list = | 1713 ZoneList<CharacterRange>* list = |
1739 new(&zone) ZoneList<CharacterRange>(4, &zone); | 1714 new(&zone) ZoneList<CharacterRange>(4, &zone); |
1740 CharacterSet set(list); | 1715 CharacterSet set(list); |
1741 | 1716 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 // .toString() throws on non-RegExps that aren't RegExp.prototype | 1931 // .toString() throws on non-RegExps that aren't RegExp.prototype |
1957 v8::Local<v8::Value> resultToStringError = CompileRun( | 1932 v8::Local<v8::Value> resultToStringError = CompileRun( |
1958 "var exception;" | 1933 "var exception;" |
1959 "try { RegExp.prototype.toString.call(null) }" | 1934 "try { RegExp.prototype.toString.call(null) }" |
1960 "catch (e) { exception = e; }" | 1935 "catch (e) { exception = e; }" |
1961 "exception"); | 1936 "exception"); |
1962 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); | 1937 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeStickyGetter]); |
1963 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); | 1938 CHECK_EQ(1, use_counts[v8::Isolate::kRegExpPrototypeToString]); |
1964 CHECK(resultToStringError->IsObject()); | 1939 CHECK(resultToStringError->IsObject()); |
1965 } | 1940 } |
OLD | NEW |