@@ -10,6 +10,7 @@ module Dhall.Test.TH where
10
10
11
11
import Control.Exception (throwIO )
12
12
import Data.Either.Validation (Validation (.. ))
13
+ import Data.Time (TimeOfDay (.. ), TimeZone (.. ), fromGregorian )
13
14
import Dhall.TH (HaskellType (.. ))
14
15
import Test.Tasty (TestTree )
15
16
@@ -27,6 +28,7 @@ deriving instance Show T
27
28
Dhall.TH. makeHaskellTypes
28
29
[ MultipleConstructors " Department" " ./tests/th/Department.dhall"
29
30
, SingleConstructor " Employee" " MakeEmployee" " ./tests/th/Employee.dhall"
31
+ , SingleConstructor " TimeExample" " TimeExample" " ./tests/th/Time.dhall"
30
32
]
31
33
32
34
deriving instance Eq Department
@@ -35,6 +37,9 @@ deriving instance Show Department
35
37
deriving instance Eq Employee
36
38
deriving instance Show Employee
37
39
40
+ deriving instance Eq TimeExample
41
+ deriving instance Show TimeExample
42
+
38
43
Dhall.TH. makeHaskellTypes
39
44
[ SingleConstructor " Bar" " MakeBar" " (./tests/th/issue2066.dhall).Bar"
40
45
, SingleConstructor " Foo" " MakeFoo" " (./tests/th/issue2066.dhall).Foo"
@@ -75,6 +80,16 @@ makeHaskellTypeFromUnion = Tasty.HUnit.testCase "makeHaskellTypeFromUnion" $ do
75
80
76
81
Tasty.HUnit. assertEqual " " qux (Foo MakeFoo { foo = 2 , bar = MakeBar { baz = 3 } })
77
82
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
+
78
93
Dhall.TH. makeHaskellTypesWith (Dhall.TH. defaultGenerateOptions
79
94
{ Dhall.TH. constructorModifier = (" My" <> )
80
95
, Dhall.TH. fieldModifier = (" my" <> ) . Data.Text. toTitle
0 commit comments