Skip to content

Commit 3f87db0

Browse files
committed
refactor: preprocessor elif test
1 parent 0e3baec commit 3f87db0

File tree

5 files changed

+102
-154
lines changed

5 files changed

+102
-154
lines changed

test/test_preproc.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@ def check_return(result_array, checks):
3333
file_path = root_dir / "preproc_else.F90"
3434
string += hover_req(file_path, 8, 12)
3535
string += hover_req(file_path, 18, 12)
36-
file_path = root_dir / "preproc_elif.F90"
37-
string += hover_req(file_path, 15, 12)
38-
string += hover_req(file_path, 19, 15)
39-
string += hover_req(file_path, 21, 10)
40-
string += hover_req(file_path, 46, 36)
41-
string += hover_req(file_path, 76, 36)
42-
string += hover_req(file_path, 106, 36)
43-
string += hover_req(file_path, 136, 36)
36+
file_path = root_dir / "preproc_elif_elif_skip.F90"
37+
string += hover_req(file_path, 24, 23)
38+
file_path = root_dir / "preproc_if_elif_else.F90"
39+
string += hover_req(file_path, 24, 23)
40+
file_path = root_dir / "preproc_if_elif_skip.F90"
41+
string += hover_req(file_path, 24, 23)
4442
config = str(root_dir / ".pp_conf.json")
4543
errcode, results = run_request(string, ["--config", config])
4644
assert errcode == 0
@@ -62,13 +60,9 @@ def check_return(result_array, checks):
6260
"```fortran90\nREAL, CONTIGUOUS, POINTER, DIMENSION(:) :: var1\n```",
6361
"```fortran90\nINTEGER :: var0\n```",
6462
"```fortran90\nREAL :: var1\n```",
65-
"```fortran90\nLOGICAL :: var1\n```",
66-
"```fortran90\nINTEGER :: var2\n```",
67-
"```fortran90\nINTEGER, INTENT(INOUT) :: var\n```",
68-
"```fortran90\nREAL(1, 5, 5, 5) :: var3\n```",
69-
"```fortran90\nREAL(5, 2, 5, 5) :: var4\n```",
70-
"```fortran90\nREAL(5, 5, 5, 4) :: var5\n```",
71-
"```fortran90\nREAL(1, 5, 5, 5) :: var6\n```",
63+
"```fortran90\nINTEGER, PARAMETER :: res = 0+1+0+0\n```",
64+
"```fortran90\nINTEGER, PARAMETER :: res = 0+0+0+1\n```",
65+
"```fortran90\nINTEGER, PARAMETER :: res = 1+0+0+0\n```",
7266
)
7367
assert len(ref_results) == len(results) - 1
7468
check_return(results[1:], ref_results)

test/test_source/pp/preproc_elif.F90

Lines changed: 0 additions & 139 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
subroutine preprocessor_elif_elif_skip()
2+
#if 0
3+
#define PART1 0
4+
#elif 1
5+
#define PART2 1
6+
#elif 1
7+
#define PART3 0
8+
#else
9+
#define PART4 0
10+
#endif
11+
12+
#ifndef PART1
13+
#define PART1 0
14+
#endif
15+
#ifndef PART2
16+
#define PART2 0
17+
#endif
18+
#ifndef PART3
19+
#define PART3 0
20+
#endif
21+
#ifndef PART4
22+
#define PART4 0
23+
#endif
24+
25+
integer, parameter :: res = PART1+PART2+PART3+PART4
26+
27+
#undef PART1
28+
#undef PART2
29+
#undef PART3
30+
#undef PART4
31+
end subroutine preprocessor_elif_elif_skip
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
subroutine preprocessor_if_elif_else()
2+
#if 0
3+
#define PART1 0
4+
#elif 0
5+
#define PART2 0
6+
#elif 0
7+
#define PART3 0
8+
#else
9+
#define PART4 1
10+
#endif
11+
12+
#ifndef PART1
13+
#define PART1 0
14+
#endif
15+
#ifndef PART2
16+
#define PART2 0
17+
#endif
18+
#ifndef PART3
19+
#define PART3 0
20+
#endif
21+
#ifndef PART4
22+
#define PART4 0
23+
#endif
24+
25+
integer, parameter :: res = PART1+PART2+PART3+PART4
26+
27+
#undef PART1
28+
#undef PART2
29+
#undef PART3
30+
#undef PART4
31+
endsubroutine preprocessor_if_elif_else
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
subroutine preprocessor_if_elif_skip()
2+
#if 1
3+
#define PART1 1
4+
#elif 0
5+
#define PART2 0
6+
#elif 1
7+
#define PART3 0
8+
#else
9+
#define PART4 0
10+
#endif
11+
12+
#ifndef PART1
13+
#define PART1 0
14+
#endif
15+
#ifndef PART2
16+
#define PART2 0
17+
#endif
18+
#ifndef PART3
19+
#define PART3 0
20+
#endif
21+
#ifndef PART4
22+
#define PART4 0
23+
#endif
24+
25+
integer, parameter :: res = PART1+PART2+PART3+PART4
26+
27+
#undef PART1
28+
#undef PART2
29+
#undef PART3
30+
#undef PART4
31+
end subroutine preprocessor_if_elif_skip

0 commit comments

Comments
 (0)