diff --git a/test/src/Symbol.iterator.js b/test/src/Symbol.iterator.js index c71e1f8..1d19bc2 100644 --- a/test/src/Symbol.iterator.js +++ b/test/src/Symbol.iterator.js @@ -13,7 +13,7 @@ const order = lexicographical(increasing); const set = (x) => list(map(([k]) => JSON.parse(k), group(JSON.stringify, sorted(order, x)))); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const result = sorted(order, Pairs.from(input)); const expected = set(map(list, input)); t.deepEqual(expected, result); @@ -22,7 +22,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)})`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/clear.js b/test/src/clear.js index 37cf3d1..40f31a4 100644 --- a/test/src/clear.js +++ b/test/src/clear.js @@ -2,7 +2,7 @@ import test from 'ava'; import {MemoryEfficientPairs, EfficientlyInvertiblePairs} from '#module'; -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const result = Pairs.from(input); const out = result.clear(); t.is(undefined, out); @@ -13,7 +13,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).clear()`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/delete.js b/test/src/delete.js index 30f51bc..ee27846 100644 --- a/test/src/delete.js +++ b/test/src/delete.js @@ -2,7 +2,7 @@ import test from 'ava'; import {MemoryEfficientPairs, EfficientlyInvertiblePairs} from '#module'; -const macro = (t, Pairs, input, deleted) => { +const macro = (t, {Pairs}, input, deleted) => { const result = Pairs.from(input); t.is(false, result.delete(deleted)); t.is(input.length, result.size); @@ -14,7 +14,10 @@ macro.title = (title, Pairs, input, deleted) => deleted, )})`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, [], 'ab'); test( macro, diff --git a/test/src/entries.js b/test/src/entries.js index b1fcb13..ee975ed 100644 --- a/test/src/entries.js +++ b/test/src/entries.js @@ -13,7 +13,7 @@ const order = lexicographical(increasing); const set = (x) => list(map(([k]) => JSON.parse(k), group(JSON.stringify, sorted(order, x)))); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const result = sorted(order, Pairs.from(input).entries()); const expected = set(map((x) => [list(x), list(x)], input)); t.deepEqual(expected, result); @@ -22,7 +22,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).entries()`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/forEach.js b/test/src/forEach.js index fef4a09..d95b0cb 100644 --- a/test/src/forEach.js +++ b/test/src/forEach.js @@ -13,7 +13,7 @@ const order = lexicographical(increasing); const set = (x) => list(map(([k]) => JSON.parse(k), group(JSON.stringify, sorted(order, x)))); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const pairs = Pairs.from(input); const _pairs = []; // eslint-disable-next-line unicorn/no-array-for-each @@ -28,7 +28,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).forEach(...)`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/from.js b/test/src/from.js index ed67de3..1715998 100644 --- a/test/src/from.js +++ b/test/src/from.js @@ -13,7 +13,7 @@ const order = lexicographical(increasing); const set = (x) => list(map(([k]) => JSON.parse(k), group(JSON.stringify, sorted(order, x)))); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const result = sorted(order, Pairs.from(input).values()); const expected = set(map(list, input)); t.deepEqual(expected, result); @@ -22,7 +22,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)})`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/invert.js b/test/src/invert.js index 8485422..0fdbceb 100644 --- a/test/src/invert.js +++ b/test/src/invert.js @@ -14,7 +14,7 @@ const set = (x) => list(map(([k]) => JSON.parse(k), group(JSON.stringify, sorted(order, x)))); const invert = (x) => map(([A, B]) => [B, A], x); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const pairs1 = Pairs.from(input); const pairs2 = pairs1.invert(); const result1 = sorted(order, pairs1.values()); @@ -28,7 +28,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).invert()`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/keys.js b/test/src/keys.js index 894f9f0..d248ed0 100644 --- a/test/src/keys.js +++ b/test/src/keys.js @@ -13,7 +13,7 @@ const order = lexicographical(increasing); const set = (x) => list(map(([k]) => JSON.parse(k), group(JSON.stringify, sorted(order, x)))); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const result = sorted(order, Pairs.from(input).keys()); const expected = set(map(list, input)); t.deepEqual(expected, result); @@ -22,7 +22,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).keys()`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/left.js b/test/src/left.js index 4a71608..b769410 100644 --- a/test/src/left.js +++ b/test/src/left.js @@ -12,7 +12,7 @@ import {MemoryEfficientPairs, EfficientlyInvertiblePairs} from '#module'; const set = (x) => sorted(increasing, new Set(x)); const left = (x) => map(([A, _B]) => A, x); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const pairs = Pairs.from(input); const l = set(left(input)); t.deepEqual(l, sorted(increasing, pairs.left())); @@ -36,7 +36,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).left()`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/leftOf.js b/test/src/leftOf.js index d8b6e92..e187bec 100644 --- a/test/src/leftOf.js +++ b/test/src/leftOf.js @@ -13,7 +13,7 @@ const set = (x) => sorted(increasing, new Set(x)); const left = (x) => map(([A, _B]) => A, x); const leftOf = (x, b) => left(filter(([_A, B]) => b === B, x)); -const macro = (t, Pairs, input, ohs) => { +const macro = (t, {Pairs}, input, ohs) => { const pairs = Pairs.from(input); const expected = set(leftOf(input, ohs)); t.deepEqual(expected, sorted(increasing, pairs.leftOf(ohs))); @@ -37,7 +37,10 @@ const macro = (t, Pairs, input, ohs) => { macro.title = (title, Pairs, input, ohs) => title || `${Pairs.name}.from(${JSON.stringify(input)}).leftOf(${ohs})`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, [], 0); test( macro, diff --git a/test/src/right.js b/test/src/right.js index 0e0b46d..97a60e0 100644 --- a/test/src/right.js +++ b/test/src/right.js @@ -12,7 +12,7 @@ import {MemoryEfficientPairs, EfficientlyInvertiblePairs} from '#module'; const set = (x) => sorted(increasing, new Set(x)); const right = (x) => map(([_A, B]) => B, x); -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const pairs = Pairs.from(input); const r = set(right(input)); t.deepEqual(r, sorted(increasing, pairs.right())); @@ -36,7 +36,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).right()`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1], diff --git a/test/src/rightOf.js b/test/src/rightOf.js index 80fa633..c306039 100644 --- a/test/src/rightOf.js +++ b/test/src/rightOf.js @@ -13,7 +13,7 @@ const set = (x) => sorted(increasing, new Set(x)); const right = (x) => map(([_A, B]) => B, x); const rightOf = (x, a) => right(filter(([A, _B]) => a === A, x)); -const macro = (t, Pairs, input, ohs) => { +const macro = (t, {Pairs}, input, ohs) => { const pairs = Pairs.from(input); const expected = set(rightOf(input, ohs)); t.deepEqual(expected, sorted(increasing, pairs.rightOf(ohs))); @@ -37,7 +37,10 @@ const macro = (t, Pairs, input, ohs) => { macro.title = (title, Pairs, input, ohs) => title || `${Pairs.name}.from(${JSON.stringify(input)}).rightOf(${ohs})`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, [], 0); test( macro, diff --git a/test/src/size.js b/test/src/size.js index 1617945..0117fd5 100644 --- a/test/src/size.js +++ b/test/src/size.js @@ -4,7 +4,7 @@ import {enumerate} from '@iterable-iterator/zip'; import {MemoryEfficientPairs, EfficientlyInvertiblePairs} from '#module'; -const macro = (t, Pairs, input) => { +const macro = (t, {Pairs}, input) => { const result = Pairs.from(input); const expected = input.length; t.is(expected, result.size); @@ -20,7 +20,10 @@ const macro = (t, Pairs, input) => { macro.title = (title, Pairs, input) => title || `${Pairs.name}.from(${JSON.stringify(input)}).size`; -for (const Pairs of [MemoryEfficientPairs, EfficientlyInvertiblePairs]) { +for (const Pairs of [ + {name: 'MemoryEfficientPairs', Pairs: MemoryEfficientPairs}, + {name: 'EfficientlyInvertiblePairs', Pairs: EfficientlyInvertiblePairs}, +]) { test(macro, Pairs, []); test(macro, Pairs, [ [1, 1],