[gjs/wip/ptomato/develop: 3/11] coverage: Correct AST walking for labelled statements



commit bf3ef2f58b8025549b5cf434d9b6b425c5ce781f
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Sep 23 11:55:21 2017 -0700

    coverage: Correct AST walking for labelled statements
    
    The AST string constant for labelled statements uses the alternate
    spelling 'LabeledStatement', so these were not getting scanned correctly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788166

 installed-tests/js/testCoverage.js |    8 ++++++++
 modules/_bootstrap/coverage.js     |    4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/installed-tests/js/testCoverage.js b/installed-tests/js/testCoverage.js
index a5fb2bf..f68a1d0 100644
--- a/installed-tests/js/testCoverage.js
+++ b/installed-tests/js/testCoverage.js
@@ -527,6 +527,14 @@ describe('Coverage.functionsForAST', function () {
                 { key: '(anonymous):2:1', line: 2, n_params: 1 },
             ],
         ],
+
+        'finds functions inside labeled statement': [
+            `loop:
+            for (function () {}; ; ) {}`,
+            [
+                { key: '(anonymous):2:0', line: 2, n_params: 0 },
+            ],
+        ],
     };
 
     Object.keys(testTable).forEach(testcase => {
diff --git a/modules/_bootstrap/coverage.js b/modules/_bootstrap/coverage.js
index ec3a4b4..bd1cf14 100644
--- a/modules/_bootstrap/coverage.js
+++ b/modules/_bootstrap/coverage.js
@@ -26,7 +26,7 @@ function getSubNodesForNode(node) {
     let subNodes = [];
     switch (node.type) {
     /* These statements have a single body */
-    case 'LabelledStatement':
+    case 'LabeledStatement':
     case 'WithStatement':
     case 'FunctionDeclaration':
     case 'FunctionExpression':
@@ -285,7 +285,7 @@ function getBranchExitStartLine(branchBodyNode) {
         return -1;
     /* These types of statements are never executable */
     case 'EmptyStatement':
-    case 'LabelledStatement':
+    case 'LabeledStatement':
         return -1;
     default:
         break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]