| 20 | */ |
| 21 | import { ComputeEngine } from '../../../src/compute-engine'; |
| 22 | import * as fs from 'fs'; |
| 23 | import * as path from 'path'; |
| 24 | |
| 25 | const scriptDir = path.dirname(process.argv[1]); |
| 26 | const corpusPath = path.join(scriptDir, '..', 'parser-test-cases.json'); |
| 27 | const corpus = JSON.parse(fs.readFileSync(corpusPath, 'utf8')); |
| 28 | const showFailures = process.argv.includes('--failures'); |
| 29 | const update = process.argv.includes('--update'); |
| 30 | |
| 31 | /** Current parser outcome: 'clean', 'throw', or the first error code. */ |
| 32 | function outcome(input: string): string { |
| 33 | // A fresh engine per input: the engine narrows free-symbol types from |
| 34 | // usage persistently, so a shared engine lets one fragment's inference |
| 35 | // contaminate another's parse (e.g. an early `A \setminus B` narrows `A` |
| 36 | // to a set and breaks a later `\frac{AB^2}{PC}`). Fragments are |
| 37 | // independent inputs; measure them independently. |
| 38 | const ce = new ComputeEngine(); |
| 39 | try { |
| 40 | const expr = ce.parse(input); |