@@ -170,94 +170,113 @@ subroutine test_46(error_cnt)
170170
171171 ! unicode:
172172 call json_f% get(CK_' not_there' , ival, found, default= 99_IK )
173- if (json % failed() .or. found .or. ival /= 99_IK ) then
173+ if (json_f % failed() .or. found .or. ival /= 99_IK ) then
174174 write (error_unit,' (A)' ) ' Error using json_get_integer_by_path default'
175175 error_cnt = error_cnt + 1
176176 end if
177177
178178 call json_f% get(CK_' not_there' , rval, found, default= 99.0_RK )
179- if (json % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
179+ if (json_f % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
180180 write (error_unit,' (A)' ) ' Error using json_get_real_by_path default'
181181 error_cnt = error_cnt + 1
182182 end if
183183
184184 call json_f% get(CK_' not_there' , lval, found, default= .true. )
185- if (json % failed() .or. found .or. lval .neqv. .true. ) then
185+ if (json_f % failed() .or. found .or. lval .neqv. .true. ) then
186186 write (error_unit,' (A)' ) ' Error using json_get_logical_by_path default'
187187 error_cnt = error_cnt + 1
188188 end if
189189
190190 call json_f% get(CK_' not_there' , cval, found, default= CK_' default' )
191- if (json % failed() .or. found .or. cval /= CK_' default' ) then
191+ if (json_f % failed() .or. found .or. cval /= CK_' default' ) then
192192 write (error_unit,' (A)' ) ' Error using json_get_string_by_path default'
193193 error_cnt = error_cnt + 1
194194 end if
195195
196196 call json_f% get(CK_' not_there' , cvec, found, default= cvec_default)
197- if (json % failed() .or. found .or. any (cvec /= cvec_default)) then
197+ if (json_f % failed() .or. found .or. any (cvec /= cvec_default)) then
198198 write (error_unit,' (A)' ) ' Error using json_get_string_vec_by_path default'
199199 error_cnt = error_cnt + 1
200200 end if
201201 call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default)
202- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
202+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
203203 write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
204204 error_cnt = error_cnt + 1
205205 end if
206206 call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default, default_ilen= ilen_default)
207- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
207+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
208208 write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
209209 error_cnt = error_cnt + 1
210210 end if
211211
212212 ! default:
213213 call json_f% get(' not_there' , ival, found, default= 99_IK )
214- if (json % failed() .or. found .or. ival /= 99_IK ) then
214+ if (json_f % failed() .or. found .or. ival /= 99_IK ) then
215215 write (error_unit,' (A)' ) ' Error using json_get_integer_by_path default'
216216 error_cnt = error_cnt + 1
217217 end if
218218
219219 call json_f% get(' not_there' , rval, found, default= 99.0_RK )
220- if (json % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
220+ if (json_f % failed() .or. found .or. rval-99.0_RK > 0.0_RK ) then
221221 write (error_unit,' (A)' ) ' Error using json_get_real_by_path default'
222222 error_cnt = error_cnt + 1
223223 end if
224224
225225 call json_f% get(' not_there' , lval, found, default= .true. )
226- if (json % failed() .or. found .or. lval .neqv. .true. ) then
226+ if (json_f % failed() .or. found .or. lval .neqv. .true. ) then
227227 write (error_unit,' (A)' ) ' Error using json_get_logical_by_path default'
228228 error_cnt = error_cnt + 1
229229 end if
230230
231231 call json_f% get(' not_there' , cval, found, default= CK_' default' )
232- if (json % failed() .or. found .or. cval /= CK_' default' ) then
232+ if (json_f % failed() .or. found .or. cval /= CK_' default' ) then
233233 write (error_unit,' (A)' ) ' Error using json_get_string_by_path default'
234234 error_cnt = error_cnt + 1
235235 end if
236236
237237 call json_f% get(' not_there' , cvec, found, default= cvec_default)
238- if (json % failed() .or. found .or. any (cvec /= cvec_default)) then
238+ if (json_f % failed() .or. found .or. any (cvec /= cvec_default)) then
239239 write (error_unit,' (A)' ) ' Error using json_get_string_vec_by_path default'
240240 error_cnt = error_cnt + 1
241241 end if
242242 call json_f% get(' not_there' , cvec2, ilen, found, default= cvec_default)
243- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
243+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
244244 write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
245245 error_cnt = error_cnt + 1
246246 end if
247247 call json_f% get(' not_there' , cvec2, ilen, found, default= cvec_default, default_ilen= ilen_default)
248- if (json % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
248+ if (json_f % failed() .or. found .or. any (cvec2 /= cvec_default) .or. any (ilen/= 1_IK )) then
249249 write (error_unit,' (A)' ) ' Error using json_get_alloc_string_vec_by_path default'
250250 error_cnt = error_cnt + 1
251251 end if
252252
253- ! now, we try them when an exception is active:
254253 call json_f% destroy()
255- json_f = json_file(CK_' {"x": 1.0e.2.1}' ) ! this will raise an exception
254+
255+ json_f = str ! this should succeed
256+ if (json_f% failed()) then
257+ write (error_unit,' (A)' ) ' Error in json_file = string assignment operator'
258+ error_cnt = error_cnt + 1
259+ end if
260+
261+ ! now, we try them when an exception is active:
262+ json_f = CK_' {"x": 1.0e.2.1}' ! this will raise an exception
263+ if (.not. json_f% failed()) then
264+ write (error_unit,' (A)' ) ' Error in json_file = string assignment operator : ' // &
265+ ' should have raised an exception'
266+ error_cnt = error_cnt + 1
267+ end if
268+
256269 call json_f% get(CK_' not_there' , rval, found, default= 99.0_RK )
257270 call json_f% get(CK_' not_there' , cvec, found, default= [CK_' 1' ])
258271 call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default)
259272 call json_f% get(CK_' not_there' , cvec2, ilen, found, default= cvec_default, default_ilen= ilen_default)
260273
274+ json_f = str ! now, try again after a failure
275+ if (json_f% failed()) then
276+ write (error_unit,' (A)' ) ' Error in json_file = string assignment operator'
277+ error_cnt = error_cnt + 1
278+ end if
279+
261280 if (error_cnt== 0 ) then
262281 write (error_unit,' (A)' ) ' Success!'
263282 else
0 commit comments