[gjs/wip/ptomato/develop: 11/11] coverage: Misc refactors



commit 488699892d12222c84861e2b548e1eaec5c9057a
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Sep 24 23:29:34 2017 -0700

    coverage: Misc refactors
    
    - Include default code coverage options in makefile so that branch
      coverage works when enabled
    
    - Fix unused parameter in C function
    
    - Remove test for deprecated SpiderMonkey syntax (it still works, we're
      just not going to test it)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788166

 Makefile-test.am                   |    1 +
 gjs/coverage.cpp                   |   30 +++++++++++++-----------------
 installed-tests/js/testCoverage.js |    7 -------
 3 files changed, 14 insertions(+), 24 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 879363c..e55e8cb 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -337,6 +337,7 @@ JS_LOG_COMPILER = $$LOG_COMPILER $$LOG_FLAGS $(top_builddir)/minijasmine
 
 CODE_COVERAGE_IGNORE_PATTERN = */{include,mfbt,gjs/test,gjs/installed-tests}/*
 CODE_COVERAGE_GENHTML_OPTIONS =                        \
+       $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)        \
        lcov/coverage.lcov                              \
        --prefix $(abs_top_builddir)/lcov/org/gnome/gjs \
        --prefix $(abs_top_builddir)                    \
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index c0de42b..2ccb323 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -431,21 +431,17 @@ get_array_from_js_value(JSContext             *context,
     if (element_clear_func)
         g_array_set_clear_func(c_side_array, element_clear_func);
 
-    if (JS_GetArrayLength(context, js_array, &js_array_len)) {
-        uint32_t i = 0;
-        JS::RootedValue element(context);
-        for (; i < js_array_len; ++i) {
-            if (!JS_GetElement(context, js_array, i, &element)) {
-                g_array_unref(c_side_array);
-                gjs_throw(context, "Failed to get function names array element %d", i);
-                return false;
-            }
+    if (!JS_GetArrayLength(context, js_array, &js_array_len)) {
+        g_array_unref(c_side_array);
+        return false;
+    }
 
-            if (!(inserter(c_side_array, context, element))) {
-                g_array_unref(c_side_array);
-                gjs_throw(context, "Failed to convert array element %d", i);
-                return false;
-            }
+    JS::RootedValue element(context);
+    for (uint32_t i = 0; i < js_array_len; ++i) {
+        if (!JS_GetElement(context, js_array, i, &element) ||
+            !inserter(c_side_array, context, element)) {
+            g_array_unref(c_side_array);
+            return false;
         }
     }
 
@@ -526,12 +522,12 @@ get_hit_count_and_line_data(JSContext       *cx,
                             int32_t         *line)
 {
     JS::RootedId hit_count_name(cx, gjs_intern_string_to_id(cx, "hitCount"));
-    if (!gjs_object_require_property(cx, obj, "function element",
+    if (!gjs_object_require_property(cx, obj, description,
                                      hit_count_name, hit_count))
         return false;
 
     JS::RootedId line_number_name(cx, gjs_intern_string_to_id(cx, "line"));
-    return gjs_object_require_property(cx, obj, "function_element",
+    return gjs_object_require_property(cx, obj, description,
                                        line_number_name, line);
 }
 
diff --git a/installed-tests/js/testCoverage.js b/installed-tests/js/testCoverage.js
index e66319e..30be052 100644
--- a/installed-tests/js/testCoverage.js
+++ b/installed-tests/js/testCoverage.js
@@ -387,13 +387,6 @@ describe('Coverage.functionsForAST', function () {
             ],
         ],
 
-        'finds functions inside for-each statement': [
-            "for each (x in function() {}()) {}\n",
-            [
-                { key: "(anonymous):1:0", line: 1, n_params: 0 }
-            ],
-        ],
-
         'finds functions inside for-of statement': [
             "for (x of (function() {}())) {}\n",
             [


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