@@ -49,6 +49,15 @@ def check_return(result_dict):
49
49
check_return (results [0 ])
50
50
51
51
52
+ def test_logger ():
53
+ """Test the logger"""
54
+ string = write_rpc_request (1 , "initialize" , {"rootPath" : test_dir })
55
+ errcode , results = run_request (string , " --debug_log" )
56
+ assert errcode == 0
57
+ assert results [1 ]["type" ] == 3
58
+ assert results [1 ]["message" ] == "FORTLS debugging enabled"
59
+
60
+
52
61
def test_open ():
53
62
string = write_rpc_request (1 , "initialize" , {"rootPath" : test_dir })
54
63
file_path = os .path .join (test_dir , "subdir" , "test_free.f90" )
@@ -178,13 +187,15 @@ def check_return(result_array):
178
187
objs = (
179
188
["test" , 6 , 7 ],
180
189
["test_abstract" , 2 , 0 ],
190
+ ["test_enum" , 2 , 0 ],
181
191
["test_external" , 2 , 0 ],
182
192
["test_forall" , 2 , 0 ],
183
193
["test_free" , 2 , 0 ],
184
194
["test_gen_type" , 5 , 1 ],
185
195
["test_generic" , 2 , 0 ],
186
196
["test_inherit" , 2 , 0 ],
187
197
["test_int" , 2 , 0 ],
198
+ ["test_lines" , 2 , 0 ],
188
199
["test_mod" , 2 , 0 ],
189
200
["test_nonint_mod" , 2 , 0 ],
190
201
["test_preproc_keywords" , 2 , 0 ],
@@ -193,12 +204,14 @@ def check_return(result_array):
193
204
["test_rename_sub" , 6 , 9 ],
194
205
["test_select" , 2 , 0 ],
195
206
["test_select_sub" , 6 , 16 ],
207
+ ["test_semicolon" , 2 , 0 ],
196
208
["test_sig_Sub" , 6 , 67 ],
197
209
["test_str1" , 13 , 5 ],
198
210
["test_str2" , 13 , 5 ],
199
211
["test_sub" , 6 , 8 ],
200
212
["test_use_ordering" , 2 , 9 ],
201
213
["test_vis_mod" , 2 , 0 ],
214
+ ["test_where" , 2 , 0 ],
202
215
)
203
216
assert len (result_array ) == len (objs )
204
217
for i , obj in enumerate (objs ):
@@ -657,8 +670,37 @@ def check_return(results, ref_results):
657
670
string += write_rpc_notification (
658
671
"textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
659
672
)
673
+ # Test where blocks
674
+ file_path = os .path .join (test_dir , "diag" , "test_where.f90" )
675
+ string += write_rpc_notification (
676
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
677
+ )
678
+ # Test where semicolon (multi-line)
679
+ file_path = os .path .join (test_dir , "diag" , "test_semicolon.f90" )
680
+ string += write_rpc_notification (
681
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
682
+ )
683
+ # Test ENUM block
684
+ file_path = os .path .join (test_dir , "diag" , "test_enum.f90" )
685
+ string += write_rpc_notification (
686
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
687
+ )
660
688
errcode , results = run_request (string )
661
689
assert errcode == 0
690
+
691
+ # Load a different config file
692
+ # Test long lines
693
+ root = os .path .join (test_dir , "diag" )
694
+ string = write_rpc_request (1 , "initialize" , {"rootPath" : root })
695
+ file_path = os .path .join (test_dir , "diag" , "test_lines.f90" )
696
+ string += write_rpc_notification (
697
+ "textDocument/didOpen" , {"textDocument" : {"uri" : file_path }}
698
+ )
699
+ file_path = os .path .join (test_dir , "diag" , "conf_long_lines.json" )
700
+ errcode , res = run_request (string , f" --config { file_path } " )
701
+ assert errcode == 0
702
+ results .extend (res [1 :])
703
+
662
704
root = Path (test_dir )
663
705
ref_results = [
664
706
[],
@@ -709,12 +751,36 @@ def check_return(results, ref_results):
709
751
],
710
752
[],
711
753
[],
754
+ [],
755
+ [],
756
+ [],
757
+ [
758
+ {
759
+ "range" : {
760
+ "start" : {"line" : 2 , "character" : 100 },
761
+ "end" : {"line" : 2 , "character" : 155 },
762
+ },
763
+ "message" : 'Line length exceeds "max_line_length" (100)' ,
764
+ "severity" : 2 ,
765
+ },
766
+ {
767
+ "range" : {
768
+ "start" : {"line" : 3 , "character" : 100 },
769
+ "end" : {"line" : 3 , "character" : 127 },
770
+ },
771
+ "message" : (
772
+ 'Comment line length exceeds "max_comment_line_length" (100)'
773
+ ),
774
+ "severity" : 2 ,
775
+ },
776
+ ],
712
777
]
713
778
check_return (results [1 :], ref_results )
714
779
715
780
716
781
if __name__ == "__main__" :
717
782
test_init ()
783
+ test_logger ()
718
784
test_open ()
719
785
test_change ()
720
786
test_symbols ()
0 commit comments