From 036a3811810c7aa956c9f66d0e153cefc4ddde67 Mon Sep 17 00:00:00 2001 From: AN Date: Sat, 1 Jul 2023 16:01:53 -0500 Subject: [PATCH] polish --- src/Hedgehog.Xunit/InternalLogic.fs | 17 ++++++----------- .../PropertyTests.fs | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Hedgehog.Xunit/InternalLogic.fs b/src/Hedgehog.Xunit/InternalLogic.fs index ddb20a2..e867a0c 100644 --- a/src/Hedgehog.Xunit/InternalLogic.fs +++ b/src/Hedgehog.Xunit/InternalLogic.fs @@ -118,17 +118,12 @@ let rec yieldAndCheckReturnValue (x: obj) = | :? Task as t -> Async.AwaitTask t |> yieldAndCheckReturnValue | :? Task as t -> Async.AwaitTask t |> yieldAndCheckReturnValue | _ when x <> null && x.GetType().IsGenericType && x.GetType().GetGenericTypeDefinition().IsSubclassOf typeof -> - let genType = x.GetType().GetGenericTypeDefinition() - if not genType.ContainsGenericParameters then - let t = x :?> Task - Async.AwaitTask t |> yieldAndCheckReturnValue - else - typeof - .GetMethods() - .First(fun x -> x.Name = "AwaitTask" && x.IsGenericMethod) - .MakeGenericMethod(x.GetType().GetGenericArguments()) - .Invoke(null, [|x|]) - |> yieldAndCheckReturnValue + typeof + .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 as a -> Async.RunSynchronously(a, cancellationToken = CancellationToken.None) |> yieldAndCheckReturnValue | _ when x <> null && x.GetType().IsGenericType && x.GetType().GetGenericTypeDefinition() = typedefof> -> diff --git a/tests/Hedgehog.Xunit.Tests.FSharp/PropertyTests.fs b/tests/Hedgehog.Xunit.Tests.FSharp/PropertyTests.fs index 995eae1..7bbb235 100644 --- a/tests/Hedgehog.Xunit.Tests.FSharp/PropertyTests.fs +++ b/tests/Hedgehog.Xunit.Tests.FSharp/PropertyTests.fs @@ -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() [] let ``Returning Task with exception fails`` () = assertShrunk (nameof ``Returning Task with exception fails, skipped``) "[11]"