Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading