Skip to content

Commit

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

let init<'a when 'a : equality> count f =
let s = run (fun () -> Seq.init count f |> Seq.toArray)
let l = run (fun () -> List.init count f |> Seq.toArray)
let a = run (fun () -> Array.init count f)
s = a && l = a

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

let item<'a when 'a : equality> (xs : 'a []) index =
let s = runAndCheckIfAnyError (fun () -> xs |> Seq.item index)
let l = runAndCheckIfAnyError (fun () -> xs |> List.ofArray |> List.item index)
Expand Down

0 comments on commit d3cf7b5

Please sign in to comment.