Skip to content

Commit

Permalink
minBy is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent 3975155 commit 5b91e1a
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,18 @@ let ``min is consistent`` () =
Check.QuickThrowOnFailure min<string>
Check.QuickThrowOnFailure min<NormalFloat>

let minBy<'a when 'a : comparison> (xs : 'a []) f =
let s = runAndCheckIfAnyError (fun () -> xs |> Seq.minBy f)
let l = runAndCheckIfAnyError (fun () -> xs |> List.ofArray |> List.minBy f)
let a = runAndCheckIfAnyError (fun () -> xs |> Array.minBy f)
s = a && l = a

[<Test>]
let ``minBy is consistent`` () =
Check.QuickThrowOnFailure minBy<int>
Check.QuickThrowOnFailure minBy<string>
Check.QuickThrowOnFailure minBy<NormalFloat>

let sort<'a when 'a : comparison> (xs : 'a []) =
let s = xs |> Seq.sort
let l = xs |> List.ofArray |> List.sort
Expand Down

0 comments on commit 5b91e1a

Please sign in to comment.