services/common/tests/unit/test_utils_deepCopy.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/services/common/tests/unit/test_utils_deepCopy.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,18 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +Cu.import("resource://testing-common/services-common/utils.js");
     1.8 +
     1.9 +function run_test() {
    1.10 +  let thing = {o: {foo: "foo", bar: ["bar"]}, a: ["foo", {bar: "bar"}]};
    1.11 +  let ret = TestingUtils.deepCopy(thing);
    1.12 +  do_check_neq(ret, thing)
    1.13 +  do_check_neq(ret.o, thing.o);
    1.14 +  do_check_neq(ret.o.bar, thing.o.bar);
    1.15 +  do_check_neq(ret.a, thing.a);
    1.16 +  do_check_neq(ret.a[1], thing.a[1]);
    1.17 +  do_check_eq(ret.o.foo, thing.o.foo);
    1.18 +  do_check_eq(ret.o.bar[0], thing.o.bar[0]);
    1.19 +  do_check_eq(ret.a[0], thing.a[0]);
    1.20 +  do_check_eq(ret.a[1].bar, thing.a[1].bar);
    1.21 +}

mercurial