-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathascending-test.js
45 lines (42 loc) · 1.4 KB
/
ascending-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
var vows = require("vows"),
load = require("../load"),
assert = require("../assert");
var suite = vows.describe("d3.ascending");
suite.addBatch({
"d3.ascending": {
topic: load("arrays/ascending").expression("d3.ascending"),
"numbers": {
"returns a negative number if a < b": function(ascending) {
assert.isTrue(ascending(0, 1) < 0);
},
"returns a positive number if a > b": function(ascending) {
assert.isTrue(ascending(1, 0) > 0);
},
"returns zero if a == b": function(ascending) {
assert.equal(ascending(0, 0), 0);
},
"returns NaN if a or b is undefined": function(ascending) {
assert.isNaN(ascending(0, undefined));
assert.isNaN(ascending(undefined, 0));
assert.isNaN(ascending(undefined, undefined));
},
"returns NaN if a or b is NaN": function(ascending) {
assert.isNaN(ascending(0, NaN));
assert.isNaN(ascending(NaN, 0));
assert.isNaN(ascending(NaN, NaN));
}
},
"strings": {
"returns a negative number if a < b": function(ascending) {
assert.isTrue(ascending("a", "b") < 0);
},
"returns a positive number if a > b": function(ascending) {
assert.isTrue(ascending("b", "a") > 0);
},
"returns zero if a == b": function(ascending) {
assert.equal(ascending("a", "a"), 0);
}
}
}
});
suite.export(module);