diff options
author | Brad King <brad.king@kitware.com> | 2018-04-23 14:28:40 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-04-23 14:28:50 (GMT) |
commit | f9b3b5a7730e1c8b87742bcff516acaed7fa7882 (patch) | |
tree | 6c43518823ecf60015beb7050baaa984c3e746aa /Tests | |
parent | 97ecefa73b54b7c585e2e16cee844b943ccf062f (diff) | |
parent | b1f95e5b1477794c0ee3a56a4ea016a34c3e3d5c (diff) | |
download | CMake-f9b3b5a7730e1c8b87742bcff516acaed7fa7882.zip CMake-f9b3b5a7730e1c8b87742bcff516acaed7fa7882.tar.gz CMake-f9b3b5a7730e1c8b87742bcff516acaed7fa7882.tar.bz2 |
Merge topic 'fortran-submodule-depends'
b1f95e5b14 Fortran: Extend submodule test with great-grandchild
402735314e Fortran: Add support for submodule dependencies
62538b2c4c Fortran: Refactor to treat .mod extension as part of module name
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Izaak Beekman <contact@izaakbeekman.com>
Merge-request: !1989
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FortranModules/Submodules/CMakeLists.txt | 24 | ||||
-rw-r--r-- | Tests/FortranModules/Submodules/child.f90 | 10 | ||||
-rw-r--r-- | Tests/FortranModules/Submodules/grandchild.f90 | 8 | ||||
-rw-r--r-- | Tests/FortranModules/Submodules/greatgrandchild.f90 | 8 | ||||
-rw-r--r-- | Tests/FortranModules/Submodules/main.f90 | 2 | ||||
-rw-r--r-- | Tests/FortranModules/Submodules/parent.f90 | 22 | ||||
-rw-r--r-- | Tests/FortranModules/Submodules/provide.f90 | 57 | ||||
-rw-r--r-- | Tests/FortranModules/Submodules/sibling.f90 | 9 |
8 files changed, 82 insertions, 58 deletions
diff --git a/Tests/FortranModules/Submodules/CMakeLists.txt b/Tests/FortranModules/Submodules/CMakeLists.txt index bf0152f..ab8e0f9 100644 --- a/Tests/FortranModules/Submodules/CMakeLists.txt +++ b/Tests/FortranModules/Submodules/CMakeLists.txt @@ -1 +1,23 @@ -add_executable(submod main.f90 provide.f90) +# The program units in this file consist of a module/submodule +# tree represented by the following graph: +# +# parent +# | +# / \ +# / \ +# child sibling +# | +# grandchild +# | +# GreatGrandChild +# +# where the parent node is a module and all other nodes are submodules. + +add_executable(submod + main.f90 + parent.f90 + child.f90 + grandchild.f90 + greatgrandchild.f90 + sibling.f90 + ) diff --git a/Tests/FortranModules/Submodules/child.f90 b/Tests/FortranModules/Submodules/child.f90 new file mode 100644 index 0000000..838ab61 --- /dev/null +++ b/Tests/FortranModules/Submodules/child.f90 @@ -0,0 +1,10 @@ +! Test the notation for a 1st-generation direct +! descendant of a parent module +submodule ( parent ) child + implicit none +contains + module function child_function() result(child_stuff) + logical :: child_stuff + child_stuff=.true. + end function +end submodule child diff --git a/Tests/FortranModules/Submodules/grandchild.f90 b/Tests/FortranModules/Submodules/grandchild.f90 new file mode 100644 index 0000000..1aef63e --- /dev/null +++ b/Tests/FortranModules/Submodules/grandchild.f90 @@ -0,0 +1,8 @@ +! Test the notation for an Nth-generation descendant +! for N>1, which necessitates the colon. +submodule ( parent : child ) grandchild +contains + module subroutine grandchild_subroutine() + print *,"Test passed." + end subroutine +end submodule grandchild diff --git a/Tests/FortranModules/Submodules/greatgrandchild.f90 b/Tests/FortranModules/Submodules/greatgrandchild.f90 new file mode 100644 index 0000000..85404ea --- /dev/null +++ b/Tests/FortranModules/Submodules/greatgrandchild.f90 @@ -0,0 +1,8 @@ +! Test the notation for an Nth-generation descendant +! for N>1, which necessitates the colon. +submodule ( parent : grandchild ) GreatGrandChild +contains + module subroutine GreatGrandChild_subroutine() + print *,"Test passed." + end subroutine +end submodule GreatGrandChild diff --git a/Tests/FortranModules/Submodules/main.f90 b/Tests/FortranModules/Submodules/main.f90 index 3c750ce..3cd2989 100644 --- a/Tests/FortranModules/Submodules/main.f90 +++ b/Tests/FortranModules/Submodules/main.f90 @@ -1,5 +1,7 @@ program main use parent, only : child_function,grandchild_subroutine + use parent, only : sibling_function,GreatGrandChild_subroutine implicit none if (child_function()) call grandchild_subroutine + if (sibling_function()) call GreatGrandChild_subroutine end program diff --git a/Tests/FortranModules/Submodules/parent.f90 b/Tests/FortranModules/Submodules/parent.f90 new file mode 100644 index 0000000..3180b70 --- /dev/null +++ b/Tests/FortranModules/Submodules/parent.f90 @@ -0,0 +1,22 @@ +module parent + implicit none + + interface + + ! Test Fortran 2008 "module function" syntax + module function child_function() result(child_stuff) + logical :: child_stuff + end function + module function sibling_function() result(sibling_stuff) + logical :: sibling_stuff + end function + + ! Test Fortran 2008 "module subroutine" syntax + module subroutine grandchild_subroutine() + end subroutine + module subroutine GreatGrandChild_subroutine() + end subroutine + + end interface + +end module parent diff --git a/Tests/FortranModules/Submodules/provide.f90 b/Tests/FortranModules/Submodules/provide.f90 deleted file mode 100644 index 0ad216a..0000000 --- a/Tests/FortranModules/Submodules/provide.f90 +++ /dev/null @@ -1,57 +0,0 @@ -! The program units in this file consist of a -! module/submodule tree represented by the following -! graph: -! -! parent -! | -! / \ -! / \ -! child sibling -! | -! grandchild -! -! where the parent node is a module and all other -! nodes are submodules. - -module parent - implicit none - - interface - - ! Test Fortran 2008 "module function" syntax - module function child_function() result(child_stuff) - logical :: child_stuff - end function - - ! Test Fortran 2008 "module subroutine" syntax - module subroutine grandchild_subroutine() - end subroutine - - end interface - -end module parent - -! Test the notation for a 1st-generation direct -! descendant of a parent module -submodule ( parent ) child - implicit none -contains - module function child_function() result(child_stuff) - logical :: child_stuff - child_stuff=.true. - end function -end submodule child - -! Empty submodule for checking disambiguation of -! nodes at the same vertical level in the tree -submodule ( parent ) sibling -end submodule sibling - -! Test the notation for an Nth-generation descendant -! for N>1, which necessitates the colon. -submodule ( parent : child ) grandchild -contains - module subroutine grandchild_subroutine() - print *,"Test passed." - end subroutine -end submodule grandchild diff --git a/Tests/FortranModules/Submodules/sibling.f90 b/Tests/FortranModules/Submodules/sibling.f90 new file mode 100644 index 0000000..8c0943d --- /dev/null +++ b/Tests/FortranModules/Submodules/sibling.f90 @@ -0,0 +1,9 @@ +! Empty submodule for checking disambiguation of +! nodes at the same vertical level in the tree +submodule ( parent ) sibling +contains + module function sibling_function() result(sibling_stuff) + logical :: sibling_stuff + sibling_stuff=.true. + end function +end submodule sibling |