| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6ae7d30 commit 23271dd
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | 39 | # Reset this number to 0 on major V8 upgrades. | |
| 40 | 40 | # Increment by one for each non-official patch applied to deps/v8. | |
| 41 | - 'v8_embedder_string': '-node.9', | ||
| 41 | + 'v8_embedder_string': '-node.10', | ||
| 42 | 42 | ||
| 43 | 43 | ##### V8 defaults for Node.js ##### | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,14 @@ void SourceRangeAstVisitor::VisitBlock(Block* stmt) { | |||
| 25 | 25 | } | |
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | + void SourceRangeAstVisitor::VisitSwitchStatement(SwitchStatement* stmt) { | ||
| 29 | + AstTraversalVisitor::VisitSwitchStatement(stmt); | ||
| 30 | + ZonePtrList<CaseClause>* clauses = stmt->cases(); | ||
| 31 | + for (CaseClause* clause : *clauses) { | ||
| 32 | + MaybeRemoveLastContinuationRange(clause->statements()); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 28 | 36 | void SourceRangeAstVisitor::VisitFunctionLiteral(FunctionLiteral* expr) { | |
| 29 | 37 | AstTraversalVisitor::VisitFunctionLiteral(expr); | |
| 30 | 38 | ZonePtrList<Statement>* stmts = expr->body(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ class SourceRangeAstVisitor final | |||
| 34 | 34 | friend class AstTraversalVisitor<SourceRangeAstVisitor>; | |
| 35 | 35 | ||
| 36 | 36 | void VisitBlock(Block* stmt); | |
| 37 | + void VisitSwitchStatement(SwitchStatement* stmt); | ||
| 37 | 38 | void VisitFunctionLiteral(FunctionLiteral* expr); | |
| 38 | 39 | bool VisitNode(AstNode* node); | |
| 39 | 40 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -434,8 +434,8 @@ TestCoverage( | |||
| 434 | 434 | `, | |
| 435 | 435 | [{"start":0,"end":399,"count":1}, | |
| 436 | 436 | {"start":1,"end":351,"count":1}, | |
| 437 | - {"start":154,"end":204,"count":0}, | ||
| 438 | - {"start":226,"end":350,"count":0}] | ||
| 437 | + {"start":154,"end":176,"count":0}, | ||
| 438 | + {"start":254,"end":276,"count":0}] | ||
| 439 | 439 | ); | |
| 440 | 440 | ||
| 441 | 441 | TestCoverage( | |
@@ -464,8 +464,8 @@ TestCoverage( | |||
| 464 | 464 | `, | |
| 465 | 465 | [{"start":0,"end":999,"count":1}, | |
| 466 | 466 | {"start":1,"end":951,"count":1}, | |
| 467 | - {"start":152,"end":202,"count":0}, | ||
| 468 | - {"start":285,"end":353,"count":0}] | ||
| 467 | + {"start":152,"end":168,"count":0}, | ||
| 468 | + {"start":287,"end":310,"count":0}] | ||
| 469 | 469 | ); | |
| 470 | 470 | ||
| 471 | 471 | TestCoverage( | |
@@ -1052,4 +1052,49 @@ try { // 0500 | |||
| 1052 | 1052 | {"start":69,"end":153,"count":1}] | |
| 1053 | 1053 | ); | |
| 1054 | 1054 | ||
| 1055 | + TestCoverage( | ||
| 1056 | + "https://crbug.com/v8/9705", | ||
| 1057 | + ` | ||
| 1058 | + function f(x) { // 0000 | ||
| 1059 | + switch (x) { // 0050 | ||
| 1060 | + case 40: nop(); // 0100 | ||
| 1061 | + case 41: nop(); return 1; // 0150 | ||
| 1062 | + case 42: nop(); break; // 0200 | ||
| 1063 | + } // 0250 | ||
| 1064 | + return 3; // 0300 | ||
| 1065 | + }; // 0350 | ||
| 1066 | + f(40); // 0400 | ||
| 1067 | + f(41); // 0450 | ||
| 1068 | + f(42); // 0500 | ||
| 1069 | + f(43); // 0550 | ||
| 1070 | + `, | ||
| 1071 | + [{"start":0,"end":599,"count":1}, | ||
| 1072 | + {"start":0,"end":351,"count":4}, | ||
| 1073 | + {"start":104,"end":119,"count":1}, | ||
| 1074 | + {"start":154,"end":179,"count":2}, | ||
| 1075 | + {"start":204,"end":226,"count":1}, | ||
| 1076 | + {"start":253,"end":350,"count":2}] | ||
| 1077 | + ); | ||
| 1078 | + | ||
| 1079 | + TestCoverage( | ||
| 1080 | + "https://crbug.com/v8/9705", | ||
| 1081 | + ` | ||
| 1082 | + function f(x) { // 0000 | ||
| 1083 | + switch (x) { // 0050 | ||
| 1084 | + case 40: nop(); // 0100 | ||
| 1085 | + case 41: nop(); return 1; // 0150 | ||
| 1086 | + case 42: nop(); break; // 0200 | ||
| 1087 | + } // 0250 | ||
| 1088 | + return 3; // 0300 | ||
| 1089 | + }; // 0350 | ||
| 1090 | + f(42); // 0400 | ||
| 1091 | + f(43); // 0450 | ||
| 1092 | + `, | ||
| 1093 | + [{"start":0,"end":499,"count":1}, | ||
| 1094 | + {"start":0,"end":351,"count":2}, | ||
| 1095 | + {"start":104,"end":119,"count":0}, | ||
| 1096 | + {"start":154,"end":179,"count":0}, | ||
| 1097 | + {"start":204,"end":226,"count":1}] | ||
| 1098 | + ); | ||
| 1099 | + | ||
| 1055 | 1100 | %DebugToggleBlockCoverage(false); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,25 +18,40 @@ let gen; | |||
| 18 | 18 | return undefined; | |
| 19 | 19 | }; | |
| 20 | 20 | ||
| 21 | - function TestCoverageInternal(name, source, expectation, collect_garbage) { | ||
| 21 | + function TestCoverageInternal( | ||
| 22 | + name, source, expectation, collect_garbage, prettyPrintResults) { | ||
| 22 | 23 | source = source.trim(); | |
| 23 | 24 | eval(source); | |
| 24 | 25 | if (collect_garbage) %CollectGarbage("collect dead objects"); | |
| 25 | 26 | var covfefe = GetCoverage(source); | |
| 26 | 27 | var stringified_result = JSON.stringify(covfefe); | |
| 27 | 28 | var stringified_expectation = JSON.stringify(expectation); | |
| 28 | - if (stringified_result != stringified_expectation) { | ||
| 29 | - print(stringified_result.replace(/[}],[{]/g, "},\n {")); | ||
| 29 | + const mismatch = stringified_result != stringified_expectation; | ||
| 30 | + if (mismatch) { | ||
| 31 | + console.log(stringified_result.replace(/[}],[{]/g, "},\n {")); | ||
| 32 | + } | ||
| 33 | + if (prettyPrintResults) { | ||
| 34 | + console.log("=== Coverage Expectation ===") | ||
| 35 | + for (const {start,end,count} of expectation) { | ||
| 36 | + console.log(`Range [${start}, ${end}) (count: ${count})`); | ||
| 37 | + console.log(source.substring(start, end)); | ||
| 38 | + } | ||
| 39 | + console.log("=== Coverage Results ===") | ||
| 40 | + for (const {start,end,count} of covfefe) { | ||
| 41 | + console.log(`Range [${start}, ${end}) (count: ${count})`); | ||
| 42 | + console.log(source.substring(start, end)); | ||
| 43 | + } | ||
| 44 | + console.log("========================") | ||
| 30 | 45 | } | |
| 31 | 46 | assertEquals(stringified_expectation, stringified_result, name + " failed"); | |
| 32 | 47 | }; | |
| 33 | 48 | ||
| 34 | - TestCoverage = function(name, source, expectation) { | ||
| 35 | - TestCoverageInternal(name, source, expectation, true); | ||
| 49 | + TestCoverage = function(name, source, expectation, prettyPrintResults) { | ||
| 50 | + TestCoverageInternal(name, source, expectation, true, prettyPrintResults); | ||
| 36 | 51 | }; | |
| 37 | 52 | ||
| 38 | - TestCoverageNoGC = function(name, source, expectation) { | ||
| 39 | - TestCoverageInternal(name, source, expectation, false); | ||
| 53 | + TestCoverageNoGC = function(name, source, expectation, prettyPrintResults) { | ||
| 54 | + TestCoverageInternal(name, source, expectation, false, prettyPrintResults); | ||
| 40 | 55 | }; | |
| 41 | 56 | ||
| 42 | 57 | nop = function() {}; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments