Skip to content

Commit

Permalink
Add a test for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
certik committed Aug 24, 2020
1 parent 6478c9b commit 6cb892d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,6 @@ if (NOT LFORTRAN_BACKEND)
RUN(allocate_01)
RUN(block_01)
RUN(associate_01)

RUN(functions_01)
endif()
33 changes: 33 additions & 0 deletions integration_tests/functions_01.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
program functions_01
implicit none
integer :: i, j
i = 1
j = 1
if (j /= 1) error stop
j = f(i)
if (i /= 1) error stop
if (j /= 2) error stop

j = 1
if (j /= 1) error stop
j = f(3)
if (j /= 4) error stop

j = 1
if (j /= 1) error stop
j = f(1+2)
if (j /= 4) error stop

j = 1
if (j /= 1) error stop
j = f(i+2)
if (j /= 4) error stop

contains

integer function f(a) result(b)
integer, intent(in) :: a
b = a + 1
end function

end program

0 comments on commit 6cb892d

Please sign in to comment.