-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathtest_parser.py
50 lines (41 loc) · 1.35 KB
/
test_parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from setup_tests import test_dir
from fortls.parsers.internal.parser import FortranFile
def test_line_continuations():
file_path = test_dir / "parse" / "line_continuations.f90"
file = FortranFile(str(file_path))
err_str, _ = file.load_from_disk()
assert err_str is None
try:
file.parse()
assert True
except Exception as e:
print(e)
assert False
def test_submodule():
file_path = test_dir / "parse" / "submodule.f90"
file = FortranFile(str(file_path))
err_str, _ = file.load_from_disk()
assert err_str is None
try:
ast = file.parse()
assert True
assert ast.scope_list[0].name == "val"
assert ast.scope_list[0].ancestor_name == "p1"
assert ast.scope_list[1].name == ""
assert ast.scope_list[1].ancestor_name == "p2"
except Exception as e:
print(e)
assert False
def test_private_visibility_interfaces():
file_path = test_dir / "vis" / "private.f90"
file = FortranFile(str(file_path))
err_str, _ = file.load_from_disk()
file.parse()
assert err_str is None
def test_end_scopes_semicolon():
file_path = test_dir / "parse" / "trailing_semicolon.f90"
file = FortranFile(str(file_path))
err_str, _ = file.load_from_disk()
ast = file.parse()
assert err_str is None
assert not ast.end_errors