Skip to content

Commit

Permalink
head element after sort is min element
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 29, 2015
1 parent 4c97a1c commit 819d3d0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/fsharp/FSharp.Core.PropertyTests/ListProperties.fs
Original file line number Diff line number Diff line change
@@ -184,15 +184,27 @@ let ``list isEmpty if and only if length is 0`` () =
Check.QuickThrowOnFailure length_and_isEmpty<string>
Check.QuickThrowOnFailure length_and_isEmpty<NormalFloat>

let min_and_max<'a when 'a : comparison> (xs : list<int>) =
let min_and_max (xs : list<int>) =
let a = run (fun () -> List.min xs)
let b = run (fun () -> xs |> List.map ((*) -1) |> List.max |> fun x -> -x)

a = b

[<Test>]
let ``min is opposite of max`` () =
Check.QuickThrowOnFailure min_and_max<int>
Check.QuickThrowOnFailure min_and_max

let min_and_sort<'a when 'a : comparison> (xs : list<'a>) =
let a = runAndCheckErrorType (fun () -> List.min xs)
let b = runAndCheckErrorType (fun () -> xs |> List.sort |> List.head)

a = b

[<Test>]
let ``head element after sort is min element`` () =
Check.QuickThrowOnFailure min_and_sort<int>
Check.QuickThrowOnFailure min_and_sort<string>
Check.QuickThrowOnFailure min_and_sort<NormalFloat>

let mapi_and_map<'a when 'a : comparison> (xs : list<'a>) f =
let indices = System.Collections.Generic.List<int>()

0 comments on commit 819d3d0

Please sign in to comment.