From 0a7eb98dd5083ede9e940a3e9cc424b76968ba4a Mon Sep 17 00:00:00 2001 From: Brad Richardson Date: Wed, 14 Oct 2020 12:23:03 -0500 Subject: Finish first unit test --- bootstrap/src/BuildModel.hs | 11 +++++++++ bootstrap/unit_test/SourceConstructionTest.hs | 35 ++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 bootstrap/src/BuildModel.hs (limited to 'bootstrap') diff --git a/bootstrap/src/BuildModel.hs b/bootstrap/src/BuildModel.hs new file mode 100644 index 0000000..87c45c7 --- /dev/null +++ b/bootstrap/src/BuildModel.hs @@ -0,0 +1,11 @@ +module BuildModel where + +data RawSource = RawSource { + rawSourceFilename :: FilePath + , rawSourceContents :: String +} + +data Source = Program + +processRawSource :: RawSource -> Source +processRawSource _ = Program diff --git a/bootstrap/unit_test/SourceConstructionTest.hs b/bootstrap/unit_test/SourceConstructionTest.hs index a3fdf68..9429975 100644 --- a/bootstrap/unit_test/SourceConstructionTest.hs +++ b/bootstrap/unit_test/SourceConstructionTest.hs @@ -3,9 +3,38 @@ module SourceConstructionTest ) where -import Hedge ( Test - , describe +import BuildModel ( RawSource(..) + , Source(..) + , processRawSource + ) +import Hedge ( Result + , Test + , assertThat + , givenInput + , then' + , whenTransformed ) test :: IO (Test ()) -test = return $ describe "something" [] +test = return $ givenInput + "a program" + exampleProgram + [ whenTransformed "processed to a source" + processRawSource + [then' "it is a Program" checkIsProgram] + ] + +exampleProgram :: RawSource +exampleProgram = RawSource + "some/file/somewhere.f90" + $ unlines + [ "program some_program" + , " implicit none" + , " print *, \"Hello, World!\"" + , "end program" + ] + +checkIsProgram :: Source -> Result +checkIsProgram s = assertThat $ case s of + Program -> True + _ -> False -- cgit v1.2.3