* Helper: parse input, simplify, check semantic equality with expected. * On failure, reports LaTeX for readability.
( input: string | Expression, expected: string | number | Expression )
| 9 | * On failure, reports LaTeX for readability. |
| 10 | */ |
| 11 | function checkSimplify( |
| 12 | input: string | Expression, |
| 13 | expected: string | number | Expression |
| 14 | ) { |
| 15 | const a = typeof input === 'string' ? ce.parse(input) : ce.expr(input); |
| 16 | const b = |
| 17 | typeof expected === 'number' |
| 18 | ? ce.expr(expected) |
| 19 | : typeof expected === 'string' |
| 20 | ? ce.parse(expected) |
| 21 | : ce.expr(expected); |
| 22 | |
| 23 | const result = a.simplify(); |
| 24 | if (!result.isSame(b)) { |
| 25 | // Provide readable failure message |
| 26 | expect(`${result.latex}`).toBe(`${b.latex}`); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // ============================================================ |
| 31 | // CANONICALIZATION TEST CASES |
no test coverage detected