@@ -175,6 +175,7 @@ def check_return(result_array):
175
175
objs = (
176
176
["test" , 6 , 7 ],
177
177
["test_abstract" , 2 , 0 ],
178
+ ["test_external" , 2 , 0 ],
178
179
["test_free" , 2 , 0 ],
179
180
["test_gen_type" , 5 , 1 ],
180
181
["test_generic" , 2 , 0 ],
@@ -586,6 +587,11 @@ def test_diagnostics():
586
587
"""
587
588
Tests some aspects of diagnostics
588
589
"""
590
+
591
+ def check_return (results , ref_results ):
592
+ for i , r in enumerate (results ):
593
+ assert r ["diagnostics" ] == ref_results [i ]
594
+
589
595
string = write_rpc_request (1 , "initialize" , {"rootPath" : test_dir })
590
596
# Test subroutines and functions with interfaces as arguments
591
597
file_path = os .path .join (test_dir , "test_diagnostic_int.f90" )
@@ -607,10 +613,64 @@ def test_diagnostics():
607
613
string += write_rpc_notification (
608
614
"textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
609
615
)
616
+ # Test that externals can be split between multiple lines
617
+ # and that diagnostics for multiple definitions of externals can account
618
+ # for that
619
+ file_path = os .path .join (test_dir , "diag" , "test_external.f90" )
620
+ string += write_rpc_notification (
621
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
622
+ )
610
623
errcode , results = run_request (string )
611
624
assert errcode == 0
612
- # check that the diagnostics list is empty
613
- assert not results [1 ]["diagnostics" ]
625
+ ref_results = [
626
+ [],
627
+ [],
628
+ [],
629
+ [],
630
+ [
631
+ {
632
+ "range" : {
633
+ "start" : {"line" : 7 , "character" : 17 },
634
+ "end" : {"line" : 7 , "character" : 22 },
635
+ },
636
+ "message" : 'Variable "VAR_B" declared twice in scope' ,
637
+ "severity" : 1 ,
638
+ "relatedInformation" : [
639
+ {
640
+ "location" : {
641
+ "uri" : f"file://{ file_path } " ,
642
+ "range" : {
643
+ "start" : {"line" : 5 , "character" : 0 },
644
+ "end" : {"line" : 5 , "character" : 0 },
645
+ },
646
+ },
647
+ "message" : "First declaration" ,
648
+ }
649
+ ],
650
+ },
651
+ {
652
+ "range" : {
653
+ "start" : {"line" : 8 , "character" : 17 },
654
+ "end" : {"line" : 8 , "character" : 22 },
655
+ },
656
+ "message" : 'Variable "VAR_A" declared twice in scope' ,
657
+ "severity" : 1 ,
658
+ "relatedInformation" : [
659
+ {
660
+ "location" : {
661
+ "uri" : f"file://{ file_path } " ,
662
+ "range" : {
663
+ "start" : {"line" : 3 , "character" : 0 },
664
+ "end" : {"line" : 3 , "character" : 0 },
665
+ },
666
+ },
667
+ "message" : "First declaration" ,
668
+ }
669
+ ],
670
+ },
671
+ ],
672
+ ]
673
+ check_return (results [1 :], ref_results )
614
674
615
675
616
676
if __name__ == "__main__" :
0 commit comments