Skip to content

Commit

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

let sortDescending<'a when 'a : comparison> (xs : 'a []) =
let s = xs |> Seq.sortDescending
let l = xs |> List.ofArray |> List.sortDescending
let a = xs |> Array.sortDescending
Seq.toArray s = a && List.toArray l = a

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

let splitInto<'a when 'a : equality> (xs : 'a []) count =
let s = run (fun () -> xs |> Seq.splitInto count |> Seq.map Seq.toArray |> Seq.toArray)
let l = run (fun () -> xs |> List.ofArray |> List.splitInto count |> Seq.map Seq.toArray |> Seq.toArray)
Expand Down

0 comments on commit 8124099

Please sign in to comment.