1
_("Make sure json saves and loads from disk");
2
Cu.import("resource://weave/util.js");
5
_("Do a simple write of an array to json and read");
7
Utils.jsonSave("foo", {}, ["v1", "v2"]);
8
Utils.jsonLoad("foo", {}, function(val) {
11
do_check_eq(typeof foo, "object");
12
do_check_eq(foo.length, 2);
13
do_check_eq(foo[0], "v1");
14
do_check_eq(foo[1], "v2");
16
_("Use the function callback version of jsonSave");
18
Utils.jsonSave("bar", {}, function() ["v1", "v2"]);
19
Utils.jsonLoad("bar", {}, function(val) {
22
do_check_eq(typeof bar, "object");
23
do_check_eq(bar.length, 2);
24
do_check_eq(bar[0], "v1");
25
do_check_eq(bar[1], "v2");
27
_("Try saving simple strings");
29
Utils.jsonSave("str", {}, "hi");
30
Utils.jsonLoad("str", {}, function(val) {
33
do_check_eq(typeof str, "string");
34
do_check_eq(str.length, 2);
35
do_check_eq(str[0], "h");
36
do_check_eq(str[1], "i");
38
_("Try saving a number");
40
Utils.jsonSave("num", {}, function() 42);
41
Utils.jsonLoad("num", {}, function(val) {
44
do_check_eq(typeof num, "number");