[gjs] coverage: Drop support for legacy comprehensions



commit a0f33664c38d3e9533812bcdd1c628b0f42d2bc1
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Jun 4 16:09:15 2017 -0400

    coverage: Drop support for legacy comprehensions
    
    In SpiderMonkey 52 these will be considered syntax errors. Only the form
    of array comprehensions with the expression at the end will be supported.
    Switch the regression tests to test the new form rather than the old
    form, and add support for the 'ComprehensionIf' Reflect.parse node type.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781429

 installed-tests/js/testCoverage.js |    7 +++----
 modules/coverage.js                |    3 +++
 2 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/installed-tests/js/testCoverage.js b/installed-tests/js/testCoverage.js
index 6d2b926..049f60a 100644
--- a/installed-tests/js/testCoverage.js
+++ b/installed-tests/js/testCoverage.js
@@ -434,7 +434,7 @@ describe('Coverage.functionsForAST', function () {
 
         'finds functions in an array comprehension body': [
             "let a = new Array(1);\n" +
-            "let b = [function() {} for (i of a)];\n",
+            "let b = [for (i of a) function() {}];\n",
             [
                 { key: "(anonymous):2:0", line: 2, n_params: 0 }
             ],
@@ -442,7 +442,7 @@ describe('Coverage.functionsForAST', function () {
 
         'finds functions in an array comprehension block': [
             "let a = new Array(1);\n" +
-            "let b = [i for (i of function() {})];\n",
+            "let b = [for (i of function() {}) i];\n",
             [
                 { key: "(anonymous):2:0", line: 2, n_params: 0 }
             ],
@@ -450,8 +450,7 @@ describe('Coverage.functionsForAST', function () {
 
         'finds functions in an array comprehension filter': [
             "let a = new Array(1);\n" +
-            "let b = [i for (i of a)" +
-            "if (function() {}())];\n",
+            "let b = [for (i of a) if (function() {}()) i];\n",
             [
                 { key: "(anonymous):2:0", line: 2, n_params: 0 }
             ],
diff --git a/modules/coverage.js b/modules/coverage.js
index d01b378..34718cc 100644
--- a/modules/coverage.js
+++ b/modules/coverage.js
@@ -113,6 +113,9 @@ function getSubNodesForNode(node) {
     case 'ComprehensionBlock':
         subNodes.push(node.right);
         break;
+    case 'ComprehensionIf':
+        subNodes.push(node.test);
+        break;
     /* It is very possible that there might be something
      * interesting in the function arguments, so we need to
      * walk them too */


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