1
- from pathlib import Path
2
-
3
1
# from types import NoneType
4
2
from setup_tests import (
5
3
path_to_uri ,
@@ -233,6 +231,10 @@ def check_return(result_array, checks):
233
231
if checks [0 ] > 0 :
234
232
assert result_array [0 ]["label" ] == checks [1 ]
235
233
assert result_array [0 ]["detail" ] == checks [2 ]
234
+ try :
235
+ assert result_array [0 ]["insertText" ] == checks [3 ]
236
+ except KeyError :
237
+ pass
236
238
237
239
def comp_request (file_path , line , char ):
238
240
return write_rpc_request (
@@ -296,15 +298,23 @@ def comp_request(file_path, line, char):
296
298
file_path = test_dir / "completion" / "test_vis_mod_completion.f90"
297
299
string += comp_request (file_path , 12 , 16 )
298
300
string += comp_request (file_path , 12 , 24 )
299
- errcode , results = run_request (string )
301
+ errcode , results = run_request (string , ["--use_signature_help" ])
302
+ assert errcode == 0
303
+
304
+ string = write_rpc_request (1 , "initialize" , {"rootPath" : str (test_dir )})
305
+ file_path = test_dir / "test_prog.f08"
306
+ string += comp_request (file_path , 12 , 6 )
307
+ errcode , res = run_request (string )
300
308
assert errcode == 0
309
+ results .extend (res [1 :])
310
+
301
311
#
302
312
exp_results = (
303
313
# test_prog.f08
304
- [1 , "myfun" , "DOUBLE PRECISION FUNCTION myfun(n, xval)" ],
305
- [9 , "glob_sub" , "SUBROUTINE glob_sub(n, xval, yval)" ],
306
- [1 , "bound_nopass" , "SUBROUTINE bound_nopass(a, b)" ],
307
- [1 , "bound_pass" , "SUBROUTINE bound_pass(arg1)" ],
314
+ [1 , "myfun" , "DOUBLE PRECISION FUNCTION myfun(n, xval)" , "myfun" ],
315
+ [9 , "glob_sub" , "SUBROUTINE glob_sub(n, xval, yval)" , "glob_sub" ],
316
+ [1 , "bound_nopass" , "SUBROUTINE bound_nopass(a, b)" , "bound_nopass" ],
317
+ [1 , "bound_pass" , "SUBROUTINE bound_pass(arg1)" , "bound_pass" ],
308
318
[1 , "stretch_vector" , "TYPE(scaled_vector)" ],
309
319
[6 , "scale" , "TYPE(scale_type)" ],
310
320
[2 , "n" , "INTEGER(4)" ],
@@ -337,7 +347,12 @@ def comp_request(file_path, line, char):
337
347
[10 , "READ" , "STATEMENT" ],
338
348
[11 , "READ" , "STATEMENT" ],
339
349
# subdir/test_generic.f90
340
- [4 , "my_gen" , "SUBROUTINE my_gen(self, a, b)" ],
350
+ [
351
+ 4 ,
352
+ "my_gen" ,
353
+ "SUBROUTINE my_gen(self, a, b)" ,
354
+ "my_gen(${1:self}, ${2:a}, ${3:b})" ,
355
+ ],
341
356
# subdir/test_inherit.f90
342
357
[1 , "val" , "REAL(8)" ],
343
358
# subdir/test_rename.F90
@@ -352,6 +367,14 @@ def comp_request(file_path, line, char):
352
367
# completion/test_vis_mod_completion.f90
353
368
[1 , "some_var" , "INTEGER" ],
354
369
[3 , "length" , "INTEGER" ],
370
+ # test_prog.f08, completion without signature_help
371
+ # returns the entire completion as a snippet
372
+ [
373
+ 1 ,
374
+ "myfun" ,
375
+ "DOUBLE PRECISION FUNCTION myfun(n, xval)" ,
376
+ "myfun(${1:n}, ${2:xval})" ,
377
+ ],
355
378
)
356
379
assert len (exp_results ) + 1 == len (results )
357
380
for i in range (len (exp_results )):
0 commit comments