summaryrefslogtreecommitdiff
path: root/common/tests/functional/utils.js
blob: b5fa59f0f20f9ddd4b5cb165ea7e8197a0c32c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function module(uri) {
    let obj = {};
    Components.utils.import(uri, obj);
    return obj;
}

var elementslib = module("resource://mozmill/modules/elementslib.js");
var frame = module("resource://mozmill/modules/frame.js");
var jumlib = module("resource://mozmill/modules/jum.js");

function toJSON(val) {
    if (typeof val == "function")
        return val.toSource();
    else
        return val;
}

function test(val, params) {
    frame.events[val ? "pass" : "fail"](params);
    return val;
}

for (var [k, v] in Iterator({

    NS: Namespace("dactyl", "http://vimperator.org/namespaces/liberator"),

    module: module,

    toJSON: toJSON,

    test: test,

    assert: function (funcName, value, comment)
        test(value, {
            function: funcName,
            value: toJSON(value),
            comment: toJSON(comment)
        }),

    assertEqual: function (funcName, want, got, comment)
        test(want == got, {
            function: funcName,
            want: toJSON(want), got: toJSON(got),
            comment: toJSON(comment)
        })
}))
    exports[k] = v;

// vim: sw=4 ts=8 et: