Skip to content

Commit

Permalink
Merge pull request #281 from Thorium/minor-cleanup
Browse files Browse the repository at this point in the history
Minor code clean-up
  • Loading branch information
CaptnCodr authored Sep 13, 2024
2 parents a76a170 + 9c5bc03 commit d18a6f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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())

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/FsUnit.Xunit/CustomMatchers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d18a6f4

Please sign in to comment.