aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/unit_test
diff options
context:
space:
mode:
authorBrad Richardson <everythingfunctional@protonmail.com>2020-10-19 15:52:45 -0500
committerBrad Richardson <everythingfunctional@protonmail.com>2020-10-19 15:52:45 -0500
commitf038a093bc0259bf7d72d86fb95f4a2aebf1a8df (patch)
tree25c9ac618e1332eb6d006e44be640f877f005a0a /bootstrap/unit_test
parenta981372352e881d1cc7d542628959c0ac501e96e (diff)
downloadfpm-f038a093bc0259bf7d72d86fb95f4a2aebf1a8df.tar.gz
fpm-f038a093bc0259bf7d72d86fb95f4a2aebf1a8df.zip
Add test for modules a submodule uses
Diffstat (limited to 'bootstrap/unit_test')
-rw-r--r--bootstrap/unit_test/SubmoduleSourceConstructionTest.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs b/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs
index 5295a97..956d782 100644
--- a/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs
+++ b/bootstrap/unit_test/SubmoduleSourceConstructionTest.hs
@@ -31,12 +31,18 @@ test = return $ givenInput
, then'
"its object file name is the 'flattened' path of the source file with '.o' appeneded"
checkSubmoduleObjectFileName
+ , then' "it knows what modules it uses directly" checkSubmoduleModulesUsed
]
]
exampleSubmodule :: RawSource
-exampleSubmodule = RawSource submoduleSourceFileName'
- $ unlines ["submodule (some_module:parent) child", "end submodule"]
+exampleSubmodule = RawSource submoduleSourceFileName' $ unlines
+ [ "submodule (some_module:parent) child"
+ , " use module1"
+ , " USE MODULE2"
+ , " implicit none"
+ , "end submodule"
+ ]
submoduleSourceFileName' :: String
submoduleSourceFileName' = "some" </> "file" </> "somewhere.f90"
@@ -55,3 +61,8 @@ checkSubmoduleObjectFileName s@(Submodule{}) =
assertEquals ("." </> "some_file_somewhere.f90.o")
$ (submoduleObjectFileName s) "."
checkSubmoduleObjectFileName _ = fail' "wasn't a Submodule"
+
+checkSubmoduleModulesUsed :: Source -> Result
+checkSubmoduleModulesUsed s@(Submodule{}) =
+ assertEquals ["module1", "module2"] $ submoduleModulesUsed s
+checkSubmoduleModulesUsed _ = fail' "wasn't a Submodule"