aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap')
-rw-r--r--bootstrap/src/BuildModel.hs4
-rw-r--r--bootstrap/unit_test/SourceConstructionTest.hs27
2 files changed, 22 insertions, 9 deletions
diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs
index 87c45c7..711f977 100644
--- a/bootstrap/src/BuildModel.hs
+++ b/bootstrap/src/BuildModel.hs
@@ -5,7 +5,7 @@ data RawSource = RawSource {
, rawSourceContents :: String
}
-data Source = Program
+data Source = Program { programSourceFileName :: String}
processRawSource :: RawSource -> Source
-processRawSource _ = Program
+processRawSource rawSource = Program $ rawSourceFilename rawSource
diff --git a/bootstrap/unit_test/SourceConstructionTest.hs b/bootstrap/unit_test/SourceConstructionTest.hs
index 9429975..18a66de 100644
--- a/bootstrap/unit_test/SourceConstructionTest.hs
+++ b/bootstrap/unit_test/SourceConstructionTest.hs
@@ -9,7 +9,9 @@ import BuildModel ( RawSource(..)
)
import Hedge ( Result
, Test
+ , assertEquals
, assertThat
+ , fail'
, givenInput
, then'
, whenTransformed
@@ -19,22 +21,33 @@ test :: IO (Test ())
test = return $ givenInput
"a program"
exampleProgram
- [ whenTransformed "processed to a source"
- processRawSource
- [then' "it is a Program" checkIsProgram]
+ [ whenTransformed
+ "processed to a source"
+ processRawSource
+ [ then' "it is a Program" checkIsProgram
+ , then' "its source file name is the same as the original"
+ checkProgramSourceFileName
+ ]
]
exampleProgram :: RawSource
-exampleProgram = RawSource
- "some/file/somewhere.f90"
- $ unlines
+exampleProgram = RawSource programSourceFileName' $ unlines
[ "program some_program"
, " implicit none"
, " print *, \"Hello, World!\""
, "end program"
]
+programSourceFileName' :: String
+programSourceFileName' = "some/file/somewhere.f90"
+
checkIsProgram :: Source -> Result
checkIsProgram s = assertThat $ case s of
- Program -> True
+ Program{} -> True
_ -> False
+
+checkProgramSourceFileName :: Source -> Result
+checkProgramSourceFileName s = case s of
+ p@(Program{}) ->
+ assertEquals programSourceFileName' $ programSourceFileName p
+ _ -> fail' "wasn't a Program"