From e015bf6a7b97fefc194cd58e9af0c7028c8194b4 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Fri, 4 Nov 2022 16:39:43 +0000 Subject: [PATCH] [test] Add pragma parsing to test runner --- compiler/forget/src/__tests__/hir-test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compiler/forget/src/__tests__/hir-test.ts b/compiler/forget/src/__tests__/hir-test.ts index 08c8e27963..7ec5ad5dee 100644 --- a/compiler/forget/src/__tests__/hir-test.ts +++ b/compiler/forget/src/__tests__/hir-test.ts @@ -33,10 +33,25 @@ wasmFolder( path.join(__dirname, "..", "..", "node_modules", "@hpcc-js", "wasm", "dist") ); +const Pragma_RE = /\/\/\s*@enable\((\w+)\)$/gm; + describe("React Forget (HIR version)", () => { generateTestsFromFixtures( path.join(__dirname, "fixtures", "hir"), (input, file) => { + const matches = input.matchAll(Pragma_RE); + + for (const match of matches) { + const [, key, value] = match; + switch (key) { + case "Pass": + // do something with value; + break; + default: + throw new Error(`unknown pragma: ${key}`); + } + } + const ast = parser.parse(input, { sourceFilename: file, plugins: ["typescript", "jsx"],