Loading services/common/Makefile.in +8 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,14 @@ libs:: TEST_DIRS += tests TESTING_JS_MODULES := aitcserver.js storageserver.js testing_modules := \ aitcserver.js \ storageserver.js \ utils.js \ $(NULL) TESTING_JS_MODULES := $(foreach file,$(testing_modules),modules-testing/$(file)) TESTING_JS_MODULE_DIR := services-common # What follows is a helper to launch a standalone storage server instance. Loading services/common/aitcserver.js→services/common/modules-testing/aitcserver.js +0 −0 File moved. View file services/common/storageserver.js→services/common/modules-testing/storageserver.js +0 −0 File moved. View file services/common/modules-testing/utils.js 0 → 100644 +42 −0 Original line number Diff line number Diff line /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const EXPORTED_SYMBOLS = [ "TestingUtils", ]; let TestingUtils = { /** * Perform a deep copy of an Array or Object. */ deepCopy: function deepCopy(thing, noSort) { if (typeof(thing) != "object" || thing == null) { return thing; } if (Array.isArray(thing)) { let ret = []; for (let element of thing) { ret.push(this.deepCopy(element, noSort)); } return ret; } let ret = {}; let props = [p for (p in thing)]; if (!noSort) { props = props.sort(); } for (let prop of props) { ret[prop] = this.deepCopy(thing[prop], noSort); } return ret; }, }; services/sync/tests/unit/test_utils_deepCopy.js→services/common/tests/unit/test_utils_deepCopy.js +5 −2 Original line number Diff line number Diff line Cu.import("resource://services-sync/util.js"); /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ Cu.import("resource://testing-common/services-common/utils.js"); function run_test() { let thing = {o: {foo: "foo", bar: ["bar"]}, a: ["foo", {bar: "bar"}]}; let ret = deepCopy(thing); let ret = TestingUtils.deepCopy(thing); do_check_neq(ret, thing) do_check_neq(ret.o, thing.o); do_check_neq(ret.o.bar, thing.o.bar); Loading Loading
services/common/Makefile.in +8 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,14 @@ libs:: TEST_DIRS += tests TESTING_JS_MODULES := aitcserver.js storageserver.js testing_modules := \ aitcserver.js \ storageserver.js \ utils.js \ $(NULL) TESTING_JS_MODULES := $(foreach file,$(testing_modules),modules-testing/$(file)) TESTING_JS_MODULE_DIR := services-common # What follows is a helper to launch a standalone storage server instance. Loading
services/common/aitcserver.js→services/common/modules-testing/aitcserver.js +0 −0 File moved. View file
services/common/storageserver.js→services/common/modules-testing/storageserver.js +0 −0 File moved. View file
services/common/modules-testing/utils.js 0 → 100644 +42 −0 Original line number Diff line number Diff line /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const EXPORTED_SYMBOLS = [ "TestingUtils", ]; let TestingUtils = { /** * Perform a deep copy of an Array or Object. */ deepCopy: function deepCopy(thing, noSort) { if (typeof(thing) != "object" || thing == null) { return thing; } if (Array.isArray(thing)) { let ret = []; for (let element of thing) { ret.push(this.deepCopy(element, noSort)); } return ret; } let ret = {}; let props = [p for (p in thing)]; if (!noSort) { props = props.sort(); } for (let prop of props) { ret[prop] = this.deepCopy(thing[prop], noSort); } return ret; }, };
services/sync/tests/unit/test_utils_deepCopy.js→services/common/tests/unit/test_utils_deepCopy.js +5 −2 Original line number Diff line number Diff line Cu.import("resource://services-sync/util.js"); /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ Cu.import("resource://testing-common/services-common/utils.js"); function run_test() { let thing = {o: {foo: "foo", bar: ["bar"]}, a: ["foo", {bar: "bar"}]}; let ret = deepCopy(thing); let ret = TestingUtils.deepCopy(thing); do_check_neq(ret, thing) do_check_neq(ret.o, thing.o); do_check_neq(ret.o.bar, thing.o.bar); Loading