|
| 1 | +import test from 'ava'; |
| 2 | + |
| 3 | +import {Measures} from '@functional-abstraction/measure'; |
| 4 | +import {nrepeat} from '@iterable-iterator/repeat'; |
| 5 | + |
| 6 | +import {empty} from '../../../../../../src/index.js'; |
| 7 | + |
| 8 | +const {COUNTER} = Measures; |
| 9 | + |
| 10 | +test('cover', (t) => { |
| 11 | + const x = 'x'; |
| 12 | + |
| 13 | + // (xxxx, (), x) |
| 14 | + let A = empty(COUNTER).cons(x).cons(x).cons(x).cons(x).cons(x); |
| 15 | + A = A.cons(x); // (xx, ([xxx]), x) |
| 16 | + A = A.cons(x).cons(x); // (xxxx, ([xxx]), x) |
| 17 | + A = A.cons(x); // (xx, ([xxx], (), [xxx]), x) |
| 18 | + A = A.cons(x).cons(x); // (xxxx, ([xxx], (), [xxx]), x) |
| 19 | + A = A.cons(x); // (xx, ([xxx][xxx], (), [xxx]), x) |
| 20 | + A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx], (), [xxx]), x) |
| 21 | + A = A.cons(x); // (xx, ([xxx][xxx][xxx], (), [xxx]), x) |
| 22 | + A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx][xxx], (), [xxx]), x) |
| 23 | + A = A.cons(x); // (xx, ([xxx][xxx][xxx][xxx], (), [xxx]), x) |
| 24 | + A = A.cons(x).cons(x); // (xxxx, ([xxx][xxx][xxx][xxx], (), [xxx]), x) |
| 25 | + |
| 26 | + // (x, (), xxxx) |
| 27 | + let B = empty(COUNTER).push(x).push(x).push(x).push(x).push(x); |
| 28 | + B = B.push(x); // (x, ([xxx]), xx) |
| 29 | + B = B.push(x).push(x); // (x, ([xxx]), xxxx) |
| 30 | + B = B.push(x); // (x, ([xxx], (), [xxx]), xx) |
| 31 | + B = B.push(x).push(x); // (x, ([xxx], (), [xxx]), xxxx) |
| 32 | + B = B.push(x); // (x, ([xxx], (), [xxx][xxx]), xx) |
| 33 | + B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx]), xxxx) |
| 34 | + B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xx) |
| 35 | + B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx][xxx]), xxxx) |
| 36 | + B = B.push(x); // (x, ([xxx], (), [xxx][xxx][xxx][xxx]), xx) |
| 37 | + B = B.push(x).push(x); // (x, ([xxx], (), [xxx][xxx][xxx][xxx]), xxxx) |
| 38 | + |
| 39 | + t.is( |
| 40 | + B.middle.right.measure(COUNTER) + |
| 41 | + B.right._nodes(COUNTER, A.left).length + |
| 42 | + A.middle.left.measure(COUNTER), |
| 43 | + 11, |
| 44 | + ); |
| 45 | + |
| 46 | + const C = B.concat(A); |
| 47 | + |
| 48 | + t.deepEqual([...C], [...nrepeat(x, 40)]); |
| 49 | +}); |
0 commit comments