MCPcopy
hub / github.com/josdejong/mathjs / exhs

Function exhs

test/unit-tests/expression/node/OperatorNode.test.js:502–522  ·  view source on GitHub ↗
(example, parens = ['keep', 'auto'])

Source from the content-addressed store, hash-verified

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'] })

Callers 1

Calls 5

parseMethod · 0.65
mapMethod · 0.65
toStringMethod · 0.65
toTexMethod · 0.65
getIdentifierMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…