(fn: AssertFn)
| 54 | |
| 55 | export const versionableAssertion = |
| 56 | (fn: AssertFn): AssertFn => |
| 57 | (expected, actual, ctx) => { |
| 58 | if (actual instanceof TypeAssertionMapping) { |
| 59 | if (!ctx.typeAssertion) { |
| 60 | throwInternalError( |
| 61 | `Unexpected missing typeAssertion when passed a TypeAssertionMapper` |
| 62 | ) |
| 63 | } |
| 64 | try { |
| 65 | const mapped = actual.fn(ctx.typeAssertion, ctx) |
| 66 | if (mapped !== null) { |
| 67 | fn( |
| 68 | "expected" in mapped ? mapped.expected : expected, |
| 69 | mapped.actual, |
| 70 | ctx |
| 71 | ) |
| 72 | } |
| 73 | } catch (e) { |
| 74 | throwAssertionError({ |
| 75 | stack: ctx.assertionStack, |
| 76 | message: `${e}` |
| 77 | }) |
| 78 | } |
| 79 | } else fn(expected, actual, ctx) |
| 80 | } |
| 81 | |
| 82 | // node:assert prints the values of a failed deepStrictEqual in full, which |
| 83 | // for a live graph like a Type's exhausts memory (#1287), so only plain data |
no test coverage detected