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

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

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

Powered by Google App Engine
This is Rietveld 408576698