Skip to content

Commit 7eca780

Browse files
committed
updates tests.
1 parent 98d7716 commit 7eca780

File tree

1 file changed

+37
-43
lines changed

1 file changed

+37
-43
lines changed

src/tests/tests.f90

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!*******************************************************************************
22
!> license: BSD
33
!
4-
! Test cases for the function parser module
4+
! Test cases for the function parser module.
55

66
program tests
77

@@ -29,23 +29,22 @@ subroutine fptest()
2929
real(wp),dimension(nvar),parameter :: val = [ 2.0_wp ]
3030

3131
type(fparser) :: parser
32-
type(list_of_errors) :: error_msg
3332
real(wp) :: res
3433
real(wp) :: x
3534

3635
write(*,*) ''
3736
write(*,*) ' Test 1'
3837
write(*,*) ''
3938

40-
call parser%parse(func, var, .false., error_msg) ! parse and bytecompile function string
41-
if (error_msg%has_errors()) then
42-
call error_msg%print(output_unit)
39+
call parser%parse(func, var, .false.) ! parse and bytecompile function string
40+
if (parser%error()) then
41+
call parser%print_errors(output_unit)
4342
else
4443

4544
write(*,*)'==> bytecode evaluation:'
46-
call parser%evaluate(val,res,error_msg) ! interprete bytecode representation of function
47-
if (error_msg%has_errors()) then
48-
call error_msg%print(output_unit)
45+
call parser%evaluate(val,res) ! interprete bytecode representation of function
46+
if (parser%error()) then
47+
call parser%print_errors(output_unit)
4948
else
5049
write(*,*) func,'=',res
5150
write(*,*)'==> direct evaluation:'
@@ -77,7 +76,6 @@ subroutine fptest2()
7776
1.0_wp, 5.0_wp, 6.0_wp ]
7877

7978
type(fparser_array) :: parser
80-
type(list_of_errors) :: error_msg
8179
real(wp),dimension(nfunc) :: res
8280
integer :: i !! counter
8381
real(wp) :: a0,b0,a1,b1,a3,b3
@@ -86,15 +84,15 @@ subroutine fptest2()
8684
write(*,*) ' Test 2'
8785
write(*,*) ''
8886

89-
call parser%parse(func, var, .false., error_msg) ! parse and bytecompile function string
90-
if (error_msg%has_errors()) then
91-
call error_msg%print(output_unit)
87+
call parser%parse(func, var, .false.) ! parse and bytecompile function string
88+
if (parser%error()) then
89+
call parser%print_errors(output_unit)
9290
else
9391

9492
write(*,*)'==> bytecode evaluation:'
95-
call parser%evaluate(val,res,error_msg) ! interprete bytecode representation of function
96-
if (error_msg%has_errors()) then
97-
call error_msg%print(output_unit)
93+
call parser%evaluate(val,res) ! interprete bytecode representation of function
94+
if (parser%error()) then
95+
call parser%print_errors(output_unit)
9896
else
9997
do i=1,nfunc
10098
write(*,*) func(i),'=',res(i)
@@ -131,7 +129,6 @@ subroutine fptest3()
131129
real(wp), dimension(nvar), parameter :: val = [ 10., 1.5, 2.0 ]
132130

133131
type(fparser_array) :: parser
134-
type(list_of_errors) :: error_msg
135132
real(wp),dimension(nfunc) :: res
136133
integer :: i !! counter
137134
real(wp) :: vel,alpha,beta
@@ -140,15 +137,15 @@ subroutine fptest3()
140137
write(*,*) ' Test 3'
141138
write(*,*) ''
142139

143-
call parser%parse(func, var, .false., error_msg) ! parse and bytecompile function string
144-
if (error_msg%has_errors()) then
145-
call error_msg%print(output_unit)
140+
call parser%parse(func, var, .false.) ! parse and bytecompile function string
141+
if (parser%error()) then
142+
call parser%print_errors(output_unit)
146143
else
147144

