Skip to content

Commit 6d43a0e

Browse files
committed
Assert Taskbuilder tests
1 parent c6200cb commit 6d43a0e

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

tests/FSharpPlus.Tests/ValueTask.fs

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -912,44 +912,50 @@ module ValueTask =
912912
[<Test>]
913913
let taskbuilderTests () =
914914
printfn "Running taskbuilder tests..."
915-
try
916-
testShortCircuitResult()
917-
testDelay()
918-
testNoDelay()
919-
testNonBlocking()
920-
testCatching1()
921-
testCatching2()
922-
testNestedCatching()
923-
testTryFinallyHappyPath()
924-
testTryFinallySadPath()
925-
testTryFinallyCaught()
926-
testUsing()
927-
testUsingFromValueTask()
928-
testUsingSadPath()
929-
testForLoop()
930-
testForLoopSadPath()
931-
testExceptionAttachedToValueTaskWithoutAwait() // *1
932-
testExceptionAttachedToValueTaskWithAwait() // *1
933-
testExceptionThrownInFinally()
934-
test2ndExceptionThrownInFinally()
935-
testFixedStackWhileLoop() // *2
936-
testFixedStackForLoop() // *2
937-
testTypeInference()
938-
// testNoStackOverflowWithImmediateResult() // *3
939-
testNoStackOverflowWithYieldResult()
915+
let tests = [
916+
testShortCircuitResult
917+
testDelay
918+
testNoDelay
919+
testNonBlocking
920+
testCatching1
921+
testCatching2
922+
testNestedCatching
923+
testTryFinallyHappyPath
924+
testTryFinallySadPath
925+
testTryFinallyCaught
926+
testUsing
927+
testUsingFromValueTask
928+
testUsingSadPath
929+
testForLoop
930+
testForLoopSadPath
931+
testExceptionAttachedToValueTaskWithoutAwait // *1
932+
testExceptionAttachedToValueTaskWithAwait // *1
933+
testExceptionThrownInFinally
934+
test2ndExceptionThrownInFinally
935+
testFixedStackWhileLoop // *2
936+
testFixedStackForLoop // *2
937+
testTypeInference
938+
// testNoStackOverflowWithImmediateResult // *3
939+
testNoStackOverflowWithYieldResult
940940
// (Original note from ValueTaskBuilder, n/a here)
941941
// we don't support TCO, so large tail recursions will stack overflow
942942
// or at least use O(n) heap. but small ones should at least function OK.
943-
testSmallTailRecursion()
944-
testTryOverReturnFrom()
945-
testTryFinallyOverReturnFromWithException()
946-
testTryFinallyOverReturnFromWithoutException()
947-
// testCompatibilityWithOldUnitValueTask() // *4
948-
testAsyncsMixedWithValueTasks() // *5
949-
printfn "Passed all tests!"
950-
with
951-
| exn ->
952-
eprintfn "Exception: %O" exn
943+
testSmallTailRecursion
944+
testTryOverReturnFrom
945+
testTryFinallyOverReturnFromWithException
946+
testTryFinallyOverReturnFromWithoutException
947+
// testCompatibilityWithOldUnitValueTask // *4
948+
testAsyncsMixedWithValueTasks // *5
949+
]
950+
951+
let passed, failed =
952+
tests
953+
|> List.map Choice.protect
954+
|> List.partitionMap (fun x -> x())
955+
956+
Assert.AreEqual (0, List.length failed, (sprintf "Some tests failed: %A" failed; failed |> List.iter (eprintfn "Exception: %O")))
957+
printfn "Passed all TaskBuilder tests (%i) !" (List.length passed)
958+
953959
()
954960

955961
// *1 Test adapted due to errors not being part of the workflow, this is by-design.

0 commit comments

Comments
 (0)