| 253 | it('should stringify an ArrayNode with custom toString', function () { |
| 254 | // Also checks if the custom functions get passed on to the children |
| 255 | const customFunction = function (node, options) { |
| 256 | if (node.type === 'ArrayNode') { |
| 257 | let string = '[' |
| 258 | node.items.forEach(function (item) { |
| 259 | string += item.toString(options) + ', ' |
| 260 | }) |
| 261 | |
| 262 | string += ']' |
| 263 | return string |
| 264 | } else if (node.type === 'ConstantNode') { |
| 265 | return 'const(' + node.value + ', ' + math.typeOf(node.value) + ')' |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | const a = new ConstantNode(1) |
| 270 | const b = new ConstantNode(2) |