Skip to content

Commit

Permalink
🔬 test: Increase coverage for _zip2.
Browse files Browse the repository at this point in the history
Also fix dostring example.
  • Loading branch information
make-github-pseudonymous-again committed May 4, 2021
1 parent c3507c4 commit 2159b22
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@commitlint/cli": "12.1.1",
"@functional-abstraction/operator": "^1.0.4",
"@iterable-iterator/chain": "^1.0.0",
"@iterable-iterator/range": "^1.0.0",
"@iterable-iterator/reduce": "^0.0.1",
"@iterable-iterator/slice": "^0.0.1",
"@js-library/commitlint-config": "0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion src/_zip2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {iter} from '@iterable-iterator/iter';
*
* @example
* // returns [ [ 'a' , 1 ] , [ 'b' , 2 ] , [ 'c' , 3 ] ]
* list( _zip2( 'abcd' , range(3) ) ) ;
* list( _zip2( 'abcd' , range(1, 4) ) ) ;
*
* @param {Iterable} A - The first iterable.
* @param {Iterable} B - The second iterable.
Expand Down
52 changes: 52 additions & 0 deletions test/src/zip2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import test from 'ava';

import {list} from '@iterable-iterator/list';
import {range} from '@iterable-iterator/range';

import {_zip2} from '../../src/index.js';

import {repr} from './_fixtures.js';

const macro = (t, first, second, out) => {
t.deepEqual(list(_zip2(first, second)), out);
};

macro.title = (title, first, second, out) =>
title ?? `_zip2(${repr(first)}, ${repr(second)}) is ${repr(out)}`;

test(
macro,
[1, 2, 3],
[4, 5, 6],
[
[1, 4],
[2, 5],
[3, 6],
],
);
test(
macro,
[4, 5, 6],
[7, 8, 9, 10],
[
[4, 7],
[5, 8],
[6, 9],
],
);
test(
macro,
[1, 2, 3, 4],
[4, 5, 6],
[
[1, 4],
[2, 5],
[3, 6],
],
);

test(macro, 'abcd', range(1, 4), [
['a', 1],
['b', 2],
['c', 3],
]);
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,11 @@
dependencies:
"@failure-abstraction/error" "^5.0.5"

"@iterable-iterator/range@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@iterable-iterator/range/-/range-1.0.0.tgz#5b3255710e3e0d174a82e38024dc2af3c1aeee25"
integrity sha512-rFgziHtzWs/Zl1c5SfkAbUZzXvqvyeMtjsrwdkvXFQ1FCCXmzFjaMOKpr++wFuoV83XzZuiJ6lyHNEd3CSIyTg==

"@iterable-iterator/reduce@^0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@iterable-iterator/reduce/-/reduce-0.0.1.tgz#35cf9b9c27afcdc1ebcd1a8d1f58162e8abd6290"
Expand Down

0 comments on commit 2159b22

Please sign in to comment.