| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 | 28 #include <cstdlib> |
| 29 #include <stdlib.h> | 29 #include <sstream> |
| 30 | 30 |
| 31 #include "src/v8.h" | 31 #include "src/v8.h" |
| 32 | 32 |
| 33 #include "src/ast.h" | 33 #include "src/ast.h" |
| 34 #include "src/char-predicates-inl.h" | 34 #include "src/char-predicates-inl.h" |
| 35 #include "src/jsregexp.h" | 35 #include "src/jsregexp.h" |
| 36 #include "src/ostreams.h" | 36 #include "src/ostreams.h" |
| 37 #include "src/parser.h" | 37 #include "src/parser.h" |
| 38 #include "src/regexp-macro-assembler.h" | 38 #include "src/regexp-macro-assembler.h" |
| 39 #include "src/regexp-macro-assembler-irregexp.h" | 39 #include "src/regexp-macro-assembler-irregexp.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 static void CheckParseEq(const char* input, const char* expected) { | 97 static void CheckParseEq(const char* input, const char* expected) { |
| 98 v8::HandleScope scope(CcTest::isolate()); | 98 v8::HandleScope scope(CcTest::isolate()); |
| 99 Zone zone(CcTest::i_isolate()); | 99 Zone zone(CcTest::i_isolate()); |
| 100 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 100 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
| 101 RegExpCompileData result; | 101 RegExpCompileData result; |
| 102 CHECK(v8::internal::RegExpParser::ParseRegExp( | 102 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 103 &reader, false, &result, &zone)); | 103 &reader, false, &result, &zone)); |
| 104 CHECK(result.tree != NULL); | 104 CHECK(result.tree != NULL); |
| 105 CHECK(result.error.is_null()); | 105 CHECK(result.error.is_null()); |
| 106 OStringStream os; | 106 std::ostringstream os; |
| 107 result.tree->Print(os, &zone); | 107 result.tree->Print(os, &zone); |
| 108 CHECK_EQ(expected, os.c_str()); | 108 CHECK_EQ(expected, os.str().c_str()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 static bool CheckSimple(const char* input) { | 112 static bool CheckSimple(const char* input) { |
| 113 v8::HandleScope scope(CcTest::isolate()); | 113 v8::HandleScope scope(CcTest::isolate()); |
| 114 Zone zone(CcTest::i_isolate()); | 114 Zone zone(CcTest::i_isolate()); |
| 115 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); | 115 FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); |
| 116 RegExpCompileData result; | 116 RegExpCompileData result; |
| 117 CHECK(v8::internal::RegExpParser::ParseRegExp( | 117 CHECK(v8::internal::RegExpParser::ParseRegExp( |
| 118 &reader, false, &result, &zone)); | 118 &reader, false, &result, &zone)); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 ExpectError("*", kNothingToRepeat); | 428 ExpectError("*", kNothingToRepeat); |
| 429 ExpectError("?", kNothingToRepeat); | 429 ExpectError("?", kNothingToRepeat); |
| 430 ExpectError("+", kNothingToRepeat); | 430 ExpectError("+", kNothingToRepeat); |
| 431 ExpectError("{1}", kNothingToRepeat); | 431 ExpectError("{1}", kNothingToRepeat); |
| 432 ExpectError("{1,2}", kNothingToRepeat); | 432 ExpectError("{1,2}", kNothingToRepeat); |
| 433 ExpectError("{1,}", kNothingToRepeat); | 433 ExpectError("{1,}", kNothingToRepeat); |
| 434 | 434 |
| 435 // Check that we don't allow more than kMaxCapture captures | 435 // Check that we don't allow more than kMaxCapture captures |
| 436 const int kMaxCaptures = 1 << 16; // Must match RegExpParser::kMaxCaptures. | 436 const int kMaxCaptures = 1 << 16; // Must match RegExpParser::kMaxCaptures. |
| 437 const char* kTooManyCaptures = "Too many captures"; | 437 const char* kTooManyCaptures = "Too many captures"; |
| 438 OStringStream os; | 438 std::ostringstream os; |
| 439 for (int i = 0; i <= kMaxCaptures; i++) { | 439 for (int i = 0; i <= kMaxCaptures; i++) { |
| 440 os << "()"; | 440 os << "()"; |
| 441 } | 441 } |
| 442 ExpectError(os.c_str(), kTooManyCaptures); | 442 ExpectError(os.str().c_str(), kTooManyCaptures); |
| 443 } | 443 } |
| 444 | 444 |
| 445 | 445 |
| 446 static bool IsDigit(uc16 c) { | 446 static bool IsDigit(uc16 c) { |
| 447 return ('0' <= c && c <= '9'); | 447 return ('0' <= c && c <= '9'); |
| 448 } | 448 } |
| 449 | 449 |
| 450 | 450 |
| 451 static bool NotDigit(uc16 c) { | 451 static bool NotDigit(uc16 c) { |
| 452 return !IsDigit(c); | 452 return !IsDigit(c); |
| (...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 | 1786 |
| 1787 ZoneList<CharacterRange> first_only(4, &zone); | 1787 ZoneList<CharacterRange> first_only(4, &zone); |
| 1788 ZoneList<CharacterRange> second_only(4, &zone); | 1788 ZoneList<CharacterRange> second_only(4, &zone); |
| 1789 ZoneList<CharacterRange> both(4, &zone); | 1789 ZoneList<CharacterRange> both(4, &zone); |
| 1790 } | 1790 } |
| 1791 | 1791 |
| 1792 | 1792 |
| 1793 TEST(Graph) { | 1793 TEST(Graph) { |
| 1794 Execute("\\b\\w+\\b", false, true, true); | 1794 Execute("\\b\\w+\\b", false, true, true); |
| 1795 } | 1795 } |
| OLD | NEW |