@@ -218,164 +218,6 @@ def check_return(result_array):
218
218
check_return (results [1 ])
219
219
220
220
221
- def test_comp ():
222
- def check_return (result_array , checks ):
223
- assert len (result_array ) == checks [0 ]
224
- if checks [0 ] > 0 :
225
- assert result_array [0 ]["label" ] == checks [1 ]
226
- assert result_array [0 ]["detail" ] == checks [2 ]
227
- try :
228
- assert result_array [0 ]["insertText" ] == checks [3 ]
229
- except KeyError :
230
- pass
231
-
232
- def comp_request (file_path , line , char ):
233
- return write_rpc_request (
234
- 1 ,
235
- "textDocument/completion" ,
236
- {
237
- "textDocument" : {"uri" : str (file_path )},
238
- "position" : {"line" : line , "character" : char },
239
- },
240
- )
241
-
242
- #
243
- string = write_rpc_request (1 , "initialize" , {"rootPath" : str (test_dir )})
244
- file_path = test_dir / "test_prog.f08"
245
- string += comp_request (file_path , 12 , 6 )
246
- string += comp_request (file_path , 13 , 6 )
247
- string += comp_request (file_path , 17 , 24 )
248
- string += comp_request (file_path , 18 , 23 )
249
- string += comp_request (file_path , 20 , 7 )
250
- string += comp_request (file_path , 21 , 20 )
251
- string += comp_request (file_path , 21 , 42 )
252
- string += comp_request (file_path , 23 , 26 )
253
- file_path = test_dir / "subdir" / "test_submod.F90"
254
- string += comp_request (file_path , 30 , 12 )
255
- string += comp_request (file_path , 31 , 8 )
256
- string += comp_request (file_path , 31 , 23 )
257
- string += comp_request (file_path , 35 , 12 )
258
- string += comp_request (file_path , 36 , 48 )
259
- file_path = test_dir / "test_inc.f90"
260
- string += comp_request (file_path , 10 , 2 )
261
- file_path = test_dir / "subdir" / "test_inc2.f90"
262
- string += comp_request (file_path , 3 , 2 )
263
- file_path = test_dir / "subdir" / "test_abstract.f90"
264
- string += comp_request (file_path , 7 , 12 )
265
- file_path = test_dir / "subdir" / "test_free.f90"
266
- string += comp_request (file_path , 10 , 22 )
267
- string += comp_request (file_path , 14 , 27 )
268
- string += comp_request (file_path , 28 , 15 )
269
- file_path = test_dir / "subdir" / "test_fixed.f"
270
- string += comp_request (file_path , 15 , 8 )
271
- string += comp_request (file_path , 15 , 21 )
272
- file_path = test_dir / "subdir" / "test_select.f90"
273
- string += comp_request (file_path , 21 , 7 )
274
- string += comp_request (file_path , 23 , 7 )
275
- string += comp_request (file_path , 25 , 7 )
276
- string += comp_request (file_path , 30 , 7 )
277
- file_path = test_dir / "test_block.f08"
278
- string += comp_request (file_path , 2 , 2 )
279
- string += comp_request (file_path , 5 , 4 )
280
- string += comp_request (file_path , 8 , 6 )
281
- file_path = test_dir / "subdir" / "test_generic.f90"
282
- string += comp_request (file_path , 14 , 10 )
283
- file_path = test_dir / "subdir" / "test_inherit.f90"
284
- string += comp_request (file_path , 10 , 11 )
285
- file_path = test_dir / "subdir" / "test_rename.F90"
286
- string += comp_request (file_path , 13 , 5 )
287
- string += comp_request (file_path , 14 , 5 )
288
- file_path = test_dir / "subdir" / "test_vis.f90"
289
- string += comp_request (file_path , 8 , 10 )
290
- file_path = test_dir / "test_import.f90"
291
- string += comp_request (file_path , 15 , 20 )
292
- file_path = test_dir / "completion" / "test_vis_mod_completion.f90"
293
- string += comp_request (file_path , 12 , 16 )
294
- string += comp_request (file_path , 12 , 24 )
295
- errcode , results = run_request (string , ["--use_signature_help" ])
296
- assert errcode == 0
297
-
298
- string = write_rpc_request (1 , "initialize" , {"rootPath" : str (test_dir )})
299
- file_path = test_dir / "test_prog.f08"
300
- string += comp_request (file_path , 12 , 6 )
301
- errcode , res = run_request (string )
302
- assert errcode == 0
303
- results .extend (res [1 :])
304
-
305
- #
306
- exp_results = (
307
- # test_prog.f08
308
- [1 , "myfun" , "DOUBLE PRECISION FUNCTION myfun(n, xval)" , "myfun" ],
309
- [9 , "glob_sub" , "SUBROUTINE glob_sub(n, xval, yval)" , "glob_sub" ],
310
- [1 , "bound_nopass" , "SUBROUTINE bound_nopass(a, b)" , "bound_nopass" ],
311
- [1 , "bound_pass" , "SUBROUTINE bound_pass(arg1)" , "bound_pass" ],
312
- [1 , "stretch_vector" , "TYPE(scaled_vector)" ],
313
- [6 , "scale" , "TYPE(scale_type)" ],
314
- [2 , "n" , "INTEGER(4)" ],
315
- [1 , "val" , "REAL(8)" ],
316
- # subdir/test_submod.F90
317
- [1 , "point" , "TYPE" ],
318
- [1 , "distance" , "REAL" ],
319
- [2 , "x" , "REAL" ],
320
- [1 , "point" , "TYPE" ],
321
- [2 , "x" , "REAL" ],
322
- # test_inc.f90
323
- [2 , "val1" , "REAL(8)" ],
324
- # subdir/test_inc2.f90
325
- [2 , "val1" , "REAL(8)" ],
326
- # subdir/test_abstract.f90
327
- [1 , "abs_interface" , "SUBROUTINE" ],
328
- # subdir/test_free.f90
329
- [1 , "DIMENSION(:)" , "KEYWORD" ],
330
- [2 , "vector_create" , "SUBROUTINE" ],
331
- [3 , "INTENT(IN)" , "KEYWORD" ],
332
- # subdir/test_fixed.f90
333
- [1 , "bob" , "CHARACTER*(LEN=200)" ],
334
- [1 , "dave" , "CHARACTER*(20)" ],
335
- # subdir/test_select.f90
336
- [2 , "a" , "REAL(8)" ],
337
- [2 , "a" , "COMPLEX(8)" ],
338
- [1 , "n" , "INTEGER(4)" ],
339
- [2 , "a" , "REAL(8)" ],
340
- # test_block.f08
341
- [9 , "READ" , "STATEMENT" ],
342
- [10 , "READ" , "STATEMENT" ],
343
- [11 , "READ" , "STATEMENT" ],
344
- # subdir/test_generic.f90
345
- [
346
- 4 ,
347
- "my_gen" ,
348
- "SUBROUTINE my_gen(self, a, b)" ,
349
- "my_gen(${1:self}, ${2:a}, ${3:b})" ,
350
- ],
351
- # subdir/test_inherit.f90
352
- [1 , "val" , "REAL(8)" ],
353
- # subdir/test_rename.F90
354
- [1 , "localname" , "INTEGER" ],
355
- [2 , "renamed_var2" , "REAL(8)" ],
356
- # subdir/test_vis.f90
357
- [3 , "some_type" , "TYPE" ],
358
- # test_import.f90
359
- # TODO: this should be 1, mytype2 should not appear in autocomplete
360
- # see #5 and #8 on GitHub
361
- [2 , "mytype" , "TYPE" ],
362
- # completion/test_vis_mod_completion.f90
363
- [1 , "some_var" , "INTEGER" ],
364
- [3 , "length" , "INTEGER" ],
365
- # test_prog.f08, completion without signature_help
366
- # returns the entire completion as a snippet
367
- [
368
- 1 ,
369
- "myfun" ,
370
- "DOUBLE PRECISION FUNCTION myfun(n, xval)" ,
371
- "myfun(${1:n}, ${2:xval})" ,
372
- ],
373
- )
374
- assert len (exp_results ) + 1 == len (results )
375
- for i in range (len (exp_results )):
376
- check_return (results [i + 1 ], exp_results [i ])
377
-
378
-
379
221
def test_sig ():
380
222
def check_return (results , checks ):
381
223
assert results .get ("activeParameter" , - 1 ) == checks [0 ]
0 commit comments