148145
write(*,*)'==> bytecode evaluation:'
149-
call parser%evaluate(val,res,error_msg) ! interprete bytecode representation of function
150-
if (error_msg%has_errors()) then
151-
call error_msg%print(output_unit)
146+
call parser%evaluate(val,res) ! interprete bytecode representation of function
147+
if (parser%error()) then
148+
call parser%print_errors(output_unit)
152149
else
153150
do i=1,nfunc
154151
write(*,*) func(i),'=',res(i)
@@ -186,7 +183,6 @@ subroutine fptest4()
186183
real(wp), dimension(nvar), parameter :: val = [ 10., 1.5, 2.0 ]
187184

188185
type(fparser_array) :: parser
189-
type(list_of_errors) :: error_msg
190186
real(wp),dimension(nfunc) :: res
191187
integer :: i,n
192188
real :: rt1,rt2,rt3
@@ -196,19 +192,19 @@ subroutine fptest4()
196192
write(*,*) ' Test 4'
197193
write(*,*) ''
198194

199-
call parser%parse(func, var, .false., error_msg) ! parse and bytecompile function string
200-
if (error_msg%has_errors()) then
201-
call error_msg%print(output_unit)
195+
call parser%parse(func, var, .false.) ! parse and bytecompile function string
196+
if (parser%error()) then
197+
call parser%print_errors(output_unit)
202198
else
203199

204200
vel = val(1)
205201
alpha = val(2)
206202
beta = val(3)
207203
call cpu_time (rt1)
208204
do n=1,neval
209-
call parser%evaluate(val,res,error_msg) ! interprete bytecode representation of function
210-
if (error_msg%has_errors()) then
211-
call error_msg%print(output_unit)
205+
call parser%evaluate(val,res) ! interprete bytecode representation of function
206+
if (parser%error()) then
207+
call parser%print_errors(output_unit)
212208
return
213209
end if
214210
end do
@@ -247,22 +243,21 @@ subroutine fptest5()
247243
real(wp),dimension(1),parameter :: val = [0.0_wp] !! not really used here
248244

249245
type(fparser) :: parser
250-
type(list_of_errors) :: error_msg
251246
real(wp) :: res
252247
real(wp) :: x
253248

254249
write(*,*) ''
255250
write(*,*) ' Test 5'
256251
write(*,*) ''
257252

258-
call parser%parse(func, var, .false., error_msg) ! parse and bytecompile function string
259-
if (error_msg%has_errors()) then
260-
call error_msg%print(output_unit)
253+
call parser%parse(func, var, .false.) ! parse and bytecompile function string
254+
if (parser%error()) then
255+
call parser%print_errors(output_unit)
261256
else
262257
write(*,*)'==> bytecode evaluation:'
263-
call parser%evaluate(val,res,error_msg) ! interprete bytecode representation of function
264-
if (error_msg%has_errors()) then
265-
call error_msg%print(output_unit)
258+
call parser%evaluate(val,res) ! interprete bytecode representation of function
259+
if (parser%error()) then
260+
call parser%print_errors(output_unit)
266261
else
267262
write(*,*) func,'=',res
268263
end if
@@ -288,7 +283,6 @@ subroutine fptest6()
288283
real(wp), dimension(nvar), parameter :: val = [ 2.0_wp, 3.0_wp, 4.0_wp ]
289284

290285
type(fparser_array) :: parser
291-
type(list_of_errors) :: error_msg
292286
real(wp),dimension(nfunc) :: res
293287
integer :: i !! counter
294288
real(wp) :: x,a,b
@@ -297,15 +291,15 @@ subroutine fptest6()
297291
write(*,*) ' Test 6'
298292
write(*,*) ''
299293

300-
call parser%parse(func, var, .false., error_msg) ! parse and bytecompile function string
301-
if (error_msg%has_errors()) then
302-
call error_msg%print(output_unit)
294+
call parser%parse(func, var, .false.) ! parse and bytecompile function string
295+
if (parser%error()) then
296+
call parser%print_errors(output_unit)
303297
else
304298

305299
write(*,*)'==> bytecode evaluation:'
306-
call parser%evaluate(val,res,error_msg) ! interprete bytecode representation of function
307-
if (error_msg%has_errors()) then
308-
call error_msg%print(output_unit)
300+
call parser%evaluate(val,res) ! interprete bytecode representation of function
301+
if (parser%error()) then
302+
call parser%print_errors(output_unit)
309303
else
310304
do i=1,nfunc
311305
write(*,*) func(i),'=',res(i)

0 commit comments

Comments
 (0)