-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathinterpreter-eval-success.spec.ts
33 lines (32 loc) · 1.43 KB
/
interpreter-eval-success.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { getAstFactory } from "../../ast/ast-helpers";
import { CompilerContext } from "../../context/context";
import { openContext, parseModules } from "../../context/store";
import { getParser } from "../../grammar";
import type { Source } from "../../imports/source";
import { evalComptimeExpressions } from "../../types/evalComptimeExpressions";
import { resolveDescriptors } from "../../types/resolveDescriptors";
import { getAllExpressionTypes } from "../../types/resolveExpression";
import { resolveSignatures } from "../../types/resolveSignatures";
import { resolveStatements } from "../../types/resolveStatements";
import { loadCases } from "../../utils/loadCases";
describe("interpreter-evaluation", () => {
for (const r of loadCases(__dirname + "/success/")) {
it(`${r.name} should pass compilation`, () => {
const Ast = getAstFactory();
const sources: Source[] = [
{ code: r.code, path: "<unknown>", origin: "user" },
];
let ctx = openContext(
new CompilerContext(),
sources,
[],
parseModules(sources, getParser(Ast)),
);
ctx = resolveDescriptors(ctx, Ast);
ctx = resolveStatements(ctx);
ctx = resolveSignatures(ctx, Ast);
evalComptimeExpressions(ctx, Ast);
expect(getAllExpressionTypes(ctx)).toMatchSnapshot();
});
}
});