Skip to content

Commit c805615

Browse files
committed
test(pp): add test for preprocessor whitespaces
1 parent aa18a68 commit c805615

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

test/test_preproc_parser.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from __future__ import annotations
2+
3+
from setup_tests import test_dir
4+
5+
from fortls.parsers.internal.parser import preprocess_file
6+
7+
8+
def test_pp_leading_spaces():
9+
root_dir = test_dir / "pp" / "leading_spaces"
10+
file_path = root_dir / "spaces.F90"
11+
with open(file_path, encoding="utf-8") as file:
12+
lines = file.readlines()
13+
_, _, _, defs = preprocess_file(lines)
14+
ref = {
15+
"LEADING_SPACES_INDENT": "1",
16+
"LEADING_SPACES_INDENT2": "True",
17+
"FILE_ENCODING": ",encoding='UTF-8'",
18+
}
19+
assert defs == ref
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#define LEADING_SPACES_INDENT 1
2+
# define LEADING_SPACES_INDENT2
3+
# define FILE_ENCODING ,encoding='UTF-8'
4+
program pp_intentation
5+
implicit none
6+
print*, LEADING_SPACES_INDENT
7+
open(unit=1,file='somefile.txt' FILE_ENCODING)
8+
end program pp_intentation

0 commit comments

Comments
 (0)