aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/unit_test
diff options
context:
space:
mode:
authorBrad Richardson <everythingfunctional@protonmail.com>2020-10-14 12:32:06 -0500
committerBrad Richardson <everythingfunctional@protonmail.com>2020-10-14 12:32:06 -0500
commited529804fc47d64f78bdbd3b4e366ff9f632c8d3 (patch)
treecf88d1eb12e13f1fcc145036ad6e698b7134d5a2 /bootstrap/unit_test
parent0a7eb98dd5083ede9e940a3e9cc424b76968ba4a (diff)
downloadfpm-ed529804fc47d64f78bdbd3b4e366ff9f632c8d3.tar.gz
fpm-ed529804fc47d64f78bdbd3b4e366ff9f632c8d3.zip
Add test for Program source file name
Diffstat (limited to 'bootstrap/unit_test')
-rw-r--r--bootstrap/unit_test/SourceConstructionTest.hs27
1 files changed, 20 insertions, 7 deletions
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"