diff --git a/src/Common.fs b/src/Common.fs index bc1c7f96..a4835e8c 100644 --- a/src/Common.fs +++ b/src/Common.fs @@ -6,7 +6,7 @@ module Common = open Microsoft.FSharp.Reflection let isUnionCase x = - FSharpType.IsUnion(<@ x @>.Type) |> not && (box x) = null + FSharpType.IsUnion(<@ x @>.Type) |> not && isNull(box x) || FSharpType.IsUnion(x.GetType()) /// diff --git a/src/FsUnit.Xunit/CustomMatchers.fs b/src/FsUnit.Xunit/CustomMatchers.fs index 760cfbe3..926f90eb 100644 --- a/src/FsUnit.Xunit/CustomMatchers.fs +++ b/src/FsUnit.Xunit/CustomMatchers.fs @@ -40,14 +40,14 @@ let equalWithin (tolerance: obj) (expected: obj) = let matches(actual: obj) = let parseValue(v: string) = match Double.TryParse(v, NumberStyles.Any, CultureInfo("en-US")) with - | true, x -> Some(x) - | false, _ -> None + | true, x -> ValueSome x + | false, _ -> ValueNone let actual = string actual |> parseValue let expect = string expected |> parseValue let tol = string tolerance |> parseValue - if [| actual; expect; tol |] |> Array.contains None |> not then + if [| actual; expect; tol |] |> Array.contains ValueNone |> not then abs(actual.Value - expect.Value) <= tol.Value else false