aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/unit_test
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/unit_test')
-rw-r--r--bootstrap/unit_test/ModuleSourceConstructionTest.hs83
-rw-r--r--bootstrap/unit_test/ModuleToCompileInfoTest.hs73
-rw-r--r--bootstrap/unit_test/ProgramSourceConstructionTest.hs69
-rw-r--r--bootstrap/unit_test/ProgramToCompileInfoTest.hs71
-rw-r--r--bootstrap/unit_test/SubmoduleSourceConstructionTest.hs79
-rw-r--r--bootstrap/unit_test/SubmoduleToCompileInfoTest.hs78
-rw-r--r--bootstrap/unit_test/Trimmer.hs1
7 files changed, 0 insertions, 454 deletions
diff --git a/bootstrap/unit_test/ModuleSourceConstructionTest.hs b/bootstrap/unit_test/ModuleSourceConstructionTest.hs
deleted file mode 100644
index b98e9d3..0000000
--- a/bootstrap/unit_test/ModuleSourceConstructionTest.hs
+++ /dev/null
@@ -1,83 +0,0 @@
-module ModuleSourceConstructionTest
- ( test
- )
-where
-
-import BuildModel ( RawSource(..)
- , Source(..)
- , processRawSource
- )
-import Hedge ( Result
- , Test
- , assertEquals
- , assertThat
- , fail'
- , 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
- , then' "its source file name is the same as the original"
- checkModuleSourceFileName
- , then'
- "its object file name is the 'flattened' path of the source file with '.o' appeneded"
- checkModuleObjectFileName
- , then' "it knows what modules it uses directly" checkModuleModulesUsed
- , then' "it knows its name" checkModuleName
- , then' "it can tell that it will produce a '.smod' file" checkSmod
- ]
- ]
-
-exampleModule :: RawSource
-exampleModule = RawSource moduleSourceFileName' $ unlines
- [ "module some_module"
- , " use module1"
- , " USE MODULE2"
- , " implicit none"
- , " interface"
- , " pure module function some_func()"
- , " integer :: some_func"
- , " end function"
- , " end interface"
- , "end module"
- ]
-
-moduleSourceFileName' :: String
-moduleSourceFileName' = "some" </> "file" </> "somewhere.f90"
-
-checkIsModule :: Source -> Result
-checkIsModule Module{} = assertThat True
-checkIsModule _ = assertThat False
-
-checkModuleSourceFileName :: Source -> Result
-checkModuleSourceFileName m@(Module{}) =
- assertEquals moduleSourceFileName' $ moduleSourceFileName m
-checkModuleSourceFileName _ = fail' "wasn't a Module"
-
-checkModuleObjectFileName :: Source -> Result
-checkModuleObjectFileName m@(Module{}) =
- assertEquals ("." </> "some_file_somewhere.f90.o")
- $ (moduleObjectFileName m) "."
-checkModuleObjectFileName _ = fail' "wasn't a Module"
-
-checkModuleModulesUsed :: Source -> Result
-checkModuleModulesUsed m@(Module{}) =
- assertEquals ["module1", "module2"] $ moduleModulesUsed m
-checkModuleModulesUsed _ = fail' "wasn't a Module"
-
-checkModuleName :: Source -> Result
-checkModuleName m@(Module{}) = assertEquals "some_module" $ moduleName m
-checkModuleName _ = fail' "wasn't a Module"
-
-checkSmod :: Source -> Result
-checkSmod m@(Module{}) = assertThat $ moduleProducesSmod m
-checkSmod _ = fail' "wasn't a Module"
diff --git a/bootstrap/unit_test/ModuleToCompileInfoTest.hs b/bootstrap/unit_test/ModuleToCompileInfoTest.hs
deleted file mode 100644
index 08cd67c..0000000
--- a/bootstrap/unit_test/ModuleToCompileInfoTest.hs
+++ /dev/null
@@ -1,73 +0,0 @@
-module ModuleToCompileInfoTest
- ( test
- )
-where
-
-import BuildModel ( AvailableModule(..)
- , CompileTimeInfo(..)
- , Source(..)
- , constructCompileTimeInfo
- )
-import Hedge ( Result
- , Test
- , assertEquals
- , givenInput
- , then'
- , whenTransformed
- )
-import System.FilePath ( (</>) )
-
-test :: IO (Test ())
-test = return $ givenInput
- "a module and available modules"
- (exampleModule, availableModules)
- [ whenTransformed
- "its compileTimeInfo is determined"
- doCompileTimeTransformation
- [ then' "it stil knows the original source file" checkSourceFileName
- , then' "it knows what object file will be produced" checkObjectFileName
- , then' "the mod and smod files are also produced" checkOtherFilesProduced
- , then' "the direct dependencies are only the available modules used"
- checkDirectDependencies
- ]
- ]
-
-exampleModule :: Source
-exampleModule = Module
- { moduleSourceFileName = moduleSourceFileName'
- , moduleObjectFileName = \bd -> bd </> "some_file_somewhere.f90.o"
- , moduleModulesUsed = ["module1", "module2", "module3"]
- , moduleName = "some_module"
- , moduleProducesSmod = True
- }
-
-moduleSourceFileName' :: FilePath
-moduleSourceFileName' = "some" </> "file" </> "somewhere.f90"
-
-availableModules :: [AvailableModule]
-availableModules = [ AvailableModule {availableModuleName = "module1", availableModuleFile = "build_dir" </> "module1.mod"}
- , AvailableModule {availableModuleName = "module3", availableModuleFile = "build_dir" </> "module3.mod"}
- ]
-
-doCompileTimeTransformation :: (Source, [AvailableModule]) -> CompileTimeInfo
-doCompileTimeTransformation (programSource, otherSources) =
- constructCompileTimeInfo programSource otherSources "build_dir"
-
-checkSourceFileName :: CompileTimeInfo -> Result
-checkSourceFileName cti =
- assertEquals moduleSourceFileName' (compileTimeInfoSourceFileName cti)
-
-checkObjectFileName :: CompileTimeInfo -> Result
-checkObjectFileName cti = assertEquals
- ("build_dir" </> "some_file_somewhere.f90.o")
- (compileTimeInfoObjectFileProduced cti)
-
-checkOtherFilesProduced :: CompileTimeInfo -> Result
-checkOtherFilesProduced cti = assertEquals
- ["build_dir" </> "some_module.mod", "build_dir" </> "some_module.smod"]
- (compileTimeInfoOtherFilesProduced cti)
-
-checkDirectDependencies :: CompileTimeInfo -> Result
-checkDirectDependencies cti = assertEquals
- ["build_dir" </> "module1.mod", "build_dir" </> "module3.mod"]
- (compileTimeInfoDirectDependencies cti)
diff --git a/bootstrap/unit_test/ProgramSourceConstructionTest.hs b/bootstrap/unit_test/ProgramSourceConstructionTest.hs
deleted file mode 100644
index 6369965..0000000
--- a/bootstrap/unit_test/ProgramSourceConstructionTest.hs
+++ /dev/null
@@ -1,69 +0,0 @@
-module ProgramSourceConstructionTest
- ( test
- )
-where
-
-import BuildModel ( RawSource(..)
- , Source(..)
- , processRawSource
- )
-import Hedge ( Result
- , Test
- , assertEquals
- , assertThat
- , fail'
- , givenInput
- , then'
- , whenTransformed
- )
-import System.FilePath ( (</>) )
-
-test :: IO (Test ())
-test = return $ givenInput
- "a program"
- exampleProgram
- [ whenTransformed
- "processed to a source"
- processRawSource
- [ then' "it is a Program" checkIsProgram
- , then' "its source file name is the same as the original"
- checkProgramSourceFileName
- , then'
- "its object file name is the 'flattened' path of the source file with '.o' appended"
- checkProgramObjectFileName
- , then' "it knows what modules it uses directly" checkProgramModulesUsed
- ]
- ]
-
-exampleProgram :: RawSource
-exampleProgram = RawSource programSourceFileName' $ unlines
- [ "program some_program"
- , " use module1"
- , " USE MODULE2"
- , " implicit none"
- , " print *, \"Hello, World!\""
- , "end program"
- ]
-
-programSourceFileName' :: String
-programSourceFileName' = "some" </> "file" </> "somewhere.f90"
-
-checkIsProgram :: Source -> Result
-checkIsProgram Program{} = assertThat True
-checkIsProgram _ = assertThat False
-
-checkProgramSourceFileName :: Source -> Result
-checkProgramSourceFileName p@(Program{}) =
- assertEquals programSourceFileName' $ programSourceFileName p
-checkProgramSourceFileName _ = fail' "wasn't a Program"
-
-checkProgramObjectFileName :: Source -> Result
-checkProgramObjectFileName p@(Program{}) =
- assertEquals ("." </> "some_file_somewhere.f90.o")
- $ (programObjectFileName p) "."
-checkProgramObjectFileName _ = fail' "wasn't a Program"
-
-checkProgramModulesUsed :: Source -> Result
-checkProgramModulesUsed p@(Program{}) =
- assertEquals ["module1", "module2"] $ programModulesUsed p
-checkProgramModulesUsed _ = fail' "wasn't a Program"
diff --git a/bootstrap/unit_test/ProgramToCompileInfoTest.hs b/bootstrap/unit_test/ProgramToCompileInfoTest.hs
deleted file mode 100644
index a9ad39b..0000000
--- a/bootstrap/unit_test/ProgramToCompileInfoTest.hs
+++ /dev/null
@@ -1,71 +0,0 @@
-module ProgramToCompileInfoTest
- ( test
- )
-where
-
-import BuildModel ( AvailableModule(..)
- , CompileTimeInfo(..)
- , Source(..)
- , constructCompileTimeInfo
- )
-import Hedge ( Result
- , Test
- , assertEmpty
- , assertEquals
- , givenInput
- , then'
- , whenTransformed
- )
-import System.FilePath ( (</>) )
-
-test :: IO (Test ())
-test = return $ givenInput
- "a program and available modules"
- (exampleProgram, availableModules)
- [ whenTransformed
- "its compileTimeInfo is determined"
- doCompileTimeTransformation
- [ then' "it still knows the original source file" checkSourceFileName
- , then' "it knows what object file will be produced" checkObjectFileName
- , then' "there are no other files produced" checkOtherFilesProduced
- , then' "the direct dependencies are only the available modules used"
- checkDirectDependencies
- ]
- ]
-
-exampleProgram :: Source
-exampleProgram = Program
- { programSourceFileName = programSourceFileName'
- , programObjectFileName = \bd -> bd </> "some_file_somewhere.f90.o"
- , programModulesUsed = ["module1", "module2", "module3"]
- }
-
-programSourceFileName' :: FilePath
-programSourceFileName' = "some" </> "file" </> "somewhere.f90"
-
-availableModules :: [AvailableModule]
-availableModules = [ AvailableModule {availableModuleName = "module1", availableModuleFile = "build_dir" </> "module1.mod"}
- , AvailableModule {availableModuleName = "module3", availableModuleFile = "build_dir" </> "module3.mod"}
- ]
-
-doCompileTimeTransformation :: (Source, [AvailableModule]) -> CompileTimeInfo
-doCompileTimeTransformation (programSource, otherSources) =
- constructCompileTimeInfo programSource otherSources "build_dir"
-
-checkSourceFileName :: CompileTimeInfo -> Result
-checkSourceFileName cti =
- assertEquals programSourceFileName' (compileTimeInfoSourceFileName cti)
-
-checkObjectFileName :: CompileTimeInfo -> Result
-checkObjectFileName cti = assertEquals
- ("build_dir" </> "some_file_somewhere.f90.o")
- (compileTimeInfoObjectFileProduced cti)
-
-checkOtherFilesProduced :: CompileTimeInfo -> Result
-checkOtherFilesProduced cti =
- assertEmpty (compileTimeInfoOtherFilesProduced cti)
-
-checkDirectDependencies :: CompileTimeInfo -> Result
-checkDirectDependencies cti = assertEquals
- ["build_dir" </> "module1.mod", "build_dir" </> "module3.mod"]
- (compileTimeInfoDirectDependencies cti)
diff --git a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs b/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs
deleted file mode 100644
index d07a6ed..0000000
--- a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs
+++ /dev/null
@@ -1,79 +0,0 @@
-module SubmoduleSourceConstructionTest
- ( test
- )
-where
-
-import BuildModel ( RawSource(..)
- , Source(..)
- , processRawSource
- )
-import Hedge ( Result
- , Test
- , assertEquals
- , assertThat
- , fail'
- , givenInput
- , then'
- , whenTransformed
- )
-import System.FilePath ( (</>) )
-
-test :: IO (Test ())
-test = return $ givenInput
- "a submodule"
- exampleSubmodule
- [ whenTransformed
- "processed to a source"
- processRawSource
- [ then' "it is a Submodule" checkIsSubmodule
- , then' "its source file name is the same as the original"
- checkSubmoduleSourceFileName
- , then'
- "its object file name is the 'flattened' path of the source file with '.o' appeneded"
- checkSubmoduleObjectFileName
- , then' "it knows what modules it uses directly" checkSubmoduleModulesUsed
- , then' "it knows its parent's name" checkSubmoduleParentName
- , then' "it knows its name" checkSubmoduleName
- ]
- ]
-
-exampleSubmodule :: RawSource
-exampleSubmodule = RawSource submoduleSourceFileName' $ unlines
- [ "submodule (some_module:parent) child"
- , " use module1"
- , " USE MODULE2"
- , " implicit none"
- , "end submodule"
- ]
-
-submoduleSourceFileName' :: String
-submoduleSourceFileName' = "some" </> "file" </> "somewhere.f90"
-
-checkIsSubmodule :: Source -> Result
-checkIsSubmodule Submodule{} = assertThat True
-checkIsSubmodule _ = assertThat False
-
-checkSubmoduleSourceFileName :: Source -> Result
-checkSubmoduleSourceFileName s@(Submodule{}) =
- assertEquals submoduleSourceFileName' $ submoduleSourceFileName s
-checkSubmoduleSourceFileName _ = fail' "wasn't a Submodule"
-
-checkSubmoduleObjectFileName :: Source -> Result
-checkSubmoduleObjectFileName s@(Submodule{}) =
- assertEquals ("." </> "some_file_somewhere.f90.o")
- $ (submoduleObjectFileName s) "."
-checkSubmoduleObjectFileName _ = fail' "wasn't a Submodule"
-
-checkSubmoduleModulesUsed :: Source -> Result
-checkSubmoduleModulesUsed s@(Submodule{}) =
- assertEquals ["module1", "module2"] $ submoduleModulesUsed s
-checkSubmoduleModulesUsed _ = fail' "wasn't a Submodule"
-
-checkSubmoduleParentName :: Source -> Result
-checkSubmoduleParentName s@(Submodule{}) =
- assertEquals "some_module@parent" (submoduleParentName s)
-checkSubmoduleParentName _ = fail' "wasn't a Submodule"
-
-checkSubmoduleName :: Source -> Result
-checkSubmoduleName s@(Submodule{}) = assertEquals "child" $ submoduleName s
-checkSubmoduleName _ = fail' "wasn't a Submodule"
diff --git a/bootstrap/unit_test/SubmoduleToCompileInfoTest.hs b/bootstrap/unit_test/SubmoduleToCompileInfoTest.hs
deleted file mode 100644
index 621b0d5..0000000
--- a/bootstrap/unit_test/SubmoduleToCompileInfoTest.hs
+++ /dev/null
@@ -1,78 +0,0 @@
-module SubmoduleToCompileInfoTest
- ( test
- )
-where
-
-import BuildModel ( AvailableModule(..)
- , CompileTimeInfo(..)
- , Source(..)
- , constructCompileTimeInfo
- )
-import Hedge ( Result
- , Test
- , assertEquals
- , givenInput
- , then'
- , whenTransformed
- )
-import System.FilePath ( (</>) )
-
-test :: IO (Test ())
-test = return $ givenInput
- "a submodule and available modules"
- (exampleSubmodule, availableModules)
- [ whenTransformed
- "its compileTimeInfo is determined"
- doCompileTimeTransformation
- [ then' "it still knows the original source file" checkSourceFileName
- , then' "it knows what object file will be produced" checkObjectFileName
- , then' "the smod file is also produced" checkOtherFilesProduced
- , then'
- "the direct dependencies are the parent smod and the available modules used"
- checkDirectDependencies
- ]
- ]
-
-exampleSubmodule :: Source
-exampleSubmodule = Submodule
- { submoduleSourceFileName = submoduleSourceFileName'
- , submoduleObjectFileName = \bd -> bd </> "some_file_somewhere.f90.o"
- , submoduleModulesUsed = ["module1", "module2", "module3"]
- , submoduleBaseModuleName = "base_module"
- , submoduleParentName = "base_module@parent"
- , submoduleName = "some_submodule"
- }
-
-submoduleSourceFileName' :: FilePath
-submoduleSourceFileName' = "some" </> "file" </> "somewhere.f90"
-
-availableModules :: [AvailableModule]
-availableModules = [ AvailableModule {availableModuleName = "module1", availableModuleFile = "build_dir" </> "module1.mod"}
- , AvailableModule {availableModuleName = "module3", availableModuleFile = "build_dir" </> "module3.mod"}
- ]
-
-doCompileTimeTransformation :: (Source, [AvailableModule]) -> CompileTimeInfo
-doCompileTimeTransformation (programSource, otherSources) =
- constructCompileTimeInfo programSource otherSources "build_dir"
-
-checkSourceFileName :: CompileTimeInfo -> Result
-checkSourceFileName cti =
- assertEquals submoduleSourceFileName' (compileTimeInfoSourceFileName cti)
-
-checkObjectFileName :: CompileTimeInfo -> Result
-checkObjectFileName cti = assertEquals
- ("build_dir" </> "some_file_somewhere.f90.o")
- (compileTimeInfoObjectFileProduced cti)
-
-checkOtherFilesProduced :: CompileTimeInfo -> Result
-checkOtherFilesProduced cti = assertEquals
- ["build_dir" </> "base_module@some_submodule.smod"]
- (compileTimeInfoOtherFilesProduced cti)
-
-checkDirectDependencies :: CompileTimeInfo -> Result
-checkDirectDependencies cti = assertEquals
- [ "build_dir" </> "base_module@parent.smod"
- , "build_dir" </> "module1.mod"
- , "build_dir" </> "module3.mod"
- ]
- (compileTimeInfoDirectDependencies cti)
diff --git a/bootstrap/unit_test/Trimmer.hs b/bootstrap/unit_test/Trimmer.hs
deleted file mode 100644
index 4e0f91d..0000000
--- a/bootstrap/unit_test/Trimmer.hs
+++ /dev/null
@@ -1 +0,0 @@
-{-# OPTIONS_GHC -F -pgmF hedge-trimmer #-}