aboutsummaryrefslogtreecommitdiff
path: root/spec/test/Thermoprint/PrintoutSpec.hs
blob: 7ba365624939527859b2d9b3be248a3d915f3ec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE StandaloneDeriving #-}

module Thermoprint.PrintoutSpec (spec) where

import Test.Hspec
import Test.Hspec.QuickCheck (prop)
import Thermoprint.Printout

import Data.Aeson (fromJSON, ToJSON(..), Result(..))
import Data.Function (on)

-- Equality via cotext on Block
instance Eq Block where
  (==) = (==) `on` cotext
-- Structural equality for Chunk 
deriving instance Eq Chunk

spec :: Spec
spec = do
  prop "prop_text" prop_text
  parallel $ prop "json" prop_json
  where
    prop_json :: Printout -> Bool
    prop_json p = (== Success p) . fromJSON . toJSON $ p