aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test.ts
blob: a3b1d801cb66f5c72545e4ff9f405eae3b627db9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Do, Effect, Kind1 } from './effect'
import { Throw, Try } from './exception'
import { Equals } from './util'

/**
 * Assert a boolean expression is true
 *
 * @typeParam _B - The boolean value to assert
 *
 * @throws {"assertion error"} if false
 *
 * @example
 * Here's an example checking if `SomeValue` is not equal to [1,2,3]
 * Uses - {@link util.Not}, {@link util.Equals}
 *
 * ```ts
 * Assert<Not<Equals<SomeValue, [1, 2, 3]>>>
 * ```
 */
export interface Assert<_B extends boolean> extends Effect {}

export interface Test<_m extends string, _effs extends Effect[]>
  extends Effect {}

export interface ShowAssertionError<_L extends unknown, _R extends unknown>
  extends Effect {}

export type AssertEquals<Left, Right> = Try<
  Assert<Equals<Left, Right>>,
  <m>() => Do<[ShowAssertionError<Left, Right>, Throw<m>]>
>

export interface AssertEqualsK<Right extends unknown> extends Kind1 {
  return: AssertEquals<this['input'], Right>
}