casual-spelling: update for jsx module system
[conkeror.git] / tests / simple / utils.js
blob4efdd080081674aaebe3be0cd7b6dc110b9fc243
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_make_uri_1: function () {
13         assert(make_uri("http://example.com/") instanceof Ci.nsIURI);
14     },
15     test_make_uri_2: function () {
16         assert(make_uri(make_file("/a/b/c")) instanceof Ci.nsIURI);
17     },
18     test_make_uri_3: function () {
19         assert_equals(make_uri(make_file("/a/b/c")).spec.substr(0,5), "file:");
20     },
21     test_splice_range_1: function () {
22         assert_objects_equal(splice_range([[1,3],[4,6],[7,10]], 2, 8),
23                              [[1,10]]);
24     }
25 });
27 walnut_run({
28     test_string_format_1: function () {
29         assert_equals(string_format("", {}),
30                       "");
31     },
32     test_string_format_2: function () {
33         assert_equals(string_format("%a", {a: 'hello'}),
34                       "hello");
35     },
36     test_string_format_3: function () {
37         assert_equals(string_format("%a%a", {a: 'hello'}),
38                       "hellohello");
39     }
40 });
43 walnut_run({
44     test_array_p_1: function () {
45         assert(array_p([]));
46     },
47     test_array_p_2: function () {
48         assert(array_p(Array()));
49     },
50     test_make_array_1: function () {
51         assert_objects_equal(make_array(undefined), []);
52     },
53     test_make_array_2: function () {
54         assert_objects_equal(make_array(null), [null]);
55     }
56 });