Skip to content

Commit 08a0649

Browse files
authored
Restore one test to original (#17923)
1 parent 8b0900c commit 08a0649

File tree

1 file changed

+9
-8
lines changed
  • tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control

1 file changed

+9
-8
lines changed

tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,26 +265,27 @@ type CancellationType() =
265265

266266
let cts = new CancellationTokenSource()
267267
let tcs = System.Threading.Tasks.TaskCompletionSource<_>()
268-
let test() =
268+
let t =
269269
async {
270270
do! tcs.Task |> Async.AwaitTask
271271
}
272-
|> StartAsTaskProperCancel None (Some cts.Token) :> Task
272+
|> StartAsTaskProperCancel None (Some cts.Token)
273273

274274
// First cancel the token, then set the task as cancelled.
275275
async {
276276
do! Async.Sleep 100
277277
cts.Cancel()
278278
do! Async.Sleep 100
279279
tcs.TrySetException (TimeoutException "Task timed out after token.")
280-
|> ignore
280+
|> ignore
281281
} |> Async.Start
282282

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

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

0 commit comments

Comments
 (0)