Skip to content

Commit

Permalink
Add and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thirumalai-Shaktivel committed Apr 15, 2022
1 parent 5954122 commit e0d0a86
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
5 changes: 5 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def main():
ast_cpp = test.get("ast_cpp", False)
ast_cpp_hip = test.get("ast_cpp_hip", False)
ast_openmp = test.get("ast_openmp", False)
ast_new = test.get("ast_new", False)
asr = test.get("asr", False)
asr_preprocess = test.get("asr_preprocess", False)
asr_indent = test.get("asr_indent", False)
Expand All @@ -63,6 +64,10 @@ def main():
run_test("ast", "lpython --show-ast --no-color {infile} -o {outfile}",
filename, update_reference, extra_args)

if ast_new:
run_test("ast_new", "lpython --show-ast --new-parser --no-color {infile} -o {outfile}",
filename, update_reference, extra_args)

if asr:
run_test("asr", "lpython --show-asr --no-color {infile} -o {outfile}",
filename, update_reference, extra_args)
Expand Down
21 changes: 21 additions & 0 deletions tests/parser/import1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# AST tests only

import os
import random as r
import random as r, abc as a
import x.y.z
import x.y.z as xyz

from ltypes import i8, i16, i32, i64, f32, f64, \
c32, c64, overload, ccall, TypeVar
from __future__ import division
from math import *
from math import (sin, cos, tan)
from math import sin, cos
from math import factorial as fact
from x.y import z
from . import a
from .a.b import a
from .a.b import *
from .abc import a
from .abc import (a, b, c)
13 changes: 13 additions & 0 deletions tests/reference/ast_new-import1-f643fd3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"basename": "ast_new-import1-f643fd3",
"cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}",
"infile": "tests/parser/import1.py",
"infile_hash": "87d09a5deba632cbd38045f935398a8a882e0958f810aada84883f86",
"outfile": null,
"outfile_hash": null,
"stdout": "ast_new-import1-f643fd3.stdout",
"stdout_hash": "912bb6761751cb6b99aaf7b80ccd4eae03cfa13ae0879c88b7e5ddd3",
"stderr": null,
"stderr_hash": null,
"returncode": 0
}
1 change: 1 addition & 0 deletions tests/reference/ast_new-import1-f643fd3.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +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)] [])
18 changes: 16 additions & 2 deletions tests/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# llvm ... run the Semantics and output LLVM, compare against reference version
# tokens ... output Tokens, compare against reference version

# tests

[[test]]
filename = "doconcurrentloop_01.py"
ast = true
Expand Down Expand Up @@ -166,6 +168,8 @@ filename = "global_scope1.py"
ast = true
asr = true

# integration_tests

[[test]]
filename = "../integration_tests/test_builtin.py"
asr = true
Expand Down Expand Up @@ -214,6 +218,12 @@ asr = true
filename = "../integration_tests/test_builtin_oct.py"
asr = true

[[test]]
filename = "../integration_tests/test_max_min.py"
asr = true

# tests/tokens

[[test]]
filename = "tokens/docstring1.py"
tokens = true
Expand All @@ -238,9 +248,13 @@ tokens = true
filename = "tokens/indent2.py"
tokens = true

# tests/parser

[[test]]
filename = "../integration_tests/test_max_min.py"
asr = true
filename = "parser/import1.py"
ast_new = true

# tests/errors

[[test]]
filename = "errors/test_str_indexing.py"
Expand Down

0 comments on commit e0d0a86

Please sign in to comment.