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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 CHECK(error_preparse->HasError()); | 237 CHECK(error_preparse->HasError()); |
238 i::ScriptDataImpl *pre_impl = | 238 i::ScriptDataImpl *pre_impl = |
239 reinterpret_cast<i::ScriptDataImpl*>(error_preparse); | 239 reinterpret_cast<i::ScriptDataImpl*>(error_preparse); |
240 i::Scanner::Location error_location = | 240 i::Scanner::Location error_location = |
241 pre_impl->MessageLocation(); | 241 pre_impl->MessageLocation(); |
242 // Error is at "z" in source, location 10..11. | 242 // Error is at "z" in source, location 10..11. |
243 CHECK_EQ(10, error_location.beg_pos); | 243 CHECK_EQ(10, error_location.beg_pos); |
244 CHECK_EQ(11, error_location.end_pos); | 244 CHECK_EQ(11, error_location.end_pos); |
245 // Should not crash. | 245 // Should not crash. |
246 const char* message = pre_impl->BuildMessage(); | 246 const char* message = pre_impl->BuildMessage(); |
247 pre_impl->BuildArgs(); | 247 i::Vector<const char*> args = pre_impl->BuildArgs(); |
248 CHECK_GT(strlen(message), 0); | 248 CHECK_GT(strlen(message), 0); |
| 249 args.Dispose(); |
| 250 i::DeleteArray(message); |
| 251 delete error_preparse; |
249 } | 252 } |
250 | 253 |
251 | 254 |
252 TEST(StandAlonePreParser) { | 255 TEST(StandAlonePreParser) { |
253 v8::V8::Initialize(); | 256 v8::V8::Initialize(); |
254 | 257 |
255 int marker; | 258 int marker; |
256 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 259 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
257 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 260 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
258 | 261 |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 | 1015 |
1013 for (int i = 0; source_data[i].outer_prefix; i++) { | 1016 for (int i = 0; source_data[i].outer_prefix; i++) { |
1014 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); | 1017 int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); |
1015 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source); | 1018 int kInnerLen = Utf8LengthHelper(source_data[i].inner_source); |
1016 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix); | 1019 int kSuffixLen = Utf8LengthHelper(source_data[i].outer_suffix); |
1017 int kPrefixByteLen = i::StrLength(source_data[i].outer_prefix); | 1020 int kPrefixByteLen = i::StrLength(source_data[i].outer_prefix); |
1018 int kInnerByteLen = i::StrLength(source_data[i].inner_source); | 1021 int kInnerByteLen = i::StrLength(source_data[i].inner_source); |
1019 int kSuffixByteLen = i::StrLength(source_data[i].outer_suffix); | 1022 int kSuffixByteLen = i::StrLength(source_data[i].outer_suffix); |
1020 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen; | 1023 int kProgramSize = kPrefixLen + kInnerLen + kSuffixLen; |
1021 int kProgramByteSize = kPrefixByteLen + kInnerByteLen + kSuffixByteLen; | 1024 int kProgramByteSize = kPrefixByteLen + kInnerByteLen + kSuffixByteLen; |
1022 i::Vector<char> program = i::Vector<char>::New(kProgramByteSize + 1); | 1025 i::ScopedVector<char> program(kProgramByteSize + 1); |
1023 i::OS::SNPrintF(program, "%s%s%s", | 1026 i::OS::SNPrintF(program, "%s%s%s", |
1024 source_data[i].outer_prefix, | 1027 source_data[i].outer_prefix, |
1025 source_data[i].inner_source, | 1028 source_data[i].inner_source, |
1026 source_data[i].outer_suffix); | 1029 source_data[i].outer_suffix); |
1027 | 1030 |
1028 // Parse program source. | 1031 // Parse program source. |
1029 i::Handle<i::String> source( | 1032 i::Handle<i::String> source( |
1030 factory->NewStringFromUtf8(i::CStrVector(program.start()))); | 1033 factory->NewStringFromUtf8(i::CStrVector(program.start()))); |
1031 CHECK_EQ(source->length(), kProgramSize); | 1034 CHECK_EQ(source->length(), kProgramSize); |
1032 i::Handle<i::Script> script = factory->NewScript(source); | 1035 i::Handle<i::Script> script = factory->NewScript(source); |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 int length = i::OS::SNPrintF(program, | 1592 int length = i::OS::SNPrintF(program, |
1590 "%s%s%s", | 1593 "%s%s%s", |
1591 context_data[i][0], | 1594 context_data[i][0], |
1592 statement_data[j], | 1595 statement_data[j], |
1593 context_data[i][1]); | 1596 context_data[i][1]); |
1594 CHECK(length == kProgramSize); | 1597 CHECK(length == kProgramSize); |
1595 TestParserSync(program.start(), flags, ARRAY_SIZE(flags)); | 1598 TestParserSync(program.start(), flags, ARRAY_SIZE(flags)); |
1596 } | 1599 } |
1597 } | 1600 } |
1598 } | 1601 } |
OLD | NEW |