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

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

Issue 1154423004: Update all callsites of the TryCatch ctor to pass an Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « test/cctest/test-log.cc ('k') | test/cctest/test-strings.cc » ('j') | 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 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 } 1678 }
1679 1679
1680 1680
1681 TEST(StrictOctal) { 1681 TEST(StrictOctal) {
1682 // Test that syntax error caused by octal literal is reported correctly as 1682 // Test that syntax error caused by octal literal is reported correctly as
1683 // such (issue 2220). 1683 // such (issue 2220).
1684 v8::V8::Initialize(); 1684 v8::V8::Initialize();
1685 v8::HandleScope scope(CcTest::isolate()); 1685 v8::HandleScope scope(CcTest::isolate());
1686 v8::Context::Scope context_scope( 1686 v8::Context::Scope context_scope(
1687 v8::Context::New(CcTest::isolate())); 1687 v8::Context::New(CcTest::isolate()));
1688 v8::TryCatch try_catch; 1688 v8::TryCatch try_catch(CcTest::isolate());
1689 const char* script = 1689 const char* script =
1690 "\"use strict\"; \n" 1690 "\"use strict\"; \n"
1691 "a = function() { \n" 1691 "a = function() { \n"
1692 " b = function() { \n" 1692 " b = function() { \n"
1693 " 01; \n" 1693 " 01; \n"
1694 " }; \n" 1694 " }; \n"
1695 "}; \n"; 1695 "}; \n";
1696 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script)); 1696 v8::Script::Compile(v8::String::NewFromUtf8(CcTest::isolate(), script));
1697 CHECK(try_catch.HasCaught()); 1697 CHECK(try_catch.HasCaught());
1698 v8::String::Utf8Value exception(try_catch.Exception()); 1698 v8::String::Utf8Value exception(try_catch.Exception());
(...skipping 4518 matching lines...) Expand 10 before | Expand all | Expand 10 after
6217 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6217 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6218 arraysize(always_flags)); 6218 arraysize(always_flags));
6219 } 6219 }
6220 6220
6221 6221
6222 TEST(StrongModeFreeVariablesDeclaredByPreviousScript) { 6222 TEST(StrongModeFreeVariablesDeclaredByPreviousScript) {
6223 i::FLAG_strong_mode = true; 6223 i::FLAG_strong_mode = true;
6224 v8::V8::Initialize(); 6224 v8::V8::Initialize();
6225 v8::HandleScope scope(CcTest::isolate()); 6225 v8::HandleScope scope(CcTest::isolate());
6226 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate())); 6226 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
6227 v8::TryCatch try_catch; 6227 v8::TryCatch try_catch(CcTest::isolate());
6228 6228
6229 // Introduce a bunch of variables, in all language modes. 6229 // Introduce a bunch of variables, in all language modes.
6230 const char* script1 = 6230 const char* script1 =
6231 "var my_var1 = 0; \n" 6231 "var my_var1 = 0; \n"
6232 "function my_func1() { } \n" 6232 "function my_func1() { } \n"
6233 "const my_const1 = 0; \n"; 6233 "const my_const1 = 0; \n";
6234 CompileRun(v8_str(script1)); 6234 CompileRun(v8_str(script1));
6235 CHECK(!try_catch.HasCaught()); 6235 CHECK(!try_catch.HasCaught());
6236 6236
6237 const char* script2 = 6237 const char* script2 =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6276 CompileRun(v8_str(script5)); 6276 CompileRun(v8_str(script5));
6277 CHECK(!try_catch.HasCaught()); 6277 CHECK(!try_catch.HasCaught());
6278 } 6278 }
6279 6279
6280 6280
6281 TEST(StrongModeFreeVariablesDeclaredByLanguage) { 6281 TEST(StrongModeFreeVariablesDeclaredByLanguage) {
6282 i::FLAG_strong_mode = true; 6282 i::FLAG_strong_mode = true;
6283 v8::V8::Initialize(); 6283 v8::V8::Initialize();
6284 v8::HandleScope scope(CcTest::isolate()); 6284 v8::HandleScope scope(CcTest::isolate());
6285 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate())); 6285 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
6286 v8::TryCatch try_catch; 6286 v8::TryCatch try_catch(CcTest::isolate());
6287 6287
6288 const char* script1 = 6288 const char* script1 =
6289 "\"use strong\"; \n" 6289 "\"use strong\"; \n"
6290 "Math; \n" 6290 "Math; \n"
6291 "RegExp; \n"; 6291 "RegExp; \n";
6292 CompileRun(v8_str(script1)); 6292 CompileRun(v8_str(script1));
6293 CHECK(!try_catch.HasCaught()); 6293 CHECK(!try_catch.HasCaught());
6294 } 6294 }
6295 6295
6296 6296
6297 TEST(StrongModeFreeVariablesDeclaredInGlobalPrototype) { 6297 TEST(StrongModeFreeVariablesDeclaredInGlobalPrototype) {
6298 i::FLAG_strong_mode = true; 6298 i::FLAG_strong_mode = true;
6299 v8::V8::Initialize(); 6299 v8::V8::Initialize();
6300 v8::HandleScope scope(CcTest::isolate()); 6300 v8::HandleScope scope(CcTest::isolate());
6301 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate())); 6301 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
6302 v8::TryCatch try_catch; 6302 v8::TryCatch try_catch(CcTest::isolate());
6303 6303
6304 const char* script1 = "this.__proto__.my_var = 0;\n"; 6304 const char* script1 = "this.__proto__.my_var = 0;\n";
6305 CompileRun(v8_str(script1)); 6305 CompileRun(v8_str(script1));
6306 CHECK(!try_catch.HasCaught()); 6306 CHECK(!try_catch.HasCaught());
6307 6307
6308 const char* script2 = 6308 const char* script2 =
6309 "\"use strong\"; \n" 6309 "\"use strong\"; \n"
6310 "my_var; \n"; 6310 "my_var; \n";
6311 CompileRun(v8_str(script2)); 6311 CompileRun(v8_str(script2));
6312 CHECK(!try_catch.HasCaught()); 6312 CHECK(!try_catch.HasCaught());
6313 } 6313 }
6314 6314
6315 6315
6316 TEST(StrongModeFreeVariablesNotDeclared) { 6316 TEST(StrongModeFreeVariablesNotDeclared) {
6317 i::FLAG_strong_mode = true; 6317 i::FLAG_strong_mode = true;
6318 v8::V8::Initialize(); 6318 v8::V8::Initialize();
6319 v8::HandleScope scope(CcTest::isolate()); 6319 v8::HandleScope scope(CcTest::isolate());
6320 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate())); 6320 v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
6321 v8::TryCatch try_catch; 6321 v8::TryCatch try_catch(CcTest::isolate());
6322 6322
6323 // Test that referencing unintroduced variables in sloppy mode is ok. 6323 // Test that referencing unintroduced variables in sloppy mode is ok.
6324 const char* script1 = 6324 const char* script1 =
6325 "if (false) { \n" 6325 "if (false) { \n"
6326 " not_there1; \n" 6326 " not_there1; \n"
6327 "} \n"; 6327 "} \n";
6328 CompileRun(v8_str(script1)); 6328 CompileRun(v8_str(script1));
6329 CHECK(!try_catch.HasCaught()); 6329 CHECK(!try_catch.HasCaught());
6330 6330
6331 // But not in strong mode. 6331 // But not in strong mode.
6332 { 6332 {
6333 const char* script2 = 6333 const char* script2 =
6334 "\"use strong\"; \n" 6334 "\"use strong\"; \n"
6335 "if (false) { \n" 6335 "if (false) { \n"
6336 " not_there2; \n" 6336 " not_there2; \n"
6337 "} \n"; 6337 "} \n";
6338 v8::TryCatch try_catch2; 6338 v8::TryCatch try_catch2(CcTest::isolate());
6339 v8::Script::Compile(v8_str(script2)); 6339 v8::Script::Compile(v8_str(script2));
6340 CHECK(try_catch2.HasCaught()); 6340 CHECK(try_catch2.HasCaught());
6341 v8::String::Utf8Value exception(try_catch2.Exception()); 6341 v8::String::Utf8Value exception(try_catch2.Exception());
6342 CHECK_EQ(0, 6342 CHECK_EQ(0,
6343 strcmp( 6343 strcmp(
6344 "ReferenceError: In strong mode, using an undeclared global " 6344 "ReferenceError: In strong mode, using an undeclared global "
6345 "variable 'not_there2' is not allowed", 6345 "variable 'not_there2' is not allowed",
6346 *exception)); 6346 *exception));
6347 } 6347 }
6348 6348
6349 // Check that the variable reference is detected inside a strong function too, 6349 // Check that the variable reference is detected inside a strong function too,
6350 // even if the script scope is not strong. 6350 // even if the script scope is not strong.
6351 { 6351 {
6352 const char* script3 = 6352 const char* script3 =
6353 "(function not_lazy() { \n" 6353 "(function not_lazy() { \n"
6354 " \"use strong\"; \n" 6354 " \"use strong\"; \n"
6355 " if (false) { \n" 6355 " if (false) { \n"
6356 " not_there3; \n" 6356 " not_there3; \n"
6357 " } \n" 6357 " } \n"
6358 "})(); \n"; 6358 "})(); \n";
6359 v8::TryCatch try_catch2; 6359 v8::TryCatch try_catch2(CcTest::isolate());
6360 v8::Script::Compile(v8_str(script3)); 6360 v8::Script::Compile(v8_str(script3));
6361 CHECK(try_catch2.HasCaught()); 6361 CHECK(try_catch2.HasCaught());
6362 v8::String::Utf8Value exception(try_catch2.Exception()); 6362 v8::String::Utf8Value exception(try_catch2.Exception());
6363 CHECK_EQ(0, 6363 CHECK_EQ(0,
6364 strcmp( 6364 strcmp(
6365 "ReferenceError: In strong mode, using an undeclared global " 6365 "ReferenceError: In strong mode, using an undeclared global "
6366 "variable 'not_there3' is not allowed", 6366 "variable 'not_there3' is not allowed",
6367 *exception)); 6367 *exception));
6368 } 6368 }
6369 } 6369 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
6601 "[a, ...]", 6601 "[a, ...]",
6602 "[..., ]", 6602 "[..., ]",
6603 "[..., ...]", 6603 "[..., ...]",
6604 "[ (...a)]", 6604 "[ (...a)]",
6605 NULL}; 6605 NULL};
6606 // clang-format on 6606 // clang-format on
6607 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays}; 6607 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays};
6608 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6608 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6609 arraysize(always_flags)); 6609 arraysize(always_flags));
6610 } 6610 }
OLDNEW
« no previous file with comments | « test/cctest/test-log.cc ('k') | test/cctest/test-strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698