| 299 | expect(result?.json).toEqual(['Add', ['Add', 1, 1], 5]); |
| 300 | }); |
| 301 | |
| 302 | it('a replacement that only changes the form counts as a change', () => { |
| 303 | // The rule returns the canonical variant of a raw expression: the value |
| 304 | // is structurally the same, but the form differs. Before PR #305 this |
| 305 | // was treated as "no change" and replace() returned null. |
| 306 | const expr = ce.expr(['Multiply', 2, 'x'], { form: 'raw' }); |
| 307 | const rule = { |
| 308 | match: ['Multiply', '_a', '_b'], |
| 309 | replace: (e) => e.canonical, |
| 310 | }; |
| 311 | const result = expr.replace(rule); |