Skip to content

Commit

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

let replicate<'a when 'a : equality> x count =
let s = runAndCheckIfAnyError (fun () -> Seq.replicate count x |> Seq.toArray)
let l = runAndCheckIfAnyError (fun () -> List.replicate count x |> List.toArray)
let a = runAndCheckIfAnyError (fun () -> Array.replicate count x)
s = a && l = a

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

Please sign in to comment.