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
|
{-# LANGUAGE DeriveDataTypeable #-}
module Labels (tests) where
-- This module tests availability of field labels.
import Test.Tasty.HUnit
import Data.Generics
-- A datatype without labels
data NoLabels = NoLabels Int Double
deriving (Typeable, Data)
-- A datatype with labels
data YesLabels = YesLabels { myint :: Int
, myfloat :: Double
}
deriving (Typeable, Data)
-- Test terms
noLabels = NoLabels 42 3.14
yesLabels = YesLabels 42 3.14
-- Main function for testing
tests = ( constrFields $ toConstr noLabels
, constrFields $ toConstr yesLabels
) @=? output
output = ([],["myint","myfloat"])
|