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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 static_cast<unsigned>(strlen(str3))); | 788 static_cast<unsigned>(strlen(str3))); |
789 TestStreamScanner(&stream3, expectations3, 1, 1 + i); | 789 TestStreamScanner(&stream3, expectations3, 1, 1 + i); |
790 } | 790 } |
791 } | 791 } |
792 | 792 |
793 | 793 |
794 void TestScanRegExp(const char* re_source, const char* expected) { | 794 void TestScanRegExp(const char* re_source, const char* expected) { |
795 i::Utf8ToUtf16CharacterStream stream( | 795 i::Utf8ToUtf16CharacterStream stream( |
796 reinterpret_cast<const i::byte*>(re_source), | 796 reinterpret_cast<const i::byte*>(re_source), |
797 static_cast<unsigned>(strlen(re_source))); | 797 static_cast<unsigned>(strlen(re_source))); |
| 798 i::HandleScope scope(CcTest::i_isolate()); |
798 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 799 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
799 scanner.Initialize(&stream); | 800 scanner.Initialize(&stream); |
800 | 801 |
801 i::Token::Value start = scanner.peek(); | 802 i::Token::Value start = scanner.peek(); |
802 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); | 803 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); |
803 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); | 804 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); |
804 scanner.Next(); // Current token is now the regexp literal. | 805 scanner.Next(); // Current token is now the regexp literal. |
805 CHECK(scanner.is_literal_one_byte()); | 806 i::Handle<i::String> val = |
806 i::Vector<const char> actual = scanner.literal_one_byte_string(); | 807 scanner.AllocateInternalizedString(CcTest::i_isolate()); |
| 808 i::DisallowHeapAllocation no_alloc; |
| 809 i::String::FlatContent content = val->GetFlatContent(); |
| 810 CHECK(content.IsAscii()); |
| 811 i::Vector<const uint8_t> actual = content.ToOneByteVector(); |
807 for (int i = 0; i < actual.length(); i++) { | 812 for (int i = 0; i < actual.length(); i++) { |
808 CHECK_NE('\0', expected[i]); | 813 CHECK_NE('\0', expected[i]); |
809 CHECK_EQ(expected[i], actual[i]); | 814 CHECK_EQ(expected[i], actual[i]); |
810 } | 815 } |
811 } | 816 } |
812 | 817 |
813 | 818 |
814 TEST(RegExpScanning) { | 819 TEST(RegExpScanning) { |
815 v8::V8::Initialize(); | 820 v8::V8::Initialize(); |
816 | 821 |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 | 2349 |
2345 const char* statement_data[] = { | 2350 const char* statement_data[] = { |
2346 statement, | 2351 statement, |
2347 NULL | 2352 NULL |
2348 }; | 2353 }; |
2349 | 2354 |
2350 // The test is quite slow, so run it with a reduced set of flags. | 2355 // The test is quite slow, so run it with a reduced set of flags. |
2351 static const ParserFlag empty_flags[] = {kAllowLazy}; | 2356 static const ParserFlag empty_flags[] = {kAllowLazy}; |
2352 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); | 2357 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); |
2353 } | 2358 } |
OLD | NEW |