summaryrefslogtreecommitdiffstats
path: root/test/fixture
diff options
context:
space:
mode:
authorPeter Diener <diener@cct.lsu.edu>2019-04-26 20:55:03 (GMT)
committerPeter Diener <diener@cct.lsu.edu>2019-04-26 20:55:03 (GMT)
commitfbe96c0207942918a0d5f34addaac57d3b9b528c (patch)
treed7a4f6aecd0af390f728c822d104040f0e17fdbc /test/fixture
parent4007416e4125db5d3598c3113bb1a3052c4460a7 (diff)
downloadSCons-fbe96c0207942918a0d5f34addaac57d3b9b528c.zip
SCons-fbe96c0207942918a0d5f34addaac57d3b9b528c.tar.gz
SCons-fbe96c0207942918a0d5f34addaac57d3b9b528c.tar.bz2
Also ignore PURE and ELEMENTAL after MODULE in Scanner and Emitter.
Add subroutines that are declared pure and elemental to the test of the Emitter. Note that in test_1.f90, the interface is repeated in the submodule, whereas in test_2.f90 the interface is taken from the module. Also note that the regex does not check whether "module pure" or "module elemental" is actually followed by "subroutine" or "function". This would be a syntax error and should trigger a compile time error.
Diffstat (limited to 'test/fixture')
-rw-r--r--test/fixture/fortran_unittests/test_1.f9022
-rw-r--r--test/fixture/fortran_unittests/test_2.f9024
-rw-r--r--test/fixture/fortran_unittests/test_submodules.f9012
3 files changed, 58 insertions, 0 deletions
diff --git a/test/fixture/fortran_unittests/test_1.f90 b/test/fixture/fortran_unittests/test_1.f90
index 25ba9d6..50ab99e 100644
--- a/test/fixture/fortran_unittests/test_1.f90
+++ b/test/fixture/fortran_unittests/test_1.f90
@@ -5,6 +5,8 @@ module test_1
contains
procedure :: set_n
procedure :: get_n
+ procedure :: increment_n
+ procedure :: decrement_n
end type test_type_1
@@ -20,6 +22,14 @@ interface
integer :: get_n
end function get_n
+ module pure subroutine increment_n ( this )
+ class(test_type_1), intent(inout) :: this
+ end subroutine increment_n
+
+ module elemental subroutine decrement_n ( this )
+ class(test_type_1), intent(inout) :: this
+ end subroutine decrement_n
+
end interface
end module test_1
@@ -43,4 +53,16 @@ contains
get_n = this%n
end procedure get_n
+ module pure subroutine increment_n ( this )
+ class(test_type_1), intent(inout) :: this
+
+ this%n = this%n+1
+ end subroutine increment_n
+
+ module elemental subroutine decrement_n ( this )
+ class(test_type_1), intent(inout) :: this
+
+ this%n = this%n-1
+ end subroutine decrement_n
+
end submodule test_1_impl
diff --git a/test/fixture/fortran_unittests/test_2.f90 b/test/fixture/fortran_unittests/test_2.f90
index 7a39b0d..e271953 100644
--- a/test/fixture/fortran_unittests/test_2.f90
+++ b/test/fixture/fortran_unittests/test_2.f90
@@ -5,6 +5,8 @@ module test_2
contains
procedure :: set_m
procedure :: get_m
+ procedure :: increment_m
+ procedure :: decrement_m
end type test_type_2
@@ -20,6 +22,14 @@ interface
integer :: get_m
end function get_m
+ module pure subroutine increment_m ( this )
+ class(test_type_2), intent(inout) :: this
+ end subroutine increment_m
+
+ module elemental subroutine decrement_m ( this )
+ class(test_type_2), intent(inout) :: this
+ end subroutine decrement_m
+
end interface
end module test_2
@@ -43,4 +53,18 @@ contains
get_m = this%m
end procedure get_m
+ module procedure increment_m
+
+ implicit none
+
+ this%m = this%m+1
+ end procedure increment_m
+
+ module procedure decrement_m
+
+ implicit none
+
+ this%m = this%m-1
+ end procedure decrement_m
+
end submodule test_2_impl
diff --git a/test/fixture/fortran_unittests/test_submodules.f90 b/test/fixture/fortran_unittests/test_submodules.f90
index 5deec37..08e472c 100644
--- a/test/fixture/fortran_unittests/test_submodules.f90
+++ b/test/fixture/fortran_unittests/test_submodules.f90
@@ -12,4 +12,16 @@ program test_submodules
print*,'var1%n = ', var1%get_n()
print*,'var2%m = ', var2%get_m()
+ call var1%increment_n()
+ call var2%increment_m()
+
+ print*,'var1%n = ', var1%get_n()
+ print*,'var2%m = ', var2%get_m()
+
+ call var1%decrement_n()
+ call var2%decrement_m()
+
+ print*,'var1%n = ', var1%get_n()
+ print*,'var2%m = ', var2%get_m()
+
end program test_submodules