From 9c5bc0378e207fd68387d34f7f636e31605f76b5 Mon Sep 17 00:00:00 2001 From: Tuomas Hietanen Date: Mon, 15 Jul 2024 16:14:37 +0100 Subject: [PATCH] minor code clean-up --- src/Common.fs | 2 +- src/FsUnit.Xunit/CustomMatchers.fs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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