File: OrdSpec.hs

package info (click to toggle)
haskell-deriving-compat 0.6.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 492 kB
  • sloc: haskell: 6,121; makefile: 5
file content (41 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{-# LANGUAGE ScopedTypeVariables #-}

{-|
Module:      OrdSpec
Copyright:   (C) 2015-2017 Ryan Scott
License:     BSD-style (see the file LICENSE)
Maintainer:  Ryan Scott
Portability: Template Haskell

@hspec@ tests for derived 'Ord', 'Ord1', and 'Ord2' instances.
-}
module OrdSpec where

import Data.Functor.Classes

import Prelude ()
import Prelude.Compat

import Test.Hspec
import Test.Hspec.QuickCheck (prop)
import Test.QuickCheck (Arbitrary)

import Types.EqOrd ()

-------------------------------------------------------------------------------

prop_Ord :: (Ord a, Ord (f a), Ord1 f) => f a -> f a -> Expectation
prop_Ord x y = compare x y `shouldBe` compare1 x y

ordSpec :: forall proxy f a. (Arbitrary (f a), Show (f a),
                              Ord a, Ord (f a), Ord1 f)
        => proxy (f a) -> Spec
ordSpec _ = prop "has a valid Ord1 instance" (prop_Ord :: f a -> f a -> Expectation)

-------------------------------------------------------------------------------

main :: IO ()
main = hspec spec

spec :: Spec
spec = pure ()