Skip to content

Commit a7bd132

Browse files
Jimmy ByrdTheAngryByrd
authored andcommitted
Adds stacktrace tests
These tests are ignored since asserting against them is very brittle. I'm open to ideas but for now I'd rather manually review them
1 parent a446547 commit a7bd132

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

tests/FsToolkit.ErrorHandling.Tests/AsyncResultCE.fs

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ let ``AsyncResultCE combine/zero/delay/run Tests`` =
171171
}
172172
]
173173

174-
175-
176-
177174
let ``AsyncResultCE try Tests`` =
178175
testList "AsyncResultCE try Tests" [
179176
testCaseAsync "Try With" <| async {
@@ -416,6 +413,45 @@ let ``AsyncResultCE applicative tests`` =
416413
}
417414
]
418415

416+
let ``AsyncResultCE Stack Trace Tests`` =
417+
418+
let failureAsync = async {
419+
failwith "Intentional failure"
420+
return ()
421+
}
422+
423+
let mainExeuctorAsync () = asyncResult {
424+
do! Ok ()
425+
let! _ = failureAsync
426+
return 42
427+
}
428+
429+
let failureAsyncResult = asyncResult {
430+
failwith "Intentional failure"
431+
return ()
432+
}
433+
434+
let mainExeuctorAsyncResult () = asyncResult {
435+
do! Ok ()
436+
let! _ = failureAsyncResult
437+
return 42
438+
}
439+
440+
// These are intentionally marked as pending
441+
// This is useful for reviewing stacktrack traces but asserting against them is very brittle
442+
// I'm open to suggestions around Assertions
443+
ptestList "AsyncResultCE Stack Trace Tests" [
444+
testCaseAsync "Async Failure" <| async {
445+
let! r = mainExeuctorAsync ()
446+
()
447+
}
448+
testCaseAsync "AsyncResult Failure" <| async {
449+
let! r = mainExeuctorAsyncResult ()
450+
()
451+
}
452+
453+
]
454+
419455

420456
let allTests = testList "AsyncResultCETests" [
421457
``AsyncResultCE return Tests``
@@ -426,4 +462,5 @@ let allTests = testList "AsyncResultCETests" [
426462
``AsyncResultCE using Tests``
427463
``AsyncResultCE loop Tests``
428464
``AsyncResultCE applicative tests``
465+
``AsyncResultCE Stack Trace Tests``
429466
]

0 commit comments

Comments
 (0)