diff options
Diffstat (limited to 'bootstrap')
-rw-r--r-- | bootstrap/src/BuildModel.hs | 2 | ||||
-rw-r--r-- | bootstrap/unit_test/SubmoduleSourceConstructionTest.hs | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs index 70046d7..db00e0d 100644 --- a/bootstrap/src/BuildModel.hs +++ b/bootstrap/src/BuildModel.hs @@ -54,6 +54,7 @@ data Source = | Submodule { submoduleSourceFileName :: FilePath , submoduleObjectFileName :: FilePath -> FilePath + , submoduleModulesUsed :: [String] } processRawSource :: RawSource -> Source @@ -79,6 +80,7 @@ processRawSource rawSource = else if hasSubmoduleDeclaration parsedContents then Submodule { submoduleSourceFileName = sourceFileName , submoduleObjectFileName = objectFileName + , submoduleModulesUsed = modulesUsed } else undefined diff --git a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs b/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs index 5295a97..956d782 100644 --- a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs +++ b/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs @@ -31,12 +31,18 @@ test = return $ givenInput , 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 ] ] exampleSubmodule :: RawSource -exampleSubmodule = RawSource submoduleSourceFileName' - $ unlines ["submodule (some_module:parent) child", "end submodule"] +exampleSubmodule = RawSource submoduleSourceFileName' $ unlines + [ "submodule (some_module:parent) child" + , " use module1" + , " USE MODULE2" + , " implicit none" + , "end submodule" + ] submoduleSourceFileName' :: String submoduleSourceFileName' = "some" </> "file" </> "somewhere.f90" @@ -55,3 +61,8 @@ 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" |