Skip to content

Commit

Permalink
Restore one test to original (#17923)
Browse files Browse the repository at this point in the history
  • Loading branch information
majocha authored Oct 25, 2024
1 parent 8b0900c commit 08a0649
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,26 +265,27 @@ type CancellationType() =

let cts = new CancellationTokenSource()
let tcs = System.Threading.Tasks.TaskCompletionSource<_>()
let test() =
let t =
async {
do! tcs.Task |> Async.AwaitTask
}
|> StartAsTaskProperCancel None (Some cts.Token) :> Task
|> StartAsTaskProperCancel None (Some cts.Token)

// First cancel the token, then set the task as cancelled.
async {
do! Async.Sleep 100
cts.Cancel()
do! Async.Sleep 100
tcs.TrySetException (TimeoutException "Task timed out after token.")
|> ignore
|> ignore
} |> Async.Start

task {
let! agg = Assert.ThrowsAsync<AggregateException>(test)
let inner = agg.InnerException
Assert.True(inner :? TimeoutException, $"Excepted TimeoutException wrapped in an AggregateException, but got %A{inner}")
}
try
let res = t.Wait(2000)
let msg = sprintf "Excepted TimeoutException wrapped in an AggregateException, but got %A" res
printfn "failure msg: %s" msg
Assert.Fail (msg)
with :? AggregateException as agg -> ()

// Simpler regression test for https://github.com/dotnet/fsharp/issues/3254
[<Fact>]
Expand Down

0 comments on commit 08a0649

Please sign in to comment.