Skip to content

Commit c5d9cf0

Browse files
committed
test: Add test for preprocessor if and elif parsing
1 parent ec0dbef commit c5d9cf0

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

test/test_preproc.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ def check_return(result_array, checks):
3030
string += hover_req(file_path, 10, 15) # defined without ()
3131
file_path = root_dir / "preproc_keywords.F90"
3232
string += hover_req(file_path, 6, 2) # ignores PP across Fortran line continuations
33+
file_path = root_dir / "preproc_elif.F90"
34+
string += hover_req(file_path, 8, 12)
35+
string += hover_req(file_path, 20, 12)
36+
string += hover_req(file_path, 32, 12)
37+
string += hover_req(file_path, 44, 12)
38+
string += hover_req(file_path, 54, 12)
39+
string += hover_req(file_path, 66, 12)
3340
config = str(root_dir / ".pp_conf.json")
3441
errcode, results = run_request(string, ["--config", config])
3542
assert errcode == 0
@@ -49,6 +56,12 @@ def check_return(result_array, checks):
4956
),
5057
"```fortran90\n#define SUCCESS .true.\n```",
5158
"```fortran90\nREAL, CONTIGUOUS, POINTER, DIMENSION(:) :: var1\n```",
59+
"```fortran90\nINTEGER :: var0\n```",
60+
"```fortran90\nCHARACTER :: var1\n```",
61+
"```fortran90\nLOGICAL :: var2\n```",
62+
"```fortran90\nINTEGER :: var3\n```",
63+
"```fortran90\nREAL :: var4\n```",
64+
"```fortran90\nINTEGER :: var5\n```",
5265
)
5366
assert len(ref_results) == len(results) - 1
5467
check_return(results[1:], ref_results)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
subroutine preprocessor_elif(var)
2+
3+
#if 0
4+
#define MYTYPE logical
5+
#else
6+
#define MYTYPE integer
7+
#endif
8+
9+
MYTYPE :: var0
10+
11+
#undef MYTYPE
12+
13+
#if 1
14+
#define MYTYPE character
15+
#elif 0
16+
#define MYTYPE logical
17+
#else
18+
#define MYTYPE integer
19+
#endif
20+
21+
MYTYPE :: var1
22+
23+
#undef MYTYPE
24+
25+
#if 0
26+
#define MYTYPE character
27+
#elif 1
28+
#define MYTYPE logical
29+
#else
30+
#define MYTYPE integer
31+
#endif
32+
33+
MYTYPE :: var2
34+
35+
#undef MYTYPE
36+
37+
#if 0
38+
#define MYTYPE character
39+
#elif 0
40+
#define MYTYPE real
41+
#else
42+
#define MYTYPE integer
43+
#endif
44+
45+
MYTYPE :: var3
46+
47+
#undef MYTYPE
48+
49+
#if 0
50+
#define MYTYPE character
51+
#elif 1
52+
#define MYTYPE real
53+
#endif
54+
55+
MYTYPE :: var4
56+
57+
#undef MYTYPE
58+
59+
#if 0
60+
#define MYTYPE character
61+
#elif 0
62+
#define MYTYPE real
63+
#elif 1
64+
#define MYTYPE integer
65+
#endif
66+
67+
MYTYPE :: var5
68+
69+
endsubroutine preprocessor_elif

0 commit comments

Comments
 (0)