-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
40 lines (31 loc) · 1.08 KB
/
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
"use strict";
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
var assert = _interopRequire(require("assert"));
var _ = require("./");
var foldl = _.foldl;
var foldr = _.foldr;
var reduce = _.reduce;
var reduceRight = _.reduceRight;
describe("fj-fold", function () {
var join = function (a, b) {
return "" + a + b;
};
it("#foldl", function () {
assert.equal(foldl, reduce);
assert.equal(typeof foldl, "function");
assert.equal(typeof foldl(0), "function");
assert.equal(typeof foldl(0)(join), "function");
assert.equal(foldl(0)(join)([1]), "01");
assert.equal(foldl(0)(join)([1, 2]), "012");
assert.equal(foldl("x")(join)([1, 2]), "x12");
});
it("#foldr", function () {
assert.equal(foldr, reduceRight);
assert.equal(typeof foldr, "function");
assert.equal(typeof foldr(0), "function");
assert.equal(typeof foldr(0)(join), "function");
assert.equal(foldr(0)(join)([1]), "01");
assert.equal(foldr(0)(join)([1, 2]), "021");
assert.equal(foldr("x")(join)([1, 2]), "x21");
});
});