File: DocsSpec.hs

package info (click to toggle)
haskell-getopt-generics 0.13.1.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 260 kB
  • sloc: haskell: 1,644; makefile: 6
file content (52 lines) | stat: -rw-r--r-- 1,164 bytes parent folder | download | duplicates (4)
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 CPP #-}

module DocsSpec where

import           Prelude ()
import           Prelude.Compat

import           Control.Monad
import           System.FilePath
import           Test.Hspec

import           ShellProtocol

import qualified Test01
import qualified CustomOption
import qualified Simple
#if MIN_VERSION_base(4,8,0)
import qualified Test02
import qualified Test03
import qualified Test04
import qualified RecordType
import qualified CustomOptionRecord
#endif

examples :: [(IO (), String)]
examples =
  (Test01.main, "Test01") :
  (CustomOption.main, "CustomOption") :
  (Simple.main, "Simple") :
#if MIN_VERSION_base(4,8,0)
  (Test02.main, "Test02") :
  (Test03.main, "Test03") :
  (Test04.main, "Test04") :
  (RecordType.main, "RecordType") :
  (CustomOptionRecord.main, "CustomOptionRecord") :
#endif
  []

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
  describe "shell protocols" $ do
    forM_ examples $ \ (program, name) ->
      it name $ do
        test program name

test :: IO () -> String -> IO ()
test program name = do
  protocol <- readFile ("docs" </> name <.> "shell-protocol")
  testShellProtocol program protocol