From 29356ac6da1a94dbcc0c50c157e8dcb353213793 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 14 Oct 2020 12:51:29 -0500 Subject: Add test for program object file name --- bootstrap/unit_test/SourceConstructionTest.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bootstrap/unit_test') diff --git a/bootstrap/unit_test/SourceConstructionTest.hs b/bootstrap/unit_test/SourceConstructionTest.hs index 18a66de..2cee008 100644 --- a/bootstrap/unit_test/SourceConstructionTest.hs +++ b/bootstrap/unit_test/SourceConstructionTest.hs @@ -7,6 +7,7 @@ import BuildModel ( RawSource(..) , Source(..) , processRawSource ) +import System.FilePath ( () ) import Hedge ( Result , Test , assertEquals @@ -27,6 +28,9 @@ test = return $ givenInput [ then' "it is a Program" checkIsProgram , then' "its source file name is the same as the original" checkProgramSourceFileName + , then' + "its object file name is the 'flattened' path of the source file with '.o' appended" + checkProgramObjectFileName ] ] @@ -39,15 +43,21 @@ exampleProgram = RawSource programSourceFileName' $ unlines ] programSourceFileName' :: String -programSourceFileName' = "some/file/somewhere.f90" +programSourceFileName' = "some" "file" "somewhere.f90" checkIsProgram :: Source -> Result checkIsProgram s = assertThat $ case s of Program{} -> True - _ -> False + _ -> False checkProgramSourceFileName :: Source -> Result checkProgramSourceFileName s = case s of p@(Program{}) -> assertEquals programSourceFileName' $ programSourceFileName p _ -> fail' "wasn't a Program" + +checkProgramObjectFileName :: Source -> Result +checkProgramObjectFileName s = case s of + p@(Program{}) -> assertEquals ("." "some_file_somewhere.f90.o") + $ (programObjectFileName p) "." + _ -> fail' "wasn't a Program" -- cgit v1.2.3