Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 13496008: fix bogus uses of preparser API (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 const char* program = "var x = 'something';\n" 322 const char* program = "var x = 'something';\n"
323 "escape: function() {}"; 323 "escape: function() {}";
324 // Fails parsing expecting an identifier after "function". 324 // Fails parsing expecting an identifier after "function".
325 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), 325 // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
326 // and then used the invalid currently scanned literal. This always 326 // and then used the invalid currently scanned literal. This always
327 // failed in debug mode, and sometimes crashed in release mode. 327 // failed in debug mode, and sometimes crashed in release mode.
328 328
329 i::Utf8ToUtf16CharacterStream stream( 329 i::Utf8ToUtf16CharacterStream stream(
330 reinterpret_cast<const i::byte*>(program), 330 reinterpret_cast<const i::byte*>(program),
331 static_cast<unsigned>(strlen(program))); 331 static_cast<unsigned>(strlen(program)));
332 i::ScriptDataImpl* data = 332 i::ScriptDataImpl* data = i::ParserApi::PreParse(&stream);
333 i::ParserApi::PreParse(&stream, NULL, false);
334 CHECK(data->HasError()); 333 CHECK(data->HasError());
335 delete data; 334 delete data;
336 } 335 }
337 336
338 337
339 TEST(Regress928) { 338 TEST(Regress928) {
340 v8::V8::Initialize(); 339 v8::V8::Initialize();
341 340
342 // Preparsing didn't consider the catch clause of a try statement 341 // Preparsing didn't consider the catch clause of a try statement
343 // as with-content, which made it assume that a function inside 342 // as with-content, which made it assume that a function inside
344 // the block could be lazily compiled, and an extra, unexpected, 343 // the block could be lazily compiled, and an extra, unexpected,
345 // entry was added to the data. 344 // entry was added to the data.
346 int marker; 345 int marker;
347 i::Isolate::Current()->stack_guard()->SetStackLimit( 346 i::Isolate::Current()->stack_guard()->SetStackLimit(
348 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); 347 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
349 348
350 const char* program = 349 const char* program =
351 "try { } catch (e) { var foo = function () { /* first */ } }" 350 "try { } catch (e) { var foo = function () { /* first */ } }"
352 "var bar = function () { /* second */ }"; 351 "var bar = function () { /* second */ }";
353 352
354 v8::HandleScope handles(v8::Isolate::GetCurrent()); 353 v8::HandleScope handles(v8::Isolate::GetCurrent());
355 i::Handle<i::String> source( 354 i::Handle<i::String> source(
356 FACTORY->NewStringFromAscii(i::CStrVector(program))); 355 FACTORY->NewStringFromAscii(i::CStrVector(program)));
357 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); 356 i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
358 i::ScriptDataImpl* data = i::ParserApi::PreParse(&stream, NULL, false); 357 i::ScriptDataImpl* data = i::ParserApi::PreParse(&stream);
359 CHECK(!data->HasError()); 358 CHECK(!data->HasError());
360 359
361 data->Initialize(); 360 data->Initialize();
362 361
363 int first_function = 362 int first_function =
364 static_cast<int>(strstr(program, "function") - program); 363 static_cast<int>(strstr(program, "function") - program);
365 int first_lbrace = first_function + i::StrLength("function () "); 364 int first_lbrace = first_function + i::StrLength("function () ");
366 CHECK_EQ('{', program[first_lbrace]); 365 CHECK_EQ('{', program[first_lbrace]);
367 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); 366 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace);
368 CHECK(!entry1.is_valid()); 367 CHECK(!entry1.is_valid());
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 " b = function() { \n" 1275 " b = function() { \n"
1277 " 01; \n" 1276 " 01; \n"
1278 " }; \n" 1277 " }; \n"
1279 "}; \n"; 1278 "}; \n";
1280 v8::Script::Compile(v8::String::New(script)); 1279 v8::Script::Compile(v8::String::New(script));
1281 CHECK(try_catch.HasCaught()); 1280 CHECK(try_catch.HasCaught());
1282 v8::String::Utf8Value exception(try_catch.Exception()); 1281 v8::String::Utf8Value exception(try_catch.Exception());
1283 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", 1282 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.",
1284 *exception); 1283 *exception);
1285 } 1284 }
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698