2023-08-26 14:20:22 +03:00
|
|
|
import { expect, vi } from 'vitest';
|
2023-08-26 14:06:41 +03:00
|
|
|
import type { ParseResult } from 'langium';
|
2023-08-26 14:01:56 +03:00
|
|
|
|
2023-08-26 14:37:36 +03:00
|
|
|
const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
2023-08-26 14:01:56 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A helper test function that validate that the result doesn't have errors
|
|
|
|
* or any ambiguous alternatives from chevrotain.
|
|
|
|
*
|
|
|
|
* @param result - the result `parse` function.
|
|
|
|
*/
|
|
|
|
export function noErrorsOrAlternatives(result: ParseResult) {
|
|
|
|
expect(result.lexerErrors).toHaveLength(0);
|
|
|
|
expect(result.parserErrors).toHaveLength(0);
|
|
|
|
|
|
|
|
expect(consoleMock).not.toHaveBeenCalled();
|
|
|
|
consoleMock.mockReset();
|
|
|
|
}
|