[gjs] coverage: Treat ArrowExpression as a function definition



commit 46f990fd52a7214848a2b04ebc998633d72de87c
Author: Sam Spilsbury <smspillaz gmail com>
Date:   Thu Jul 2 17:48:55 2015 +0800

    coverage: Treat ArrowExpression as a function definition
    
    We weren't treating it like this before, which was causing
    coverage-counting to abort on files that used them.

 installed-tests/js/testCoverage.js |    1 +
 modules/coverage.js                |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/installed-tests/js/testCoverage.js b/installed-tests/js/testCoverage.js
index 841bfa9..522e102 100644
--- a/installed-tests/js/testCoverage.js
+++ b/installed-tests/js/testCoverage.js
@@ -362,6 +362,7 @@ function testFunctionsInsideArrowExpression() {
 
     assertArrayEquals(foundFunctions,
                       [
+                          { key: "(anonymous):1:1", line: 1, n_params: 1 },
                           { key: "(anonymous):1:0", line: 1, n_params: 0 }
                       ],
                       functionDeclarationsEqual);
diff --git a/modules/coverage.js b/modules/coverage.js
index f5d0db5..0ae96f7 100644
--- a/modules/coverage.js
+++ b/modules/coverage.js
@@ -219,6 +219,7 @@ function functionsForNode(node) {
     switch (node.type) {
     case 'FunctionDeclaration':
     case 'FunctionExpression':
+    case 'ArrowExpression':
         functionNames.push({ key: _getFunctionKeyFromReflectedFunction(node),
                              line: node.loc.start.line,
                              n_params: node.params.length });


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