Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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