@@ -10,6 +10,7 @@ module Dhall.Test.TH where
1010
1111import Control.Exception (throwIO )
1212import Data.Either.Validation (Validation (.. ))
13+ import Data.Time (TimeOfDay (.. ), TimeZone (.. ), fromGregorian )
1314import Dhall.TH (HaskellType (.. ))
1415import Test.Tasty (TestTree )
1516
@@ -27,6 +28,7 @@ deriving instance Show T
2728Dhall.TH. makeHaskellTypes
2829 [ MultipleConstructors " Department" " ./tests/th/Department.dhall"
2930 , SingleConstructor " Employee" " MakeEmployee" " ./tests/th/Employee.dhall"
31+ , SingleConstructor " TimeExample" " TimeExample" " ./tests/th/Time.dhall"
3032 ]
3133
3234deriving instance Eq Department
@@ -35,6 +37,9 @@ deriving instance Show Department
3537deriving instance Eq Employee
3638deriving instance Show Employee
3739
40+ deriving instance Eq TimeExample
41+ deriving instance Show TimeExample
42+
3843Dhall.TH. makeHaskellTypes
3944 [ SingleConstructor " Bar" " MakeBar" " (./tests/th/issue2066.dhall).Bar"
4045 , SingleConstructor " Foo" " MakeFoo" " (./tests/th/issue2066.dhall).Foo"
@@ -75,6 +80,16 @@ makeHaskellTypeFromUnion = Tasty.HUnit.testCase "makeHaskellTypeFromUnion" $ do
7580
7681 Tasty.HUnit. assertEqual " " qux (Foo MakeFoo { foo = 2 , bar = MakeBar { baz = 3 } })
7782
83+ timex <- Dhall. input Dhall. auto " let T = ./tests/th/Time.dhall in { txTime = 21:12:00, txDate = 1976-04-01, txTimeZone = +05:00 } : T"
84+
85+ Tasty.HUnit. assertEqual " " timex TimeExample { txTime = tod, txDate = day, txTimeZone = tz}
86+
87+ where
88+ tod = TimeOfDay { todHour = 21 , todMin = 12 , todSec = 0 }
89+ day = fromGregorian 1976 4 1
90+ tz = TimeZone { timeZoneMinutes = 300 , timeZoneSummerOnly = False , timeZoneName = " " }
91+
92+
7893Dhall.TH. makeHaskellTypesWith (Dhall.TH. defaultGenerateOptions
7994 { Dhall.TH. constructorModifier = (" My" <> )
8095 , Dhall.TH. fieldModifier = (" my" <> ) . Data.Text. toTitle
0 commit comments