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

Unified Diff: test/cctest/test-usecounters.cc

Issue 2599253002: [counters] Add UseCounters for 'f() = 0' syntax (Closed)
Patch Set: fix test Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser-base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-usecounters.cc
diff --git a/test/cctest/test-usecounters.cc b/test/cctest/test-usecounters.cc
index 8d4628c9f70f3e912acd02a3ca495898ffeff404..3482476b76933b8d03beaf367325469a030e8423 100644
--- a/test/cctest/test-usecounters.cc
+++ b/test/cctest/test-usecounters.cc
@@ -71,3 +71,46 @@ TEST(DefineGetterSetterThrowUseCount) {
"a.__defineSetter__('b', ()=>{});");
CHECK_EQ(2, use_counts[v8::Isolate::kDefineGetterOrSetterWouldThrow]);
}
+
+TEST(AssigmentExpressionLHSIsCall) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope scope(isolate);
+ LocalContext env;
+ int use_counts[v8::Isolate::kUseCounterFeatureCount] = {};
+ global_use_counts = use_counts;
+ CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
+
+ // AssignmentExpressions whose LHS is not a call do not increment counters
+ CompileRun("function f(){ a = 0; a()[b] = 0; }");
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+ CompileRun("function f(){ ++a; ++a()[b]; }");
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+ CompileRun("function f(){ 'use strict'; a = 0; a()[b] = 0; }");
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+ CompileRun("function f(){ 'use strict'; ++a; ++a()[b]; }");
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+
+ // AssignmentExpressions whose LHS is a call increment appropriate counters
+ CompileRun("function f(){ a() = 0; }");
+ CHECK_NE(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+ use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy] = 0;
+ CompileRun("function f(){ 'use strict'; a() = 0; }");
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_NE(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+ use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict] = 0;
+
+ // UpdateExpressions whose LHS is a call increment appropriate counters
+ CompileRun("function f(){ ++a(); }");
+ CHECK_NE(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+ use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy] = 0;
+ CompileRun("function f(){ 'use strict'; ++a(); }");
+ CHECK_EQ(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy]);
+ CHECK_NE(0, use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict]);
+ use_counts[v8::Isolate::kAssigmentExpressionLHSIsCallInStrict] = 0;
+}
« no previous file with comments | « src/parsing/parser-base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698