Skip to content

Commit

Permalink
filter is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent 3d002fa commit 82291c5
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ let sort<'a when 'a : comparison> (xs : 'a []) =
let a = xs |> Array.sort
Seq.toArray s = a && List.toArray l = a

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

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

[<Test>]
let ``sort is consistent`` () =
Check.QuickThrowOnFailure sort<int>
Expand Down

0 comments on commit 82291c5

Please sign in to comment.