| 19 | } |
| 20 | |
| 21 | export const loadTestFile = async (id: string, file: string): Promise<any> => { |
| 22 | const path = resolve("programs", id, file); |
| 23 | const contents = (await readFile(path, "utf-8")).trim(); |
| 24 | |
| 25 | if (file.endsWith(".ts")) { |
| 26 | return await import(path); |
| 27 | } else if (file.endsWith(".jsonl")) { |
| 28 | return contents.split("\n").map((line) => JSON.parse(line)); |
| 29 | } else if (file.endsWith(".json")) { |
| 30 | return JSON.parse(contents); |
| 31 | } |
| 32 | |
| 33 | return contents; |
| 34 | }; |
| 35 | |
| 36 | export function reduce(xs: Value[]): [Value[], number] { |
| 37 | let ys: Value[] = []; |