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 13 matching lines...) Expand all Loading... |
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 #include <stdlib.h> | 28 #include <stdlib.h> |
29 #include <stdio.h> | 29 #include <stdio.h> |
30 #include <string.h> | 30 #include <string.h> |
31 | 31 |
32 #include "src/v8.h" | 32 #include "src/v8.h" |
33 | 33 |
34 #include "src/ast-value-factory.h" | |
35 #include "src/compiler.h" | 34 #include "src/compiler.h" |
36 #include "src/execution.h" | 35 #include "src/execution.h" |
37 #include "src/isolate.h" | 36 #include "src/isolate.h" |
38 #include "src/objects.h" | 37 #include "src/objects.h" |
39 #include "src/parser.h" | 38 #include "src/parser.h" |
40 #include "src/preparser.h" | 39 #include "src/preparser.h" |
41 #include "src/scanner-character-streams.h" | 40 #include "src/scanner-character-streams.h" |
42 #include "src/token.h" | 41 #include "src/token.h" |
43 #include "src/utils.h" | 42 #include "src/utils.h" |
44 #include "test/cctest/cctest.h" | 43 #include "test/cctest/cctest.h" |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 reinterpret_cast<const i::byte*>(re_source), | 789 reinterpret_cast<const i::byte*>(re_source), |
791 static_cast<unsigned>(strlen(re_source))); | 790 static_cast<unsigned>(strlen(re_source))); |
792 i::HandleScope scope(CcTest::i_isolate()); | 791 i::HandleScope scope(CcTest::i_isolate()); |
793 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 792 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
794 scanner.Initialize(&stream); | 793 scanner.Initialize(&stream); |
795 | 794 |
796 i::Token::Value start = scanner.peek(); | 795 i::Token::Value start = scanner.peek(); |
797 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); | 796 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); |
798 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); | 797 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); |
799 scanner.Next(); // Current token is now the regexp literal. | 798 scanner.Next(); // Current token is now the regexp literal. |
800 i::AstValueFactory ast_value_factory(NULL); | |
801 ast_value_factory.Internalize(CcTest::i_isolate()); | |
802 i::Handle<i::String> val = | 799 i::Handle<i::String> val = |
803 scanner.CurrentSymbol(&ast_value_factory)->string(); | 800 scanner.AllocateInternalizedString(CcTest::i_isolate()); |
804 i::DisallowHeapAllocation no_alloc; | 801 i::DisallowHeapAllocation no_alloc; |
805 i::String::FlatContent content = val->GetFlatContent(); | 802 i::String::FlatContent content = val->GetFlatContent(); |
806 CHECK(content.IsAscii()); | 803 CHECK(content.IsAscii()); |
807 i::Vector<const uint8_t> actual = content.ToOneByteVector(); | 804 i::Vector<const uint8_t> actual = content.ToOneByteVector(); |
808 for (int i = 0; i < actual.length(); i++) { | 805 for (int i = 0; i < actual.length(); i++) { |
809 CHECK_NE('\0', expected[i]); | 806 CHECK_NE('\0', expected[i]); |
810 CHECK_EQ(expected[i], actual[i]); | 807 CHECK_EQ(expected[i], actual[i]); |
811 } | 808 } |
812 } | 809 } |
813 | 810 |
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 v8::Local<v8::String> source = | 2542 v8::Local<v8::String> source = |
2546 v8::String::NewFromTwoByte(isolate, two_byte_source); | 2543 v8::String::NewFromTwoByte(isolate, two_byte_source); |
2547 v8::Local<v8::Value> result = CompileRun(source); | 2544 v8::Local<v8::Value> result = CompileRun(source); |
2548 CHECK(result->IsString()); | 2545 CHECK(result->IsString()); |
2549 v8::Local<v8::String> expected_name = | 2546 v8::Local<v8::String> expected_name = |
2550 v8::String::NewFromTwoByte(isolate, two_byte_name); | 2547 v8::String::NewFromTwoByte(isolate, two_byte_name); |
2551 CHECK(result->Equals(expected_name)); | 2548 CHECK(result->Equals(expected_name)); |
2552 i::DeleteArray(two_byte_source); | 2549 i::DeleteArray(two_byte_source); |
2553 i::DeleteArray(two_byte_name); | 2550 i::DeleteArray(two_byte_name); |
2554 } | 2551 } |
2555 | |
2556 | |
2557 TEST(RegressionLazyFunctionWithErrorWithArg) { | |
2558 // The bug occurred when a lazy function had an error which requires a | |
2559 // parameter (such as "unknown label" here). The error message was processed | |
2560 // before the AstValueFactory containing the error message string was | |
2561 // internalized. | |
2562 v8::Isolate* isolate = CcTest::isolate(); | |
2563 v8::HandleScope scope(isolate); | |
2564 LocalContext env; | |
2565 i::FLAG_lazy = true; | |
2566 i::FLAG_min_preparse_length = 0; | |
2567 CompileRun("function this_is_lazy() {\n" | |
2568 " break p;\n" | |
2569 "}\n" | |
2570 "this_is_lazy();\n"); | |
2571 } | |
OLD | NEW |