File: Labels.hs

package info (click to toggle)
haskell-syb 0.7.2.4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 356 kB
  • sloc: haskell: 2,264; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (3)
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"])