From 84884be16503e506cd5ad7f927297fd7d25de779 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Thu, 15 Oct 2020 10:28:02 -0500 Subject: Add test for module object file name --- bootstrap/src/BuildModel.hs | 21 ++++++++++----------- bootstrap/unit_test/ModuleSourceConstructionTest.hs | 9 +++++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs index 043173f..6446a12 100644 --- a/bootstrap/src/BuildModel.hs +++ b/bootstrap/src/BuildModel.hs @@ -44,25 +44,24 @@ data Source = } | Module { moduleSourceFileName :: FilePath + , moduleObjectFileName :: FilePath -> FilePath } processRawSource :: RawSource -> Source processRawSource rawSource = let sourceFileName = rawSourceFilename rawSource parsedContents = parseContents rawSource + objectFileName = + \bd -> bd (pathSeparatorsToUnderscores sourceFileName) <.> "o" in if hasProgramDeclaration parsedContents - then Program - { programSourceFileName = sourceFileName - , programObjectFileName = \buildDirectory -> - buildDirectory - (pathSeparatorsToUnderscores - sourceFileName - ) - <.> "o" - , programModulesUsed = getModulesUsed parsedContents - } + then Program { programSourceFileName = sourceFileName + , programObjectFileName = objectFileName + , programModulesUsed = getModulesUsed parsedContents + } else if hasModuleDeclaration parsedContents - then Module { moduleSourceFileName = sourceFileName } + then Module { moduleSourceFileName = sourceFileName + , moduleObjectFileName = objectFileName + } else undefined pathSeparatorsToUnderscores :: FilePath -> FilePath diff --git a/bootstrap/unit_test/ModuleSourceConstructionTest.hs b/bootstrap/unit_test/ModuleSourceConstructionTest.hs index fae7c89..fd69844 100644 --- a/bootstrap/unit_test/ModuleSourceConstructionTest.hs +++ b/bootstrap/unit_test/ModuleSourceConstructionTest.hs @@ -28,6 +28,9 @@ test = return $ givenInput [ 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 ] ] @@ -46,3 +49,9 @@ 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" -- cgit v1.2.3