[test] Add pragma parsing to test runner
Sathya Gunasekaran committed
Nov 4, 2022 at 16:39 UTC
e015bf6a7b97fefc194cd58e9af0c7028c8194b4
1 file changed
+15
compiler/forget/src/__tests__/hir-test.ts
+15
@@ -33,10 +33,25 @@ wasmFolder(
33
path.join(__dirname, "..", "..", "node_modules", "@hpcc-js", "wasm", "dist")
34
);
35
36
+const Pragma_RE = /\/\/\s*@enable\((\w+)\)$/gm;
37
+
38
describe("React Forget (HIR version)", () => {
39
generateTestsFromFixtures(
40
path.join(__dirname, "fixtures", "hir"),
41
(input, file) => {
42
+ const matches = input.matchAll(Pragma_RE);
43
+
44
+ for (const match of matches) {
45
+ const [, key, value] = match;
46
+ switch (key) {
47
+ case "Pass":
48
+ // do something with value;
49
+ break;
50
+ default:
51
+ throw new Error(`unknown pragma: ${key}`);
52
+ }
53
+ }
54
+
55
const ast = parser.parse(input, {
56
sourceFilename: file,
57
plugins: ["typescript", "jsx"],