(mj: any)
| 774 | .sort((a: number, b: number) => a - b); |
| 775 | |
| 776 | test('should solve |x| = 2 (both roots)', () => { |
| 777 | // Regression: the |ax+b|+c root rule had a sign error and a malformed |
| 778 | // second branch, so this returned only [2] (or garbage). |
| 779 | expect(roots('|x| = 2')).toEqual([-2, 2]); |
| 780 | }); |
| 781 | |
| 782 | test('should solve |x - 1| = 2 (unit coefficient)', () => { |
| 783 | expect(roots('|x - 1| = 2')).toEqual([-1, 3]); |
| 784 | }); |
| 785 | |
| 786 | test('should solve |2x - 1| = 3', () => { |