| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 FlatStringReader reader(Isolate::Current(), CStrVector(input)); | 87 FlatStringReader reader(Isolate::Current(), CStrVector(input)); |
| 88 RegExpCompileData result; | 88 RegExpCompileData result; |
| 89 CHECK(v8::internal::RegExpParser::ParseRegExp( | 89 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 90 &reader, false, &result, &zone)); | 90 &reader, false, &result, &zone)); |
| 91 CHECK(result.tree != NULL); | 91 CHECK(result.tree != NULL); |
| 92 CHECK(result.error.is_null()); | 92 CHECK(result.error.is_null()); |
| 93 SmartArrayPointer<const char> output = result.tree->ToString(&zone); | 93 SmartArrayPointer<const char> output = result.tree->ToString(&zone); |
| 94 return output; | 94 return output; |
| 95 } | 95 } |
| 96 | 96 |
| 97 |
| 97 static bool CheckSimple(const char* input) { | 98 static bool CheckSimple(const char* input) { |
| 98 V8::Initialize(NULL); | 99 V8::Initialize(NULL); |
| 99 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 100 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 100 Zone zone(Isolate::Current()); | 101 Zone zone(Isolate::Current()); |
| 101 FlatStringReader reader(Isolate::Current(), CStrVector(input)); | 102 FlatStringReader reader(Isolate::Current(), CStrVector(input)); |
| 102 RegExpCompileData result; | 103 RegExpCompileData result; |
| 103 CHECK(v8::internal::RegExpParser::ParseRegExp( | 104 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 104 &reader, false, &result, &zone)); | 105 &reader, false, &result, &zone)); |
| 105 CHECK(result.tree != NULL); | 106 CHECK(result.tree != NULL); |
| 106 CHECK(result.error.is_null()); | 107 CHECK(result.error.is_null()); |
| 107 return result.simple; | 108 return result.simple; |
| 108 } | 109 } |
| 109 | 110 |
| 110 struct MinMaxPair { | 111 struct MinMaxPair { |
| 111 int min_match; | 112 int min_match; |
| 112 int max_match; | 113 int max_match; |
| 113 }; | 114 }; |
| 114 | 115 |
| 116 |
| 115 static MinMaxPair CheckMinMaxMatch(const char* input) { | 117 static MinMaxPair CheckMinMaxMatch(const char* input) { |
| 116 V8::Initialize(NULL); | 118 V8::Initialize(NULL); |
| 117 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 119 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 118 Zone zone(Isolate::Current()); | 120 Zone zone(Isolate::Current()); |
| 119 FlatStringReader reader(Isolate::Current(), CStrVector(input)); | 121 FlatStringReader reader(Isolate::Current(), CStrVector(input)); |
| 120 RegExpCompileData result; | 122 RegExpCompileData result; |
| 121 CHECK(v8::internal::RegExpParser::ParseRegExp( | 123 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 122 &reader, false, &result, &zone)); | 124 &reader, false, &result, &zone)); |
| 123 CHECK(result.tree != NULL); | 125 CHECK(result.tree != NULL); |
| 124 CHECK(result.error.is_null()); | 126 CHECK(result.error.is_null()); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 CHECK_MIN_MAX("(?:ab){4,7}", 8, 14); | 372 CHECK_MIN_MAX("(?:ab){4,7}", 8, 14); |
| 371 CHECK_MIN_MAX("a\\bc", 2, 2); | 373 CHECK_MIN_MAX("a\\bc", 2, 2); |
| 372 CHECK_MIN_MAX("a\\Bc", 2, 2); | 374 CHECK_MIN_MAX("a\\Bc", 2, 2); |
| 373 CHECK_MIN_MAX("a\\sc", 3, 3); | 375 CHECK_MIN_MAX("a\\sc", 3, 3); |
| 374 CHECK_MIN_MAX("a\\Sc", 3, 3); | 376 CHECK_MIN_MAX("a\\Sc", 3, 3); |
| 375 CHECK_MIN_MAX("a(?=b)c", 2, 2); | 377 CHECK_MIN_MAX("a(?=b)c", 2, 2); |
| 376 CHECK_MIN_MAX("a(?=bbb|bb)c", 2, 2); | 378 CHECK_MIN_MAX("a(?=bbb|bb)c", 2, 2); |
| 377 CHECK_MIN_MAX("a(?!bbb|bb)c", 2, 2); | 379 CHECK_MIN_MAX("a(?!bbb|bb)c", 2, 2); |
| 378 } | 380 } |
| 379 | 381 |
| 382 |
| 380 TEST(ParserRegression) { | 383 TEST(ParserRegression) { |
| 381 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); | 384 CHECK_PARSE_EQ("[A-Z$-][x]", "(! [A-Z $ -] [x])"); |
| 382 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); | 385 CHECK_PARSE_EQ("a{3,4*}", "(: 'a{3,' (# 0 - g '4') '}')"); |
| 383 CHECK_PARSE_EQ("{", "'{'"); | 386 CHECK_PARSE_EQ("{", "'{'"); |
| 384 CHECK_PARSE_EQ("a|", "(| 'a' %)"); | 387 CHECK_PARSE_EQ("a|", "(| 'a' %)"); |
| 385 } | 388 } |
| 386 | 389 |
| 387 static void ExpectError(const char* input, | 390 static void ExpectError(const char* input, |
| 388 const char* expected) { | 391 const char* expected) { |
| 389 V8::Initialize(NULL); | 392 V8::Initialize(NULL); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 for (int j = 0; j < kRangeCount; j++) { | 655 for (int j = 0; j < kRangeCount; j++) { |
| 653 uc16* range = ranges[j]; | 656 uc16* range = ranges[j]; |
| 654 bool is_on = false; | 657 bool is_on = false; |
| 655 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) | 658 for (int k = 0; !is_on && (k < 2 * kRangeSize); k += 2) |
| 656 is_on = (range[k] <= p && p <= range[k + 1]); | 659 is_on = (range[k] <= p && p <= range[k + 1]); |
| 657 CHECK_EQ(is_on, outs->Get(j)); | 660 CHECK_EQ(is_on, outs->Get(j)); |
| 658 } | 661 } |
| 659 } | 662 } |
| 660 } | 663 } |
| 661 | 664 |
| 665 |
| 662 // Test of debug-only syntax. | 666 // Test of debug-only syntax. |
| 663 #ifdef DEBUG | 667 #ifdef DEBUG |
| 664 | 668 |
| 665 TEST(ParsePossessiveRepetition) { | 669 TEST(ParsePossessiveRepetition) { |
| 666 bool old_flag_value = FLAG_regexp_possessive_quantifier; | 670 bool old_flag_value = FLAG_regexp_possessive_quantifier; |
| 667 | 671 |
| 668 // Enable possessive quantifier syntax. | 672 // Enable possessive quantifier syntax. |
| 669 FLAG_regexp_possessive_quantifier = true; | 673 FLAG_regexp_possessive_quantifier = true; |
| 670 | 674 |
| 671 CHECK_PARSE_EQ("a*+", "(# 0 - p 'a')"); | 675 CHECK_PARSE_EQ("a*+", "(# 0 - p 'a')"); |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 ZoneList<CharacterRange> first_only(4, &zone); | 1810 ZoneList<CharacterRange> first_only(4, &zone); |
| 1807 ZoneList<CharacterRange> second_only(4, &zone); | 1811 ZoneList<CharacterRange> second_only(4, &zone); |
| 1808 ZoneList<CharacterRange> both(4, &zone); | 1812 ZoneList<CharacterRange> both(4, &zone); |
| 1809 } | 1813 } |
| 1810 | 1814 |
| 1811 | 1815 |
| 1812 TEST(Graph) { | 1816 TEST(Graph) { |
| 1813 V8::Initialize(NULL); | 1817 V8::Initialize(NULL); |
| 1814 Execute("\\b\\w+\\b", false, true, true); | 1818 Execute("\\b\\w+\\b", false, true, true); |
| 1815 } | 1819 } |
| OLD | NEW |