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

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

Issue 1041863002: Use counter for legacy const. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ready for review Created 5 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
« src/parser.cc ('K') | « 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 3423 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 global_use_counts = use_counts; 3434 global_use_counts = use_counts;
3435 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback); 3435 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
3436 CompileRun("\"use asm\";\n" 3436 CompileRun("\"use asm\";\n"
3437 "var foo = 1;\n" 3437 "var foo = 1;\n"
3438 "\"use asm\";\n" // Only the first one counts. 3438 "\"use asm\";\n" // Only the first one counts.
3439 "function bar() { \"use asm\"; var baz = 1; }"); 3439 "function bar() { \"use asm\"; var baz = 1; }");
3440 CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]); 3440 CHECK_EQ(2, use_counts[v8::Isolate::kUseAsm]);
3441 } 3441 }
3442 3442
3443 3443
3444 TEST(UseConstLegacyCount) {
3445 i::Isolate* isolate = CcTest::i_isolate();
3446 i::HandleScope scope(isolate);
3447 LocalContext env;
3448 int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
3449 global_use_counts = use_counts;
3450 CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
3451 CompileRun(
3452 "const x = 1;\n"
3453 "var foo = 1;\n"
3454 "const y = 1;\n"
3455 "function bar() {\n"
3456 " const z = 1; var baz = 1;\n"
3457 " function q() { const k = 42; }\n"
3458 "}");
3459 CHECK_EQ(4, use_counts[v8::Isolate::kLegacyConst]);
3460 }
3461
3462
3444 TEST(ErrorsArrowFunctions) { 3463 TEST(ErrorsArrowFunctions) {
3445 // Tests that parser and preparser generate the same kind of errors 3464 // Tests that parser and preparser generate the same kind of errors
3446 // on invalid arrow function syntax. 3465 // on invalid arrow function syntax.
3447 const char* context_data[][2] = { 3466 const char* context_data[][2] = {
3448 {"", ";"}, 3467 {"", ";"},
3449 {"v = ", ";"}, 3468 {"v = ", ";"},
3450 {"bar ? (", ") : baz;"}, 3469 {"bar ? (", ") : baz;"},
3451 {"bar ? baz : (", ");"}, 3470 {"bar ? baz : (", ");"},
3452 {"bar[", "];"}, 3471 {"bar[", "];"},
3453 {"bar, ", ";"}, 3472 {"bar, ", ";"},
(...skipping 2327 matching lines...) Expand 10 before | Expand all | Expand 10 after
5781 v8::Script::Compile(v8_str(script3)); 5800 v8::Script::Compile(v8_str(script3));
5782 CHECK(try_catch2.HasCaught()); 5801 CHECK(try_catch2.HasCaught());
5783 v8::String::Utf8Value exception(try_catch2.Exception()); 5802 v8::String::Utf8Value exception(try_catch2.Exception());
5784 CHECK_EQ(0, 5803 CHECK_EQ(0,
5785 strcmp( 5804 strcmp(
5786 "ReferenceError: In strong mode, using an undeclared global " 5805 "ReferenceError: In strong mode, using an undeclared global "
5787 "variable 'not_there3' is not allowed", 5806 "variable 'not_there3' is not allowed",
5788 *exception)); 5807 *exception));
5789 } 5808 }
5790 } 5809 }
OLDNEW
« src/parser.cc ('K') | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698