aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/src/BuildModel.hs8
-rw-r--r--bootstrap/unit_test/ModuleSourceConstructionTest.hs17
2 files changed, 20 insertions, 5 deletions
diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs
index db44b54..043173f 100644
--- a/bootstrap/src/BuildModel.hs
+++ b/bootstrap/src/BuildModel.hs
@@ -42,7 +42,9 @@ data Source =
, programObjectFileName :: FilePath -> FilePath
, programModulesUsed :: [String]
}
- | Module {}
+ | Module
+ { moduleSourceFileName :: FilePath
+ }
processRawSource :: RawSource -> Source
processRawSource rawSource =
@@ -59,7 +61,9 @@ processRawSource rawSource =
<.> "o"
, programModulesUsed = getModulesUsed parsedContents
}
- else if hasModuleDeclaration parsedContents then Module{} else undefined
+ else if hasModuleDeclaration parsedContents
+ then Module { moduleSourceFileName = sourceFileName }
+ else undefined
pathSeparatorsToUnderscores :: FilePath -> FilePath
pathSeparatorsToUnderscores fileName =
diff --git a/bootstrap/unit_test/ModuleSourceConstructionTest.hs b/bootstrap/unit_test/ModuleSourceConstructionTest.hs
index cc6d079..fae7c89 100644
--- a/bootstrap/unit_test/ModuleSourceConstructionTest.hs
+++ b/bootstrap/unit_test/ModuleSourceConstructionTest.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 module"
exampleModule
- [ whenTransformed "processed to a source"
- processRawSource
- [then' "it is a Module" checkIsModule]
+ [ whenTransformed
+ "processed to a source"
+ processRawSource
+ [ then' "it is a Module" checkIsModule
+ , then' "its source file name is the same as the original"
+ checkModuleSourceFileName
+ ]
]
exampleModule :: RawSource
@@ -35,3 +41,8 @@ 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"