-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
☔ test(concatenate/nodes): Cover all cases to prevent regression.
This is progress on #120.
- Loading branch information
1 parent
855888c
commit 38b9e05
Showing
12 changed files
with
413 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)]); | ||
}); |
Oops, something went wrong.