62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
|
/**
|
||
|
* The shared test interface, so tests can be run by both runtimes
|
||
|
*/
|
||
|
export interface ITestBase {
|
||
|
test(name: string, fn: () => void): void;
|
||
|
assertEquals(actual: unknown, expected: unknown): void;
|
||
|
assertNotEquals(actual: unknown, expected: unknown): void;
|
||
|
assertStrictEquals(actual: unknown, expected: unknown): void;
|
||
|
assertExists(actual: unknown): void;
|
||
|
assertInstanceOf(actual: unknown, expectedType: any): void;
|
||
|
assertTrue(actual: boolean): void;
|
||
|
assertFalse(actual: boolean): void;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* The native functions for terminal settings
|
||
|
*/
|
||
|
export interface IFFI {
|
||
|
/**
|
||
|
* Get the existing termios settings (for canonical mode)
|
||
|
*/
|
||
|
tcgetattr(fd: number, termiosPtr: unknown): number;
|
||
|
|
||
|
/**
|
||
|
* Update the termios settings
|
||
|
*/
|
||
|
tcsetattr(fd: number, act: number, termiosPtr: unknown): number;
|
||
|
|
||
|
/**
|
||
|
* Update the termios pointer with raw mode settings
|
||
|
*/
|
||
|
cfmakeraw(termiosPtr: unknown): void;
|
||
|
|
||
|
/**
|
||
|
* Convert a TypedArray to an opaque pointer for ffi calls
|
||
|
*/
|
||
|
getPointer(ta: any): unknown;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Runtime-specific IO streams
|
||
|
*/
|
||
|
export interface ITerminalIO {
|
||
|
/**
|
||
|
* The generator function returning chunks of input from the stdin stream
|
||
|
*/
|
||
|
inputLoop(): AsyncGenerator<Uint8Array, void, unknown>;
|
||
|
|
||
|
/**
|
||
|
* Pipe a string to stdout
|
||
|
*/
|
||
|
write(s: string): Promise<void>;
|
||
|
}
|
||
|
|
||
|
export interface IRuntime {
|
||
|
/**
|
||
|
* Set a beforeExit/beforeUnload event handler for the runtime
|
||
|
* @param cb - The event handler
|
||
|
*/
|
||
|
onExit(cb: () => void): void;
|
||
|
}
|