-
Notifications
You must be signed in to change notification settings - Fork 294
/
LargeNumberTest.hs
52 lines (46 loc) · 1.18 KB
/
LargeNumberTest.hs
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
module LargeNumberTest where
import Init
import Data.Word
#ifdef WITH_MONGODB
mkPersist persistSettings [persist|
#else
share [mkPersist sqlSettings, mkMigrate "numberMigrate"] [persist|
#endif
Number
intx Int
int32 Int32
word32 Word32
int64 Int64
word64 Word64
|]
#ifdef WITH_MONGODB
db = db' cleanDB
cleanDB :: PersistQuery b m => b m ()
cleanDB = do
deleteWhere ([] :: [Filter Number])
#endif
specs :: Specs
specs = describe "persistent" $ do
it "large numbers" $ db $ do
let go x = do
xid <- insert x
x' <- get xid
liftIO $ x' @?= Just x
go $ Number maxBound 0 0 0 0
go $ Number 0 maxBound 0 0 0
go $ Number 0 0 maxBound 0 0
go $ Number 0 0 0 maxBound 0
go $ Number 0 0 0 0 maxBound
go $ Number minBound 0 0 0 0
go $ Number 0 minBound 0 0 0
go $ Number 0 0 minBound 0 0
go $ Number 0 0 0 minBound 0
go $ Number 0 0 0 0 minBound