typir
Version:
General purpose type checking library
86 lines • 6.06 kB
TypeScript
/******************************************************************************
* Copyright 2024 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
import { Type } from '../graph/type-node.js';
import { Severity } from '../services/validation.js';
import { TypirServices, TypirSpecifics } from '../typir.js';
/**
* Testing utility to check, that exactly the expected types are in the type system.
* @param services the Typir services
* @param filterTypes used to identify the types of interest
* @param namesOfExpectedTypes the names (not the identifiers!) of the expected types;
* ensures that there are no more types;
* it is possible to specify names multiple times, if there are multiple types with the same name (e.g. for overloaded functions)
* @returns all the found types
*/
export declare function expectTypirTypes<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, filterTypes: (type: Type) => boolean, ...namesOfExpectedTypes: string[]): Type[];
export declare function expectToBeType<T extends Type>(type: unknown, checkType: (t: unknown) => t is T, checkDetails?: (t: T) => boolean): asserts type is T;
/**
* Tests, whether exactly the specified issues are found during the validation of the given language node,
* i.e. neither more nor less validation issues.
* @param services the Typir services
* @param languageNode the language node to validate
* @param expectedIssues the expected issues to occur
*/
export declare function expectValidationIssues<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, languageNode: Specifics['LanguageType'], expectedIssues: string[]): void;
/**
* Tests, whether the specified issues are found during the validation of the given language node,
* more validation issues beyond the specified ones might occur.
* @param services the Typir services
* @param languageNode the language node to validate
* @param options These options are used to filter all occurred issues before the expectations are checked
* @param expectedIssues the expected issues to occur
*/
export declare function expectValidationIssues<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, languageNode: Specifics['LanguageType'], options: ExpectedValidationIssuesOptions, expectedIssues: string[]): void;
/**
* Tests, whether exactly the specified issues are found during the validation of the given language node,
* i.e. neither more nor less validation issues.
* @param services the Typir services
* @param languageNode the language node to validate
* @param expectedStrictIssues the expected issues to occur
*/
export declare function expectValidationIssuesStrict<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, languageNode: Specifics['LanguageType'], expectedStrictIssues: string[]): void;
/**
* Tests, whether exactly the specified issues are found during the validation of the given language node,
* i.e. neither more nor less validation issues.
* @param services the Typir services
* @param languageNode the language node to validate
* @param options These options are used to filter all occurred issues before the expectations are checked
* @param expectedStrictIssues the expected issues to occur
*/
export declare function expectValidationIssuesStrict<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, languageNode: Specifics['LanguageType'], options: ExpectedValidationIssuesOptions, expectedStrictIssues: string[]): void;
/**
* Tests, whether the specified issues are NOT found during the validation of the given language node,
* other validation issues than the specified ones might occur.
* @param services the Typir services
* @param languageNode the language node to validate
* @param forbiddenIssues the issues which are expected to NOT occur
*/
export declare function expectValidationIssuesAbsent<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, languageNode: Specifics['LanguageType'], forbiddenIssues: string[]): void;
/**
* Tests, whether the specified issues are NOT found during the validation of the given language node,
* other validation issues than the specified ones might occur.
* @param services the Typir services
* @param languageNode the language node to validate
* @param options These options are used to filter all occurred issues before the expectations are checked
* @param forbiddenIssues the issues which are expected to NOT occur
*/
export declare function expectValidationIssuesAbsent<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, languageNode: Specifics['LanguageType'], options: ExpectedValidationIssuesOptions, forbiddenIssues: string[]): void;
/**
* Tests, whether no issues at all are found during the validation of the given language node.
* @param services the Typir services
* @param languageNode the language node to validate
* @param options These options are used to filter all occurred issues before the expectations are checked
*/
export declare function expectValidationIssuesNone<Specifics extends TypirSpecifics>(services: TypirServices<Specifics>, languageNode: Specifics['LanguageType'], options?: ExpectedValidationIssuesOptions): void;
export interface ExpectedValidationIssuesOptions {
/** Check only issues which have the specified severity (or check all issues in case of an 'undefined' severity) */
severity?: Severity;
}
export declare function compareValidationIssues(actualIssues: string[], expectedIssues: string[]): void;
export declare function compareValidationIssuesStrict(actualIssues: string[], expectedStrictIssues: string[]): void;
export declare function compareValidationIssuesAbsent(actualIssues: string[], forbiddenIssues: string[]): void;
export declare function compareValidationIssuesNone(actualIssues: string[]): void;
//# sourceMappingURL=test-utils.d.ts.map