| 271 | it('should stringify a BlockNode with custom toString', function () { |
| 272 | // Also checks if the custom functions get passed on to the children |
| 273 | const customFunction = function (node, options) { |
| 274 | if (node.type === 'BlockNode') { |
| 275 | let string = '' |
| 276 | node.blocks.forEach(function (block) { |
| 277 | string += block.node.toString(options) + '; ' |
| 278 | }) |
| 279 | |
| 280 | return string |
| 281 | } else if (node.type === 'ConstantNode') { |
| 282 | return 'const(' + node.value + ', ' + math.typeOf(node.value) + ')' |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | const a = new ConstantNode(1) |
| 287 | const b = new ConstantNode(2) |