deno.land / x / simplestatistic@v7.7.1 / test / chunk.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
/* eslint no-shadow: 0 */
const test = require("tap").test;const ss = require("../");
test("chunk", function (t) { t.test("can get chunks of an array", function (t) { t.same(ss.chunk([1, 2], 1), [[1], [2]]); t.same(ss.chunk([1, 2], 2), [[1, 2]]); t.same(ss.chunk([1, 2, 3, 4], 4), [[1, 2, 3, 4]]); t.same(ss.chunk([1, 2, 3, 4], 2), [ [1, 2], [3, 4] ]); t.same(ss.chunk([1, 2, 3, 4], 3), [[1, 2, 3], [4]]); t.same(ss.chunk([1, 2, 3, 4, 5, 6, 7], 2), [ [1, 2], [3, 4], [5, 6], [7] ]); t.same(ss.chunk([], 2), []); t.throws(function () { ss.chunk([1, 2], 0); }, "Throws with zero chunk size");
t.throws(function () { ss.chunk([1, 2], 1.5); }, "Throws with non-integer chunk size"); t.end(); }); t.end();});
simplestatistic

Version Info

Tagged at
2 years ago