1
1
! *******************************************************************************
2
2
! > license: BSD
3
3
!
4
- ! Test cases for the function parser module
4
+ ! Test cases for the function parser module.
5
5
6
6
program tests
7
7
@@ -29,23 +29,22 @@ subroutine fptest()
29
29
real (wp),dimension (nvar),parameter :: val = [ 2.0_wp ]
30
30
31
31
type (fparser) :: parser
32
- type (list_of_errors) :: error_msg
33
32
real (wp) :: res
34
33
real (wp) :: x
35
34
36
35
write (* ,* ) ' '
37
36
write (* ,* ) ' Test 1'
38
37
write (* ,* ) ' '
39
38
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)
43
42
else
44
43
45
44
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)
49
48
else
50
49
write (* ,* ) func,' =' ,res
51
50
write (* ,* )' ==> direct evaluation:'
@@ -77,7 +76,6 @@ subroutine fptest2()
77
76
1.0_wp , 5.0_wp , 6.0_wp ]
78
77
79
78
type (fparser_array) :: parser
80
- type (list_of_errors) :: error_msg
81
79
real (wp),dimension (nfunc) :: res
82
80
integer :: i ! ! counter
83
81
real (wp) :: a0,b0,a1,b1,a3,b3
@@ -86,15 +84,15 @@ subroutine fptest2()
86
84
write (* ,* ) ' Test 2'
87
85
write (* ,* ) ' '
88
86
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)
92
90
else
93
91
94
92
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)
98
96
else
99
97
do i= 1 ,nfunc
100
98
write (* ,* ) func(i),' =' ,res(i)
@@ -131,7 +129,6 @@ subroutine fptest3()
131
129
real (wp), dimension (nvar), parameter :: val = [ 10 ., 1.5 , 2.0 ]
132
130
133
131
type (fparser_array) :: parser
134
- type (list_of_errors) :: error_msg
135
132
real (wp),dimension (nfunc) :: res
136
133
integer :: i ! ! counter
137
134
real (wp) :: vel,alpha,beta
@@ -140,15 +137,15 @@ subroutine fptest3()
140
137
write (* ,* ) ' Test 3'
141
138
write (* ,* ) ' '
142
139
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)
146
143
else
147
144
148
145
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)
152
149
else
153
150
do i= 1 ,nfunc
154
151
write (* ,* ) func(i),' =' ,res(i)
@@ -186,7 +183,6 @@ subroutine fptest4()
186
183
real (wp), dimension (nvar), parameter :: val = [ 10 ., 1.5 , 2.0 ]
187
184
188
185
type (fparser_array) :: parser
189
- type (list_of_errors) :: error_msg
190
186
real (wp),dimension (nfunc) :: res
191
187
integer :: i,n
192
188
real :: rt1,rt2,rt3
@@ -196,19 +192,19 @@ subroutine fptest4()
196
192
write (* ,* ) ' Test 4'
197
193
write (* ,* ) ' '
198
194
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)
202
198
else
203
199
204
200
vel = val(1 )
205
201
alpha = val(2 )
206
202
beta = val(3 )
207
203
call cpu_time (rt1)
208
204
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)
212
208
return
213
209
end if
214
210
end do
@@ -247,22 +243,21 @@ subroutine fptest5()
247
243
real (wp),dimension (1 ),parameter :: val = [0.0_wp ] ! ! not really used here
248
244
249
245
type (fparser) :: parser
250
- type (list_of_errors) :: error_msg
251
246
real (wp) :: res
252
247
real (wp) :: x
253
248
254
249
write (* ,* ) ' '
255
250
write (* ,* ) ' Test 5'
256
251
write (* ,* ) ' '
257
252
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)
261
256
else
262
257
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)
266
261
else
267
262
write (* ,* ) func,' =' ,res
268
263
end if
@@ -288,7 +283,6 @@ subroutine fptest6()
288
283
real (wp), dimension (nvar), parameter :: val = [ 2.0_wp , 3.0_wp , 4.0_wp ]
289
284
290
285
type (fparser_array) :: parser
291
- type (list_of_errors) :: error_msg
292
286
real (wp),dimension (nfunc) :: res
293
287
integer :: i ! ! counter
294
288
real (wp) :: x,a,b
@@ -297,15 +291,15 @@ subroutine fptest6()
297
291
write (* ,* ) ' Test 6'
298
292
write (* ,* ) ' '
299
293
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)
303
297
else
304
298
305
299
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)
309
303
else
310
304
do i= 1 ,nfunc
311
305
write (* ,* ) func(i),' =' ,res(i)
0 commit comments