(example, parens = ['keep', 'auto'])
| 224 | // Takes optional 2nd argument that gives the list of paren values to try, |
| 225 | // defaults to ['keep', 'auto'] |
| 226 | function ex (example, parens = ['keep', 'auto']) { |
| 227 | const hasi = 'i' in example |
| 228 | const expr = hasi ? math.parse(example.i) : example.n |
| 229 | const orig = hasi |
| 230 | ? example.i |
| 231 | : `${expr.getIdentifier()}${expr.args.map(arg => arg.getIdentifier())}` |
| 232 | for (const paren of parens) { |
| 233 | const prefix = `${orig},${paren}: ` // eases reading of failure output |
| 234 | const skey = 's' in example ? 's' : 's' + paren |
| 235 | const lkey = 'l' in example ? 'l' : 'l' + paren |
| 236 | assert.strictEqual( |
| 237 | prefix + expr.toString({ parenthesis: paren }), prefix + example[skey]) |
| 238 | assert.strictEqual( |
| 239 | prefix + expr.toTex({ parenthesis: paren }), prefix + example[lkey]) |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | describe('toString and toTex', function () { |
| 244 | it('on an OperatorNode', function () { |
no test coverage detected