Add basic testsuite using ui_test

This commit is contained in:
nora 2023-08-01 11:57:44 +02:00
parent 1551847d8c
commit b68d775671
13 changed files with 1524 additions and 79 deletions

View file

@ -11,7 +11,10 @@ export function spanMerge(a: Span, b: Span): Span {
}
export const DUMMY_SPAN = { start: 0, end: 0 };
export const EOF_SPAN = {start: Number.MAX_SAFE_INTEGER, end: Number.MAX_SAFE_INTEGER};
export const EOF_SPAN = {
start: Number.MAX_SAFE_INTEGER,
end: Number.MAX_SAFE_INTEGER,
};
export class CompilerError extends Error {
msg: string;
@ -24,16 +27,18 @@ export class CompilerError extends Error {
}
}
export function withErrorPrinter(
export function withErrorPrinter<R>(
input: string,
filename: string,
f: () => void
): void {
f: () => R,
afterError: (e: CompilerError) => R
): R {
try {
f();
return f();
} catch (e) {
if (e instanceof CompilerError) {
renderError(input, filename, e);
return afterError(e);
} else {
throw e;
}