Skip to content

Commit

Permalink
tryHead is consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent 38b6406 commit 8476b22
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1066,3 +1066,15 @@ let ``tryFindIndexBack is consistent`` () =
Check.QuickThrowOnFailure tryFindIndexBack<int>
Check.QuickThrowOnFailure tryFindIndexBack<string>
Check.QuickThrowOnFailure tryFindIndexBack<NormalFloat>

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

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

0 comments on commit 8476b22

Please sign in to comment.