Skip to content

Commit

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

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

[<Test>]
let ``indexed is consistent`` () =
Check.QuickThrowOnFailure indexed<int>
Check.QuickThrowOnFailure indexed<string>
Check.QuickThrowOnFailure indexed<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 7f1900f

Please sign in to comment.