@@ -353,11 +353,20 @@ module NonEmptyListTests =
353353
354354 testPropertyWithConfig
355355 config10k
356- " sortBy produces sorted output"
356+ " sortBy with identity projection produces ascending sorted output"
357357 ( Prop.forAll( neListOfInt())
358358 <| fun nel ->
359359 let sorted = NonEmptyList.sortBy id nel |> NonEmptyList.toList
360- let expected = nel |> NonEmptyList.toList |> List.sort
360+ let expected = nel |> NonEmptyList.toList |> List.sortBy id
361+ sorted = expected)
362+
363+ testPropertyWithConfig
364+ config10k
365+ " sortBy with negation projection produces descending sorted output"
366+ ( Prop.forAll( neListOfInt())
367+ <| fun nel ->
368+ let sorted = NonEmptyList.sortBy ( fun x -> - x) nel |> NonEmptyList.toList
369+ let expected = nel |> NonEmptyList.toList |> List.sortBy ( fun x -> - x)
361370 sorted = expected)
362371
363372 testPropertyWithConfig
@@ -371,12 +380,24 @@ module NonEmptyListTests =
371380
372381 testPropertyWithConfig
373382 config10k
374- " maxBy returns maximum element"
383+ " maxBy with identity projection returns maximum element"
375384 ( Prop.forAll( neListOfInt())
376385 <| fun nel -> NonEmptyList.maxBy id nel = ( nel |> NonEmptyList.toList |> List.max))
377386
378387 testPropertyWithConfig
379388 config10k
380- " minBy returns minimum element"
389+ " maxBy with negation projection returns minimum element"
390+ ( Prop.forAll( neListOfInt())
391+ <| fun nel -> NonEmptyList.maxBy ( fun x -> - x) nel = ( nel |> NonEmptyList.toList |> List.min))
392+
393+ testPropertyWithConfig
394+ config10k
395+ " minBy with identity projection returns minimum element"
396+ ( Prop.forAll( neListOfInt())
397+ <| fun nel -> NonEmptyList.minBy id nel = ( nel |> NonEmptyList.toList |> List.min))
398+
399+ testPropertyWithConfig
400+ config10k
401+ " minBy with negation projection returns maximum element"
381402 ( Prop.forAll( neListOfInt())
382- <| fun nel -> NonEmptyList.minBy id nel = ( nel |> NonEmptyList.toList |> List.min )) ]
403+ <| fun nel -> NonEmptyList.minBy ( fun x -> - x ) nel = ( nel |> NonEmptyList.toList |> List.max )) ]
0 commit comments