Skip to content

Commit

Permalink
test(pp): add test for preprocessor whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
gnikit committed Apr 13, 2024
1 parent aa18a68 commit c805615
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/test_preproc_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import annotations

from setup_tests import test_dir

from fortls.parsers.internal.parser import preprocess_file


def test_pp_leading_spaces():
root_dir = test_dir / "pp" / "leading_spaces"
file_path = root_dir / "spaces.F90"
with open(file_path, encoding="utf-8") as file:
lines = file.readlines()
_, _, _, defs = preprocess_file(lines)
ref = {
"LEADING_SPACES_INDENT": "1",
"LEADING_SPACES_INDENT2": "True",
"FILE_ENCODING": ",encoding='UTF-8'",
}
assert defs == ref
8 changes: 8 additions & 0 deletions test/test_source/pp/leading_spaces/spaces.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#define LEADING_SPACES_INDENT 1
# define LEADING_SPACES_INDENT2
# define FILE_ENCODING ,encoding='UTF-8'
program pp_intentation
implicit none
print*, LEADING_SPACES_INDENT
open(unit=1,file='somefile.txt' FILE_ENCODING)
end program pp_intentation

0 comments on commit c805615

Please sign in to comment.