-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
48 lines (48 loc) · 811 Bytes
/
test.js
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
var bindall, log, ob1, ob2, ob3, stashedFns, ret;
bindall = require("./main.js");
process.exitCode = 0;
log = function(){
return this.fuel;
};
ob1 = {
fuel: "coffee",
fns: {
foo: log,
bar: log
}
};
bindall(ob1, ob1.fns);
if (!(ob1.fns.foo() === "coffee") && ob1.fns.bar() === "coffee") {
process.exitCode = 1;
}
ob2 = {
fuel: "coffee",
fns: {
foo: log,
bar: log
}
};
bindall(ob2, ob2.fns, {
select: ["foo"]
});
if (!(ob2.fns.foo() === "coffee") || ob2.fns.bar() === "coffee") {
process.exitCode = 1;
}
ob3 = {
fuel: "coffee",
fns: {
foo: log,
bar: log
}
};
stashedFns = ob3.fns;
ret = bindall(ob3, ob3.fns, {
select: ["foo"],
addto: []
});
if (!(ret.foo() === "coffee")) {
process.exitCode = 1;
}
if (!(stashedFns === ob3.fns)) {
process.exitCode = 1;
}