diff options
-rw-r--r-- | bootstrap/src/BuildModel.hs | 4 | ||||
-rw-r--r-- | bootstrap/unit_test/SubmoduleSourceConstructionTest.hs | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs index f784624..9a9866a 100644 --- a/bootstrap/src/BuildModel.hs +++ b/bootstrap/src/BuildModel.hs @@ -52,6 +52,8 @@ data Source = , moduleProducesSmod :: Bool } | Submodule + { submoduleSourceFileName :: FilePath + } processRawSource :: RawSource -> Source processRawSource rawSource = @@ -74,7 +76,7 @@ processRawSource rawSource = , moduleProducesSmod = hasModuleSubprogramDeclaration parsedContents } else if hasSubmoduleDeclaration parsedContents - then Submodule + then Submodule { submoduleSourceFileName = sourceFileName } else undefined pathSeparatorsToUnderscores :: FilePath -> FilePath diff --git a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs b/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs index 96492fb..6158939 100644 --- a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs +++ b/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs @@ -9,7 +9,9 @@ import BuildModel ( RawSource(..) ) import Hedge ( Result , Test + , assertEquals , assertThat + , fail' , givenInput , then' , whenTransformed @@ -20,9 +22,13 @@ test :: IO (Test ()) test = return $ givenInput "a submodule" exampleSubmodule - [ whenTransformed "processed to a source" - processRawSource - [then' "it is a Submodule" checkIsSubmodule] + [ whenTransformed + "processed to a source" + processRawSource + [ then' "it is a Submodule" checkIsSubmodule + , then' "its source file name is the same as the original" + checkSubmoduleSourceFileName + ] ] exampleSubmodule :: RawSource @@ -35,3 +41,8 @@ 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" |