Skip to content

Commit fe9d389

Browse files
committed
Added unittest for #if define VAR
1 parent b34363d commit fe9d389

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
- Updated `setup.cfg` in preparation of submitting package to `conda-forge`
88
- Added `Editor Integration` section in documentation
99

10+
### Fixed
11+
12+
- Fixed parsing of `defined` without by parenthesis surrounding the definition
13+
([#67](https://github.com/gnikit/fortls/pull/67))
14+
1015
## 2.2.4
1116

1217
### Fixed

test/test_preproc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def check_return(result_array, checks):
2727
string += hover_req(file_path, 7, 40) # multi-lin variable
2828
string += hover_req(file_path, 8, 7) # function with if conditional
2929
string += hover_req(file_path, 9, 7) # multiline function with if conditional
30+
string += hover_req(file_path, 10, 15) # defined without ()
3031
file_path = root_dir / "preproc_keywords.F90"
3132
string += hover_req(file_path, 6, 2) # ignores PP across Fortran line continuations
3233
config = str(root_dir / ".pp_conf.json")
@@ -40,6 +41,7 @@ def check_return(result_array, checks):
4041
"#define varVar 55",
4142
"#define ewrite if (priority <= 3) write((priority), format)",
4243
"#define ewrite2 if (priority <= 3) write((priority), format)",
44+
"#define SUCCESS .true.",
4345
"REAL, CONTIGUOUS, POINTER, DIMENSION(:)",
4446
)
4547
assert len(ref_results) == len(results) - 1

test/test_source/pp/include/petscerror.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44
#define PETSC_ERR_MEM 55
55
#define PETSC_ERR_INT_OVERFLOW 84
66
#define PETSC_ERR_FLOP_COUNT 90
7+
8+
#if defined PETSC_ERR_MEM || defined PETSC_ERR_INT_OVERFLOW
9+
#define SUCCESS .true.
10+
#endif
11+
712
#endif

test/test_source/pp/preproc.F90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ program preprocessor
88
print*, PETSC_ERR_INT_OVERFLOW, varVar
99
ewrite(1,*) 'Assemble EP P1 matrix and rhs sytem'
1010
ewrite2(1,*) 'Assemble EP P1 matrix and rhs sytem'
11+
print*, SUCCESS
1112

1213
#endif
1314
end program preprocessor

0 commit comments

Comments
 (0)