Skip to content

Commit

Permalink
☔ test(concatenate/nodes): Cover all cases to prevent regression.
Browse files Browse the repository at this point in the history
This is progress on #120.
  • Loading branch information
make-github-pseudonymous-again committed Sep 2, 2021
1 parent 855888c commit 38b9e05
Show file tree
Hide file tree
Showing 12 changed files with 413 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"@iterable-iterator/list": "1.0.1",
"@iterable-iterator/map": "1.0.1",
"@iterable-iterator/range": "2.1.0",
"@iterable-iterator/repeat": "1.0.1",
"@iterable-iterator/reversed": "1.0.0",
"@iterable-iterator/tee": "1.0.0",
"@js-library/commitlint-config": "0.0.4",
Expand Down
35 changes: 35 additions & 0 deletions test/src/regression/core/concatenate/nodes/03.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)

t.is(
A.middle.right.measure(COUNTER) +
A.right._nodes(COUNTER, B.left).length +
B.middle.left.measure(COUNTER),
3,
);

const C = A.concat(B);

t.deepEqual([...C], [...nrepeat(x, 18)]);
});
35 changes: 35 additions & 0 deletions test/src/regression/core/concatenate/nodes/04.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
4,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 18)]);
});
37 changes: 37 additions & 0 deletions test/src/regression/core/concatenate/nodes/05.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xxx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
5,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 21)]);
});
40 changes: 40 additions & 0 deletions test/src/regression/core/concatenate/nodes/06.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx]), xxxx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
6,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 26)]);
});
41 changes: 41 additions & 0 deletions test/src/regression/core/concatenate/nodes/07.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x); // (xxx, ([xxx][xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx]), xxxx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
7,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 27)]);
});
43 changes: 43 additions & 0 deletions test/src/regression/core/concatenate/nodes/08.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx][xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
8,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 30)]);
});
45 changes: 45 additions & 0 deletions test/src/regression/core/concatenate/nodes/09.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx][xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xxxx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
9,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 34)]);
});
47 changes: 47 additions & 0 deletions test/src/regression/core/concatenate/nodes/10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx][xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx][xxx][xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx][xxx]), xx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
10,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 36)]);
});
49 changes: 49 additions & 0 deletions test/src/regression/core/concatenate/nodes/11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import test from 'ava';

import {Measures} from '@functional-abstraction/measure';
import {nrepeat} from '@iterable-iterator/repeat';

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

const {COUNTER} = Measures;

test('cover', (t) => {
const x = 'x';

// (xxxx, (), x)
let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x);
A = A.cons(x); // (xx, ([xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx]), x)
A = A.cons(x); // (xx, ([xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx][xxx], (), [xxx]), x)
A = A.cons(x); // (xx, ([xxx][xxx][xxx][xxx], (), [xxx]), x)
A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx][xxx][xxx], (), [xxx]), x)

// (x, (), xxxx)
let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x);
B = B.push(x); // (x, ([xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xxxx)
B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx][xxx]), xx)
B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx][xxx][xxx]), xxxx)

t.is(
B.middle.right.measure(COUNTER) +
B.right._nodes(COUNTER, A.left).length +
A.middle.left.measure(COUNTER),
11,
);

const C = B.concat(A);

t.deepEqual([...C], [...nrepeat(x, 40)]);
});
Loading

0 comments on commit 38b9e05

Please sign in to comment.