From a7a415a0bb502920086367f21cc2c7879e100197 Mon Sep 17 00:00:00 2001 From: make-github-pseudonymous-again <5165674+make-github-pseudonymous-again@users.noreply.github.com> Date: Sat, 29 Oct 2022 13:26:14 +0200 Subject: [PATCH] :test_tube: test(dist): Make tests run. --- test/src/_fixtures.js | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/test/src/_fixtures.js b/test/src/_fixtures.js index 3451a2e..262937b 100644 --- a/test/src/_fixtures.js +++ b/test/src/_fixtures.js @@ -1,9 +1,51 @@ +import { + eq0, + eq1, + eq_1, + le0, + lt0, + ge0, + gt0, + le1, + lt1, + ge1, + gt1, + ge, + lt, + le, + gt, + eq, + ne, +} from '#module'; + +const _names = new Map([ + [eq0, 'eq0'], + [eq1, 'eq1'], + [eq_1, 'eq_1'], + [le0, 'le0'], + [lt0, 'lt0'], + [ge0, 'ge0'], + [gt0, 'gt0'], + [le1, 'le1'], + [lt1, 'lt1'], + [ge1, 'ge1'], + [gt1, 'gt1'], + [ge, 'ge'], + [lt, 'lt'], + [le, 'le'], + [gt, 'gt'], + [eq, 'eq'], + [ne, 'ne'], +]); + +const name = (f) => _names.get(f) ?? f.name; + export const macro = (t, expected, f, ...args) => { t.is(f(...args), expected); }; macro.title = (title, expected, f, ...args) => - title ?? `${f.name}(${args.join(', ')}) is ${JSON.stringify(expected)}`; + title ?? `${name(f)}(${args.join(', ')}) is ${JSON.stringify(expected)}`; const throws = (t, expected, f, ...args) => { t.throws(() => f(...args), expected); @@ -11,6 +53,6 @@ const throws = (t, expected, f, ...args) => { throws.title = (title, expected, f, ...args) => { return ( - title ?? `${f.name}(${args.join(', ')}) throws ${JSON.stringify(expected)}` + title ?? `${name(f)}(${args.join(', ')}) throws ${JSON.stringify(expected)}` ); };