11module Records where
22
33import Prelude
4- import Data.Generic (class Generic , toSpine , GenericSpine (..))
54import Control.Monad.Eff.Console (log )
65import Test.Assert (assert' )
76
87newtype AstralKeys = AstralKeys { " 💡" :: Int , " 💢" :: Int }
98newtype LoneSurrogateKeys = LoneSurrogateKeys { " \xdf06 " :: Int , " \xd834 " :: Int }
109
11- derive instance genericAstralKeys :: Generic AstralKeys
12- derive instance genericLoneSurrogateKeys :: Generic LoneSurrogateKeys
13-
14- spineOf :: forall a . Generic a => a -> Unit -> GenericSpine
15- spineOf x _ = toSpine x
16-
1710testLoneSurrogateKeys =
1811 let
1912 expected = 5
@@ -40,27 +33,7 @@ testAstralKeys =
4033 case o." 💡" of
4134 x -> { " 💢" : x }
4235
43- testGenericLoneSurrogateKeys = do
44- let expected = SProd " Records.LoneSurrogateKeys"
45- [ \_ -> SRecord [ {recLabel: " \xd834 " , recValue: spineOf 1 }
46- , {recLabel: " \xdf06 " , recValue: spineOf 0 }
47- ]
48- ]
49- actual = toSpine (LoneSurrogateKeys { " \xdf06 " : 0 , " \xd834 " : 1 })
50- assert' (" generic lone surrogate keys: " <> show actual) (expected == actual)
51-
52- testGenericAstralKeys = do
53- let expected = SProd " Records.AstralKeys"
54- [ \_ -> SRecord [ {recLabel: " 💡" , recValue: spineOf 0 }
55- , {recLabel: " 💢" , recValue: spineOf 1 }
56- ]
57- ]
58- actual = toSpine (AstralKeys { " 💡" : 0 , " 💢" : 1 })
59- assert' (" generic astral keys: " <> show actual) (expected == actual)
60-
6136main = do
6237 testLoneSurrogateKeys
6338 testAstralKeys
64- testGenericLoneSurrogateKeys
65- testGenericAstralKeys
6639 log " Done"
0 commit comments