Skip to content

Commit

Permalink
🧪 test(iterator): Simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed May 3, 2021
1 parent 63affdf commit c1d9937
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions test/src/iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import test from 'ava';

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

const macro = (t, start, stop, step, expected) => {
t.deepEqual(Array.from(range(start, stop, step)), expected);
const macro = (t, items, expected) => {
t.deepEqual(Array.from(items), expected);
};

macro.title = (title, start, stop, step, expected) =>
title ??
`list(range(${start}, ${stop}, ${step})) = ${JSON.stringify(expected)}`;
macro.title = (title, items, expected) =>
title ?? `list(${items}) = ${JSON.stringify(expected)}`;

test(macro, 3, undefined, undefined, [0, 1, 2]);
test(macro, 3, 6, undefined, [3, 4, 5]);
test(macro, range(3), [0, 1, 2]);
test(macro, range(3, 6), [3, 4, 5]);

test(macro, 0, 0, 1, []);
test(macro, 1, 1, 1, []);
test(macro, 0, 1, 1, [0]);
test(macro, 0, 1, 2, [0]);
test(macro, 0, 7, 1, [0, 1, 2, 3, 4, 5, 6]);
test(macro, 7, 0, -1, [7, 6, 5, 4, 3, 2, 1]);
test(macro, range(0, 0, 1), []);
test(macro, range(1, 1, 1), []);
test(macro, range(0, 1, 1), [0]);
test(macro, range(0, 1, 2), [0]);
test(macro, range(0, 7, 1), [0, 1, 2, 3, 4, 5, 6]);
test(macro, range(7, 0, -1), [7, 6, 5, 4, 3, 2, 1]);

0 comments on commit c1d9937

Please sign in to comment.