Files
Imhotep/packages/imhotep-dsl/src/quantifiers.ts
T

27 lines
868 B
TypeScript
Raw Normal View History

// Quantifier combinators for compositional expectations
// all(), any(), none() wrap multiple assertions into quantified groups.
import type { FluentAssertion, FluentRelation } from './fluent.js'
export type ComposableAssertion = FluentAssertion | FluentRelation
export interface QuantifiedGroup {
kind: 'all' | 'any' | 'none'
assertions: ComposableAssertion[]
}
/** Every assertion in the group must hold. */
export function all(...assertions: ComposableAssertion[]): QuantifiedGroup {
return { kind: 'all', assertions }
}
/** At least one assertion in the group must hold. */
export function any(...assertions: ComposableAssertion[]): QuantifiedGroup {
return { kind: 'any', assertions }
}
/** No assertion in the group may hold. */
export function none(...assertions: ComposableAssertion[]): QuantifiedGroup {
return { kind: 'none', assertions }
}