(fn, pattern, msg)
| 25 | } |
| 26 | |
| 27 | function assertThrows(fn, pattern, msg) { |
| 28 | let threw = false; |
| 29 | try { |
| 30 | fn(); |
| 31 | } catch (err) { |
| 32 | threw = true; |
| 33 | if (pattern) { |
| 34 | const detail = err instanceof Error ? err.message : String(err); |
| 35 | assert(pattern.test(detail), `${msg}: wrong error detail: ${detail}`); |
| 36 | } |
| 37 | } |
| 38 | assert(threw, `${msg}: expected throw`); |
| 39 | } |
| 40 | |
| 41 | function assertMetricsShape(metrics) { |
| 42 | assert(metrics && typeof metrics === "object", "engineGetMetrics must return an object"); |