Skip to content

Commit

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

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

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

let min<'a when 'a : comparison> (xs : 'a []) =
let s = runAndCheckIfAnyError (fun () -> xs |> Seq.min)
Expand Down

0 comments on commit 3975155

Please sign in to comment.