aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/unit_test/ModuleSourceConstructionTest.hs
blob: cc6d079f1b148c9031c720b845ff674da06e989b (plain)
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
module ModuleSourceConstructionTest
  ( test
  )
where

import           BuildModel                     ( RawSource(..)
                                                , Source(..)
                                                , processRawSource
                                                )
import           Hedge                          ( Result
                                                , Test
                                                , assertThat
                                                , givenInput
                                                , then'
                                                , whenTransformed
                                                )
import           System.FilePath                ( (</>) )

test :: IO (Test ())
test = return $ givenInput
  "a module"
  exampleModule
  [ whenTransformed "processed to a source"
                    processRawSource
                    [then' "it is a Module" checkIsModule]
  ]

exampleModule :: RawSource
exampleModule =
  RawSource moduleSourceFileName' $ unlines ["module some_module", "end module"]

moduleSourceFileName' :: String
moduleSourceFileName' = "some" </> "file" </> "somewhere.f90"

checkIsModule :: Source -> Result
checkIsModule Module{} = assertThat True
checkIsModule _        = assertThat False