()
| 23 | |
| 24 | /** @returns {Promise<Map<string, { exercise: string, patch?: string }>>} */ |
| 25 | const getPatchMap = async () => { |
| 26 | const [exercises, patches] = await Promise.all([ |
| 27 | getFilesInFolder("../../exercises"), |
| 28 | getFilesInFolder("../../patch"), |
| 29 | ]); |
| 30 | |
| 31 | const map = new Map(); |
| 32 | for (const { name, content } of exercises) { |
| 33 | if (!name.endsWith(".wat")) continue; |
| 34 | |
| 35 | map.set(basename(name, ".wat"), { exercise: content }); |
| 36 | } |
| 37 | |
| 38 | for (const { name, content } of patches) { |
| 39 | if (!name.endsWith(".patch")) continue; |
| 40 | |
| 41 | const baseName = basename(name, ".patch"); |
| 42 | if (!map.has(baseName)) { |
| 43 | console.log(map); |
| 44 | throw new Error(`No exercise file found for patch ${name}`); |
| 45 | } |
| 46 | map.get(baseName).patch = content; |
| 47 | } |
| 48 | |
| 49 | return map; |
| 50 | }; |
| 51 | |
| 52 | test("each file has an associated patch", async () => { |
| 53 | const patchMap = await getPatchMap(); |
no test coverage detected