Skip to content

Commit 5f0e0ef

Browse files
rousonbonachea
authored andcommitted
fix(test): rm module in proc interf
Also manually inline string function.
1 parent 399ed80 commit 5f0e0ef

File tree

2 files changed

+14
-33
lines changed

2 files changed

+14
-33
lines changed

src/assert/assert_subroutine_m.F90

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pure subroutine assert(assertion, description)
8787

8888
end subroutine
8989

90-
pure module subroutine assert_always(assertion, description)
90+
pure subroutine assert_always(assertion, description)
9191
!! Same as above but always enforces the assertion (regardless of ASSERTIONS)
9292
implicit none
9393
logical, intent(in) :: assertion
@@ -104,7 +104,11 @@ pure module subroutine assert_always(assertion, description)
104104
# else
105105
me = this_image()
106106
# endif
107-
message = 'Assertion failure on image ' // string(me) // ':' // description
107+
block
108+
character(len=128) image_number
109+
write(image_number, *) me
110+
message = 'Assertion failure on image ' // trim(adjustl(image_number)) // ':' // description
111+
end block
108112
#else
109113
message = 'Assertion failure: ' // description
110114
me = 0 ! avoid a harmless warning
@@ -118,32 +122,6 @@ pure module subroutine assert_always(assertion, description)
118122

119123
end if check_assertion
120124

121-
contains
122-
123-
pure function string(numeric) result(number_as_string)
124-
!! Result is a string represention of the numeric argument
125-
class(*), intent(in) :: numeric
126-
integer, parameter :: max_len=128
127-
character(len=max_len) :: untrimmed_string
128-
character(len=:), allocatable :: number_as_string
129-
130-
select type(numeric)
131-
type is(complex)
132-
write(untrimmed_string, *) numeric
133-
type is(integer)
134-
write(untrimmed_string, *) numeric
135-
type is(logical)
136-
write(untrimmed_string, *) numeric
137-
type is(real)
138-
write(untrimmed_string, *) numeric
139-
class default
140-
error stop "Internal error in subroutine 'assert': unsupported type in function 'string'."
141-
end select
142-
143-
number_as_string = trim(adjustl(untrimmed_string))
144-
145-
end function string
146-
147125
end subroutine
148126

149127
end module assert_subroutine_m

test/test-assert-subroutine-error-termination.F90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ program test_assert_subroutine_error_termination
4848
end if
4949
end if
5050
end block
51+
#else
52+
#ifdef __LFORTRAN__
53+
print *,trim(merge("passes","FAILS ",exit_status/=0)) // " on error-terminating when assertion = .false."
5154
#else
5255
block
53-
! integer unit
54-
! open(newunit=unit, file="build/exit_status", status="old")
55-
! read(unit,*) exit_status
56-
print *,trim(merge("passes","FAILS ",exit_status/=0)) // " on error-terminating when assertion = .false."
57-
! close(unit)
56+
integer unit
57+
open(newunit=unit, file="build/exit_status", status="old")
58+
read(unit,*) exit_status
59+
close(unit)
5860
end block
5961
#endif
62+
#endif
6063

6164
contains
6265

0 commit comments

Comments
 (0)