From cfb8b07fcb102573b70f37de9421e14d1300ac58 Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Tue, 20 Oct 2020 11:06:35 -0500 Subject: Add test for source file name of program's compile time info --- bootstrap/unit_test/ProgramToCompileInfoTest.hs | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 bootstrap/unit_test/ProgramToCompileInfoTest.hs (limited to 'bootstrap/unit_test') diff --git a/bootstrap/unit_test/ProgramToCompileInfoTest.hs b/bootstrap/unit_test/ProgramToCompileInfoTest.hs new file mode 100644 index 0000000..b855c66 --- /dev/null +++ b/bootstrap/unit_test/ProgramToCompileInfoTest.hs @@ -0,0 +1,48 @@ +module ProgramToCompileInfoTest + ( test + ) +where + +import BuildModel ( Source(..) + , CompileTimeInfo(..) + , constructCompileTimeInfo + ) +import Hedge ( Result + , Test + , assertEquals + , givenInput + , then' + , whenTransformed + ) +import System.FilePath ( () ) + +test :: IO (Test ()) +test = return $ givenInput + "a program and other sources" + (exampleProgram, exampleSources) + [ whenTransformed + "its compileTimeInfo is determined" + doCompileTimeTransformation + [then' "it still knows the original source file" checkSourceFileName] + ] + +exampleProgram :: Source +exampleProgram = Program + { programSourceFileName = programSourceFileName' + , programObjectFileName = \bd -> bd "some_file_somewhere.f90.o" + , programModulesUsed = ["module1", "module2", "module3"] + } + +programSourceFileName' :: String +programSourceFileName' = "some" "file" "somewhere.f90" + +exampleSources :: [Source] +exampleSources = [] + +doCompileTimeTransformation :: (Source, [Source]) -> CompileTimeInfo +doCompileTimeTransformation (programSource, otherSources) = + constructCompileTimeInfo programSource otherSources "build_dir" + +checkSourceFileName :: CompileTimeInfo -> Result +checkSourceFileName cti = + assertEquals programSourceFileName' (compileTimeInfoSourceFileName cti) -- cgit v1.2.3