-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Localise module maps #286
Merged
Merged
Localise module maps #286
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
31a3e06
some helpers for working with constant expression evaluator
dorchard 2240b9d
remoev comment
dorchard a21e146
feature for tagging in module maps whether names are defined loal or …
dorchard 04c497a
improve error reporting if syntax error with mod file
dorchard 100ee4c
mod file spec test
dorchard 10a45ca
add modfilespec to cabal
dorchard 4d028b7
more robust test
dorchard 001abaf
os agnostic test
dorchard e1dc768
--version functionality
dorchard 8776f07
package update
dorchard 1fde26a
add missing fall through case
dorchard a3e71c1
comment
dorchard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Language.Fortran.Analysis.ModFileSpec (spec) where | ||
|
||
import Test.Hspec | ||
import TestUtil | ||
|
||
import Language.Fortran.Util.ModFile | ||
import Language.Fortran.Util.Files (expandDirs, flexReadFile) | ||
import Language.Fortran.Version | ||
import System.FilePath ((</>)) | ||
import qualified Data.Map as M | ||
import qualified Language.Fortran.Parser as Parser | ||
import qualified Data.ByteString.Char8 as B | ||
import Language.Fortran.AST | ||
import Language.Fortran.Analysis | ||
import Language.Fortran.Analysis.Renaming | ||
import Language.Fortran.Analysis.BBlocks | ||
import Language.Fortran.Analysis.DataFlow | ||
|
||
spec :: Spec | ||
spec = | ||
describe "Modfiles" $ | ||
it "Test module maps for a small package" $ | ||
testModuleMaps | ||
|
||
pParser :: String -> IO (ProgramFile (Analysis A0)) | ||
pParser name = do | ||
contents <- flexReadFile name | ||
let pf = Parser.byVerWithMods [] Fortran90 name contents | ||
case pf of | ||
Right pf -> return $ rename . analyseBBlocks . analyseRenames . initAnalysis $ pf | ||
Left err -> error $ "Error parsing " ++ name ++ ": " ++ show err | ||
|
||
-- A simple test that checks that we correctly localise the declaration | ||
-- of the variable `constant` to the leaf module, whilst understanding | ||
-- in the `mid1` and `mid2` modules that it is an imported declaration. | ||
testModuleMaps = do | ||
paths <- expandDirs ["test-data" </> "module"] | ||
-- parse all files into mod files | ||
pfs <- mapM (\p -> pParser p) paths | ||
let modFiles = map genModFile pfs | ||
-- get unique name to filemap | ||
let mmap = genUniqNameToFilenameMap modFiles | ||
-- check that `constant` is declared in leaf.f90 | ||
let Just leaf = M.lookup "leaf_constant_1" mmap | ||
leaf `shouldBe` ("test-data" </> "module" </> "leaf.f90") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(We should have a release guide that instructs updating the version string shown here. I'll start a wiki page later.)