@@ -262,6 +262,14 @@ def test_contains():
262
262
"message" : "CONTAINS statement without enclosing scope" ,
263
263
"severity" : 1 ,
264
264
},
265
+ {
266
+ "range" : {
267
+ "start" : {"line" : 8 , "character" : 0 },
268
+ "end" : {"line" : 8 , "character" : 0 },
269
+ },
270
+ "message" : "Subroutine/Function definition before CONTAINS statement" ,
271
+ "severity" : 1 ,
272
+ },
265
273
]
266
274
267
275
@@ -277,10 +285,109 @@ def test_visibility():
277
285
assert results [1 ]["diagnostics" ] == [
278
286
{
279
287
"range" : {
280
- "start" : {"line" : 3 , "character" : 0 },
281
- "end" : {"line" : 3 , "character" : 0 },
288
+ "start" : {"line" : 5 , "character" : 0 },
289
+ "end" : {"line" : 5 , "character" : 0 },
282
290
},
283
291
"message" : "Visibility statement without enclosing scope" ,
284
292
"severity" : 1 ,
293
+ },
294
+ {
295
+ "range" : {
296
+ "start" : {"line" : 1 , "character" : 8 },
297
+ "end" : {"line" : 1 , "character" : 26 },
298
+ },
299
+ "message" : 'Module "nonexisting_module" not found in project' ,
300
+ "severity" : 3 ,
301
+ },
302
+ {
303
+ "range" : {
304
+ "start" : {"line" : 3 , "character" : 8 },
305
+ "end" : {"line" : 3 , "character" : 11 },
306
+ },
307
+ "message" : 'Module "mod" not found in project' ,
308
+ "severity" : 3 ,
309
+ },
310
+ {
311
+ "range" : {
312
+ "start" : {"line" : 2 , "character" : 4 },
313
+ "end" : {"line" : 2 , "character" : 12 },
314
+ },
315
+ "message" : "USE statements after IMPLICIT statement" ,
316
+ "severity" : 1 ,
317
+ },
318
+ ]
319
+
320
+
321
+ def test_import ():
322
+ string = write_rpc_request (1 , "initialize" , {"rootPath" : str (test_dir )})
323
+ # Test module procedure in submodules importing scopes
324
+ file_path = str (test_dir / "diag" / "test_import.f90" )
325
+ string += write_rpc_notification (
326
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
327
+ )
328
+ errcode , results = run_request (string )
329
+ assert errcode == 0
330
+ assert results [1 ]["diagnostics" ] == [
331
+ {
332
+ "range" : {
333
+ "start" : {"line" : 1 , "character" : 0 },
334
+ "end" : {"line" : 1 , "character" : 0 },
335
+ },
336
+ "message" : "IMPORT statement outside of interface" ,
337
+ "severity" : 1 ,
338
+ }
339
+ ]
340
+
341
+
342
+ def test_variable ():
343
+ string = write_rpc_request (1 , "initialize" , {"rootPath" : str (test_dir )})
344
+ # Test module procedure in submodules importing scopes
345
+ file_path = str (test_dir / "diag" / "test_variable.f90" )
346
+ string += write_rpc_notification (
347
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
348
+ )
349
+ errcode , results = run_request (string )
350
+ assert errcode == 0
351
+ assert results [1 ]["diagnostics" ] == [
352
+ {
353
+ "range" : {
354
+ "start" : {"line" : 4 , "character" : 19 },
355
+ "end" : {"line" : 4 , "character" : 22 },
356
+ },
357
+ "message" : 'Variable "val" masks variable in parent scope' ,
358
+ "severity" : 2 ,
359
+ "relatedInformation" : [
360
+ {
361
+ "location" : {
362
+ "uri" : path_to_uri (str (file_path )),
363
+ "range" : {
364
+ "start" : {"line" : 1 , "character" : 0 },
365
+ "end" : {"line" : 1 , "character" : 0 },
366
+ },
367
+ },
368
+ "message" : "First declaration" ,
369
+ }
370
+ ],
371
+ }
372
+ ]
373
+
374
+
375
+ def test_function ():
376
+ string = write_rpc_request (1 , "initialize" , {"rootPath" : str (test_dir )})
377
+ # Test module procedure in submodules importing scopes
378
+ file_path = str (test_dir / "diag" / "test_function.f90" )
379
+ string += write_rpc_notification (
380
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
381
+ )
382
+ errcode , results = run_request (string )
383
+ assert errcode == 0
384
+ assert results [1 ]["diagnostics" ] == [
385
+ {
386
+ "range" : {
387
+ "start" : {"line" : 3 , "character" : 31 },
388
+ "end" : {"line" : 3 , "character" : 34 },
389
+ },
390
+ "message" : 'Variable "bar" with INTENT keyword not found in argument list' ,
391
+ "severity" : 1 ,
285
392
}
286
393
]
0 commit comments