Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmaturtle committed Jul 1, 2023
1 parent 3cb81fb commit 036a381
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions src/Hedgehog.Xunit/InternalLogic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,12 @@ let rec yieldAndCheckReturnValue (x: obj) =
| :? Task<unit> as t -> Async.AwaitTask t |> yieldAndCheckReturnValue
| :? Task<bool> as t -> Async.AwaitTask t |> yieldAndCheckReturnValue
| _ when x <> null && x.GetType().IsGenericType && x.GetType().GetGenericTypeDefinition().IsSubclassOf typeof<Task> ->
let genType = x.GetType().GetGenericTypeDefinition()
if not genType.ContainsGenericParameters then
let t = x :?> Task
Async.AwaitTask t |> yieldAndCheckReturnValue
else
typeof<Async>
.GetMethods()
.First(fun x -> x.Name = "AwaitTask" && x.IsGenericMethod)
.MakeGenericMethod(x.GetType().GetGenericArguments())
.Invoke(null, [|x|])
|> yieldAndCheckReturnValue
typeof<Async>
.GetMethods()
.First(fun x -> x.Name = "AwaitTask" && x.IsGenericMethod)
.MakeGenericMethod(x.GetType().GetGenericArguments().First())
.Invoke(null, [|x|])
|> yieldAndCheckReturnValue
| :? Task as t -> Async.AwaitTask t |> yieldAndCheckReturnValue
| :? Async<unit> as a -> Async.RunSynchronously(a, cancellationToken = CancellationToken.None) |> yieldAndCheckReturnValue
| _ when x <> null && x.GetType().IsGenericType && x.GetType().GetGenericTypeDefinition() = typedefof<Async<_>> ->
Expand Down
2 changes: 1 addition & 1 deletion tests/Hedgehog.Xunit.Tests.FSharp/PropertyTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ module ``Asynchronous tests`` =
let ``Returning Task with exception fails, skipped`` (i: int) : Task =
if i > 10 then
Exception() |> Task.FromException
else Task.Delay 100
else FooAsync()
[<Fact>]
let ``Returning Task with exception fails`` () =
assertShrunk (nameof ``Returning Task with exception fails, skipped``) "[11]"
Expand Down

0 comments on commit 036a381

Please sign in to comment.