4d2e9eabce6c17f39a63b85c40c2b7d89e388f8b
[conkeror.git] / tests / simple / utils.js
blob4d2e9eabce6c17f39a63b85c40c2b7d89e388f8b
2 require('walnut.js');
4 walnut_run({
5     test_remove_duplicates_filter_1: function () {
6         var ar = [1, 2, 3, 3];
7         assert_objects_equal(ar.filter(remove_duplicates_filter()), [1, 2, 3]);
8     },
9     test_get_home_directory_1: function () {
10         assert(get_home_directory() instanceof Ci.nsIFile);
11     },
12     test_splice_range_1: function () {
13         assert_objects_equal(splice_range([[1,3],[4,6],[7,10]], 2, 8),
14                              [[1,10]]);
15     }
16 });
18 walnut_run({
19     test_string_format_1: function () {
20         assert_equals(string_format("", {}),
21                       "");
22     },
23     test_string_format_2: function () {
24         assert_equals(string_format("%a", {a: 'hello'}),
25                       "hello");
26     },
27     test_string_format_3: function () {
28         assert_equals(string_format("%a%a", {a: 'hello'}),
29                       "hellohello");
30     }
31 });
34 walnut_run({
35     test_array_p_1: function () {
36         assert(array_p([]));
37     },
38     test_array_p_2: function () {
39         assert(array_p(Array()));
40     },
41     test_make_array_1: function () {
42         assert_objects_equal(make_array(undefined), []);
43     },
44     test_make_array_2: function () {
45         assert_objects_equal(make_array(null), [null]);
46     }
47 });
49 walnut_run({
50     test_possibly_valid_url_1: function () {
51         assert_not(possibly_valid_url(""));
52     },
53     test_possibly_valid_url_2: function () {
54         assert_not(possibly_valid_url("         "));
55     },
56     test_possibly_valid_url_3: function () {
57         assert(possibly_valid_url("example"));
58     },
59     test_possibly_valid_url_4: function () {
60         assert(possibly_valid_url("  example  "));
61     },
62     test_possibly_valid_url_5: function () {
63         assert_not(possibly_valid_url("example foo"));
64     },
65     test_possibly_valid_url_6: function () {
66         assert(possibly_valid_url("example/ foo"));
67     },
68     test_possibly_valid_url_7: function () {
69         assert_not(possibly_valid_url("example /foo"));
70     },
71     test_possibly_valid_url_8: function () {
72         assert(possibly_valid_url("/example foo"));
73     },
74     test_possibly_valid_url_9: function () {
75         assert(possibly_valid_url(" /example foo"));
76     },
77     test_possibly_valid_url_10: function () {
78         assert(possibly_valid_url(" ex/ample foo"));
79     },
80     test_possibly_valid_url_11: function () {
81         assert(possibly_valid_url("/"));
82     }
83 });