0 | module Test.Async.Spec.TestEnv
 1 |
 2 | import Data.Linear.Ref1
 3 | import Data.Nat
 4 | import Text.PrettyPrint.Bernardy
 5 |
 6 | %default total
 7 |
 8 | public export
 9 | record TestEnv where
10 |   [noHints]
11 |   constructor TE
12 |   depth    : IORef Nat
13 |   failures : IORef Nat
14 |   tests    : IORef Nat
15 |   useColor : Bool
16 |   layout   : LayoutOpts
17 |
18 | export
19 | LL80 : LayoutOpts
20 | LL80 = Opts 80
21 |
22 | export
23 | mkEnv : Lift1 World f => Bool -> f TestEnv
24 | mkEnv b = do
25 |   d <- newref Z
26 |   f <- newref Z
27 |   t <- newref Z
28 |   pure $ TE d f t b LL80
29 |
30 | parameters {auto te  : TestEnv}
31 |            {auto has : HasIO io}
32 |
33 |   export %inline
34 |   addFailure : io ()
35 |   addFailure = runIO $ casmod1 te.failures S
36 |
37 |   export %inline
38 |   addTest : io ()
39 |   addTest = runIO $ casmod1 te.tests S
40 |
41 |   export %inline
42 |   incDepth : io ()
43 |   incDepth = runIO $ casmod1 te.depth S
44 |   
45 |   export %inline
46 |   decDepth : io ()
47 |   decDepth = runIO $ casmod1 te.depth pred
48 |
49 | export
50 | renderDoc : (te : TestEnv) => Doc te.layout -> String
51 | renderDoc = render te.layout . indent 2
52 |