Skip to content

Commit 7f892ac

Browse files
committed
test: Add test for preprocessor #if-#else parsing
1 parent 27b9d49 commit 7f892ac

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/test_preproc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ 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_else.F90"
34+
string += hover_req(file_path, 8, 12)
35+
string += hover_req(file_path, 18, 12)
3336
config = str(root_dir / ".pp_conf.json")
3437
errcode, results = run_request(string, ["--config", config])
3538
assert errcode == 0
@@ -49,6 +52,8 @@ def check_return(result_array, checks):
4952
),
5053
"```fortran90\n#define SUCCESS .true.\n```",
5154
"```fortran90\nREAL, CONTIGUOUS, POINTER, DIMENSION(:) :: var1\n```",
55+
"```fortran90\nINTEGER :: var0\n```",
56+
"```fortran90\nREAL :: var1\n```",
5257
)
5358
assert len(ref_results) == len(results) - 1
5459
check_return(results[1:], ref_results)

test/test_source/pp/preproc_else.F90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
subroutine preprocessor_else(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 real
15+
#else
16+
#define MYTYPE character
17+
#endif
18+
19+
MYTYPE :: var1
20+
21+
endsubroutine preprocessor_else

0 commit comments

Comments
 (0)