UNPKG

@firfi/quint-connect

Version:

Model-based testing framework connecting Quint specifications to TypeScript implementations

64 lines 3.57 kB
import type { StandardSchemaV1 } from "@standard-schema/spec"; import type { RunOptions, TestGenerationOptions } from "./cli/quint.js"; import type { Config } from "./driver/types.js"; export type { QuintRunGeneration, QuintTestGeneration, RunGenerationOptions, RunOptions, TestGenerationOptions, TraceGenerationMode, TraceGenerationOptions } from "./cli/quint.js"; export type { Config } from "./driver/types.js"; export { defaultConfig } from "./driver/types.js"; export { QuintError, QuintNotFoundError } from "./cli/quint.js"; export { NoTracesError, StateMismatchError, TraceReplayError } from "./runner/runner.js"; type PicksSchema = Record<string, StandardSchemaV1<any, any>>; type HandlerPicks<Fields extends PicksSchema> = { readonly [K in keyof Fields]: StandardSchemaV1.InferOutput<Fields[K]>; }; type DriverFactoryResult<S extends Record<string, Record<string, StandardSchemaV1<any, any>>>, State> = { [K in keyof S]: (picks: HandlerPicks<S[K]>) => void | Promise<void>; } & { getState?: () => State; config?: () => Config; }; type DefinedSimpleActions<S extends Record<string, Record<string, StandardSchemaV1<any, any>>>> = { readonly [K in keyof S]: { readonly picks: S[K]; readonly handler: (picks: HandlerPicks<S[K]>) => void | Promise<void>; }; }; interface AnySimpleActionDefPicks { readonly picks: PicksSchema; } interface AnySimpleActionDefHandler { readonly handler: (picks: any) => void | Promise<void>; } type AnySimpleActionDef = AnySimpleActionDefPicks & AnySimpleActionDefHandler; export interface SimpleActionMap { readonly [action: string]: AnySimpleActionDef; } interface SimpleDriverActions<Actions extends SimpleActionMap> { readonly actions: Actions; } interface SimpleDriverHooks<S> { readonly getState?: () => S; readonly config?: () => Config; } export type SimpleDriver<S, Actions extends SimpleActionMap = SimpleActionMap> = SimpleDriverActions<Actions> & SimpleDriverHooks<S>; interface SimpleRunStateCheck<S> { readonly compareState: (spec: S, impl: S) => boolean; readonly deserializeState: (raw: unknown) => S; } export declare const stateCheck: <S>(deserializeState: (raw: unknown) => S, compareState: (spec: S, impl: S) => boolean) => SimpleRunStateCheck<S>; interface SimpleRunDriver<S, Actions extends SimpleActionMap> { readonly driver: () => SimpleDriver<S, Actions> | Promise<SimpleDriver<S, Actions>>; } interface SimpleRunOptionsExtra<S> { readonly stateCheck?: SimpleRunStateCheck<S> | undefined; readonly concurrency?: number | undefined; } export type SimpleRunOptions<S, Actions extends SimpleActionMap = SimpleActionMap> = RunOptions & SimpleRunDriver<S, Actions> & SimpleRunOptionsExtra<S>; export type SimpleTestOptions<S, Actions extends SimpleActionMap = SimpleActionMap> = TestGenerationOptions & SimpleRunDriver<S, Actions> & SimpleRunOptionsExtra<S>; export type SimpleGenerationOptions<S, Actions extends SimpleActionMap = SimpleActionMap> = SimpleRunOptions<S, Actions> | SimpleTestOptions<S, Actions>; export declare function defineDriver<S extends Record<string, Record<string, StandardSchemaV1<any, any>>>, State = unknown>(schema: S, factory: () => DriverFactoryResult<S, State>): () => SimpleDriver<State, DefinedSimpleActions<S>>; export declare const run: <S, Actions extends SimpleActionMap>(opts: SimpleGenerationOptions<S, Actions>) => Promise<{ readonly tracesReplayed: number; readonly seed: string; }>; export { transformITFValue } from "@firfi/itf-trace-parser"; //# sourceMappingURL=simple.d.ts.map