// ets_tracing: off import type { ZSpec } from "../Spec/index.js" export const TestAspectTypeId = Symbol.for("@effect-ts/system/Testing/TestAspect") export type TestAspectTypeId = typeof TestAspectTypeId export type ZSpecLB = ZSpec & [LowerR] extends [R] ? ZSpec : ZSpec /** * A `TestAspect` is an aspect that can be weaved into specs. You can think of * an aspect as a polymorphic function, capable of transforming one test into * another, possibly enlarging the environment or error type. */ export interface TestAspect extends TestAspectBase { (spec: ZSpecLB): ZSpec } export interface TestAspectBase { readonly [TestAspectTypeId]: TestAspectTypeId readonly some: ( predicate: (s: string) => boolean ) => ( spec: ZSpecLB ) => ZSpec } /** * Creates a test aspect by specify the some function */ export function aspect( some: ( predicate: (s: string) => boolean ) => ( spec: ZSpecLB ) => ZSpec ): TestAspect { const all: ( spec: ZSpecLB ) => ZSpec = (spec) => some(() => true)(spec) return Object.assign(all, { [TestAspectTypeId]: TestAspectTypeId, some } as TestAspectBase) } /** * An aspect that returns the tests unchanged */ export const identity: TestAspect = aspect( () => (self) => self )