Skip to content

Commit

Permalink
Added testParamAsync and testParamTask (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
1eyewonder authored Oct 13, 2024
1 parent 04f34d2 commit 440b207
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Expecto.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ let expecto =
Expect.isLessThan value 1444 "Should be less than"
] |> List.ofSeq)

testList "testParamAsync" (
testParamAsync 1 [
"First sample",
fun value -> async {
Expect.equal value 1 "Should be expected value"
}
]
|> List.ofSeq
)

testList "testParamTask" (
testParamTask 1 [
"First sample",
fun value () -> task {
Expect.equal value 1 "Should be expected value"
}
]
|> List.ofSeq
)

testList "shuffle" [
testAsync "array sort same" {
let a = [|1;2;3;4;5;6;7|]
Expand Down
11 changes: 11 additions & 0 deletions Expecto/Expecto.fs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,22 @@ module Tests =
ptestCase (stringify case) <| fun () ->
test case |> ignore
ptestList name (cases |> Seq.map caseToTest |> List.ofSeq)

/// Applies a value to a list of partial tests
let inline testParam param =
Seq.map (fun (name, partialTest) ->
testCase name (partialTest param))

/// Applies a value to a list of partial async tests
let inline testParamAsync param =
Seq.map (fun (name, partialTest) ->
testCaseAsync name (partialTest param))

/// Applies a value to a list of partial task tests
let inline testParamTask param =
Seq.map (fun (name, partialTest) ->
testCaseTask name (partialTest param))

/// Test case computation expression builder
type TestCaseBuilder(name, focusState) =
member __.TryFinally(f, compensation) =
Expand Down

0 comments on commit 440b207

Please sign in to comment.