| 200 | it('should stringify a RelationalNode with custom toString', function () { |
| 201 | // Also checks if the custom functions get passed on to the children |
| 202 | const customFunction = function (node, options) { |
| 203 | if (node.type === 'RelationalNode') { |
| 204 | let ret = node.params[0].toString(options) |
| 205 | for (let i = 0; i < node.conditionals.length; i++) { |
| 206 | ret += ' ' + node.conditionals[i] + ' ' + node.params[i + 1].toString(options) |
| 207 | } |
| 208 | return ret |
| 209 | } else if (node.type === 'ConstantNode') { |
| 210 | switch (node.value) { |
| 211 | case 1: return 'one' |
| 212 | case 2: return 'two' |
| 213 | case 3: return 'three' |
| 214 | default: return 'NaN' |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | const n = new RelationalNode(['smaller', 'larger', 'smallerEq', 'largerEq', 'equal', 'unequal'], [one, three, two, three, two, two, one]) |
| 220 | |