0 | module Evince.Async.Spec
 1 |
 2 | import Language.Reflection
 3 | import Language.Reflection.TTImp
 4 | import IO.Async
 5 | import Evince.Core
 6 |
 7 | %language ElabReflection
 8 |
 9 | ||| Define a test case with an `Async` body, so the test can spawn
10 | ||| fibers, await, and use the full async toolkit.
11 | export
12 | itAsync : String -> Async e [] (TestResult ()) -> Spec (Async e []) a ()
13 | itAsync label action = MkSpec [< It label Nothing (\_ => action)] ()
14 |
15 | ||| Define an `Async` test case that receives the group's resource.
16 | export
17 | itAsyncWith : String -> (a -> Async e [] (TestResult ())) -> Spec (Async e []) a ()
18 | itAsyncWith label f = MkSpec [< It label Nothing f] ()
19 |
20 | ||| Mark an `Async` test as pending - the body is ignored and not executed.
21 | export
22 | xitAsync : String -> Lazy (Async e [] (TestResult ())) -> Spec (Async e []) a ()
23 | xitAsync label _ = MkSpec [< Pending label Nothing] ()
24 |
25 | ||| Define an `Async` test with source location captured at the call site.
26 | |||   itAsyncLoc `(()) "test name" $ asyncAction
27 | export
28 | %macro
29 | itAsyncLoc : TTImp -> String -> Async e [] (TestResult ()) -> Elab (Spec (Async e []) a ())
30 | itAsyncLoc t label action =
31 |   pure $ MkSpec [< It label (Just (fcToSrcLoc (getFC t))) (\_ => action)] ()
32 |