(example, parens = ['keep', 'auto'])
| 500 | |
| 501 | // Variant of the `ex` tester that also tests implicit hide and show |
| 502 | function exhs (example, parens = ['keep', 'auto']) { |
| 503 | const imps = ['hide', 'show'] |
| 504 | const hasi = 'i' in example |
| 505 | const expr = hasi ? math.parse(example.i) : example.n |
| 506 | const orig = hasi |
| 507 | ? example.i |
| 508 | : `${expr.getIdentifier()}${expr.args.map(arg => arg.getIdentifier())}` |
| 509 | for (const paren of parens) { |
| 510 | const skey = 's' in example ? 's' : 's' + paren |
| 511 | const lkey = 'l' in example ? 'l' : 'l' + paren |
| 512 | for (const i of [0, 1]) { |
| 513 | const prefix = `${orig},${paren},${imps[i]}: ` // eases reading of failure output |
| 514 | assert.strictEqual( |
| 515 | prefix + expr.toString({ parenthesis: paren, implicit: imps[i] }), |
| 516 | prefix + example[skey][i]) |
| 517 | assert.strictEqual( |
| 518 | prefix + expr.toTex({ parenthesis: paren, implicit: imps[i] }), |
| 519 | prefix + example[lkey][i]) |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | it('should format implicit multiplications', function () { |
| 525 | exhs({ i: '4a', s: ['4 a', '4 * a'], l: ['4~ a', '4\\cdot a'] }) |
no test coverage detected
searching dependent graphs…