AssertOperators Module
Concise operator syntax for example-based assertions.
The Assert DSL is expression-left: the quoted value stays on the left and the asserted logic reads from left to right.
Recommended usage:
|>? for one expectation, <|> and <&> to compose a few reusable
expectations, ||? when any expectation from a sequence may pass, and &&? when
every expectation from a sequence must pass.
Assert operators are fail-fast. They raise on the first failing assertion instead of collecting multiple failures.
Functions and values
| Function or value |
Description
|
||
Full Usage:
expr &&? expectations
Parameters:
Expr<'T>
-
The quoted expression under test.
expectations : AssertExpectation<'T> seq
-
The expectations that must all succeed.
Modifiers: inline Type parameters: 'T |
Asserts that every expectation from a sequence succeeds.
Use this when you want readable sequence-based logic instead of manually folding
Example
|
||
Full Usage:
a <&> b
Parameters:
^T
-
The first required expectation.
b : ^T
-
The second required expectation.
Returns: ^T
A combined expectation that succeeds only when both input expectations succeed.
Modifiers: inline Type parameters: ^T |
Combines two expectations with logical AND.
Use this to build reusable logic before applying it with
|
||
Full Usage:
expr <=? value
Parameters:
Expr<'T>
-
The quoted expression under test.
value : 'T
-
The inclusive upper bound.
Modifiers: inline Type parameters: 'T |
|||
Full Usage:
expr <>? value
Parameters:
Expr<'T>
-
The quoted expression under test.
value : 'T
-
The value that must not be observed.
Modifiers: inline Type parameters: 'T |
|||
Full Usage:
expr <? value
Parameters:
Expr<'T>
-
The quoted expression under test.
value : 'T
-
The exclusive upper bound.
Modifiers: inline Type parameters: 'T |
|||
Full Usage:
a <|> b
Parameters:
^T
-
The first alternative expectation.
b : ^T
-
The second alternative expectation.
Returns: ^T
A combined expectation that succeeds when either input expectation succeeds.
Modifiers: inline Type parameters: ^T |
Combines two expectations with logical OR.
Use this to build reusable logic before applying it with
|
||
Full Usage:
expr =? value
Parameters:
Expr<'T>
-
The quoted expression under test.
value : 'T
-
The expected value.
Modifiers: inline Type parameters: 'T |
Asserts that a quoted value equals the provided value.
Example
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T with get member IsEmpty: bool with get member Item: index: int -> 'T with get ... val length: list: 'T list -> int
|
||
Full Usage:
expr >=? value
Parameters:
Expr<'T>
-
The quoted expression under test.
value : 'T
-
The inclusive lower bound.
Modifiers: inline Type parameters: 'T |
|||
Full Usage:
expr >>? expectation
Parameters:
Expr<'T>
-
The quoted expression under test.
expectation : AssertExpectation<'T>
-
The expectation to apply.
Returns: Expr<'T>
The original quoted expression.
Modifiers: inline Type parameters: 'T |
Runs one assertion, then returns the original quotation for further chaining.
This is the chain-friendly Assert operator. It supports readable left-to-right pipelines while preserving fail-fast behavior. The returned quotation is not cached. If it is checked again later in the chain, it will be evaluated again.
Example
val ignore: value: 'T -> unit
|
||
Full Usage:
expr >? value
Parameters:
Expr<'T>
-
The quoted expression under test.
value : 'T
-
The exclusive lower bound.
Modifiers: inline Type parameters: 'T |
|||
Full Usage:
expr |>? expectation
Parameters:
Expr<'T>
-
The quoted expression under test.
expectation : AssertExpectation<'T>
-
The expectation to apply.
Modifiers: inline Type parameters: 'T |
Applies one expectation to a quoted expression and raises immediately on failure.
This is the primary Assert DSL operator. Use it for one expectation, or for a small composed
expectation built with
Example
Example
|
||
Full Usage:
expr ||? expectations
Parameters:
Expr<'T>
-
The quoted expression under test.
expectations : AssertExpectation<'T> seq
-
The expectations to try.
Modifiers: inline Type parameters: 'T |
Asserts that at least one expectation from a sequence succeeds. Use this when you have several alternative expectations and the expression may satisfy any one of them.
Example
|
testify