Skip to content

Commit e0d0a86

Browse files
Add and update tests
1 parent 5954122 commit e0d0a86

5 files changed

Lines changed: 56 additions & 2 deletions

File tree

run_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def main():
4242
ast_cpp = test.get("ast_cpp", False)
4343
ast_cpp_hip = test.get("ast_cpp_hip", False)
4444
ast_openmp = test.get("ast_openmp", False)
45+
ast_new = test.get("ast_new", False)
4546
asr = test.get("asr", False)
4647
asr_preprocess = test.get("asr_preprocess", False)
4748
asr_indent = test.get("asr_indent", False)
@@ -63,6 +64,10 @@ def main():
6364
run_test("ast", "lpython --show-ast --no-color {infile} -o {outfile}",
6465
filename, update_reference, extra_args)
6566

67+
if ast_new:
68+
run_test("ast_new", "lpython --show-ast --new-parser --no-color {infile} -o {outfile}",
69+
filename, update_reference, extra_args)
70+
6671
if asr:
6772
run_test("asr", "lpython --show-asr --no-color {infile} -o {outfile}",
6873
filename, update_reference, extra_args)

tests/parser/import1.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# AST tests only
2+
3+
import os
4+
import random as r
5+
import random as r, abc as a
6+
import x.y.z
7+
import x.y.z as xyz
8+
9+
from ltypes import i8, i16, i32, i64, f32, f64, \
10+
c32, c64, overload, ccall, TypeVar
11+
from __future__ import division
12+
from math import *
13+
from math import (sin, cos, tan)
14+
from math import sin, cos
15+
from math import factorial as fact
16+
from x.y import z
17+
from . import a
18+
from .a.b import a
19+
from .a.b import *
20+
from .abc import a
21+
from .abc import (a, b, c)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"basename": "ast_new-import1-f643fd3",
3+
"cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}",
4+
"infile": "tests/parser/import1.py",
5+
"infile_hash": "87d09a5deba632cbd38045f935398a8a882e0958f810aada84883f86",
6+
"outfile": null,
7+
"outfile_hash": null,
8+
"stdout": "ast_new-import1-f643fd3.stdout",
9+
"stdout_hash": "912bb6761751cb6b99aaf7b80ccd4eae03cfa13ae0879c88b7e5ddd3",
10+
"stderr": null,
11+
"stderr_hash": null,
12+
"returncode": 0
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(Module [(Import [(os ())]) (Import [(random r)]) (Import [(random r) (abc a)]) (Import [(x.y.z ())]) (Import [(x.y.z xyz)]) (ImportFrom ltypes [(i8 ()) (i16 ()) (i32 ()) (i64 ()) (f32 ()) (f64 ()) (c32 ()) (c64 ()) (overload ()) (ccall ()) (TypeVar ())] 0) (ImportFrom __future__ [(division ())] 0) (ImportFrom math [(* ())] 0) (ImportFrom math [(sin ()) (cos ()) (tan ())] 0) (ImportFrom math [(sin ()) (cos ())] 0) (ImportFrom math [(factorial fact)] 0) (ImportFrom x.y [(z ())] 0) (ImportFrom () [(a ())] 1) (ImportFrom a.b [(a ())] 1) (ImportFrom a.b [(* ())] 1) (ImportFrom abc [(a ())] 1) (ImportFrom abc [(a ()) (b ()) (c ())] 1)] [])

tests/tests.toml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# llvm ... run the Semantics and output LLVM, compare against reference version
55
# tokens ... output Tokens, compare against reference version
66

7+
# tests
8+
79
[[test]]
810
filename = "doconcurrentloop_01.py"
911
ast = true
@@ -166,6 +168,8 @@ filename = "global_scope1.py"
166168
ast = true
167169
asr = true
168170

171+
# integration_tests
172+
169173
[[test]]
170174
filename = "../integration_tests/test_builtin.py"
171175
asr = true
@@ -214,6 +218,12 @@ asr = true
214218
filename = "../integration_tests/test_builtin_oct.py"
215219
asr = true
216220

221+
[[test]]
222+
filename = "../integration_tests/test_max_min.py"
223+
asr = true
224+
225+
# tests/tokens
226+
217227
[[test]]
218228
filename = "tokens/docstring1.py"
219229
tokens = true
@@ -238,9 +248,13 @@ tokens = true
238248
filename = "tokens/indent2.py"
239249
tokens = true
240250

251+
# tests/parser
252+
241253
[[test]]
242-
filename = "../integration_tests/test_max_min.py"
243-
asr = true
254+
filename = "parser/import1.py"
255+
ast_new = true
256+
257+
# tests/errors
244258

245259
[[test]]
246260
filename = "errors/test_str_indexing.py"

0 commit comments

Comments
 (0)