| 371 | it('should stringify an OperatorNode with custom toString', function () { |
| 372 | // Also checks if the custom functions get passed on to the children |
| 373 | const customFunction = function (node, options) { |
| 374 | if (node.type === 'OperatorNode') { |
| 375 | return node.op + node.fn + '(' + |
| 376 | node.args[0].toString(options) + |
| 377 | ', ' + node.args[1].toString(options) + ')' |
| 378 | } else if (node.type === 'ConstantNode') { |
| 379 | return 'const(' + node.value + ', ' + math.typeOf(node.value) + ')' |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | const n2 = new OperatorNode('-', 'subtract', [one, two]) |
| 384 | |