From e0d0a86d981950f2c669c955db10e4c02a5ee616 Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Fri, 15 Apr 2022 13:37:02 +0530 Subject: [PATCH] Add and update tests --- run_tests.py | 5 +++++ tests/parser/import1.py | 21 +++++++++++++++++++ tests/reference/ast_new-import1-f643fd3.json | 13 ++++++++++++ .../reference/ast_new-import1-f643fd3.stdout | 1 + tests/tests.toml | 18 ++++++++++++++-- 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/parser/import1.py create mode 100644 tests/reference/ast_new-import1-f643fd3.json create mode 100644 tests/reference/ast_new-import1-f643fd3.stdout diff --git a/run_tests.py b/run_tests.py index 55569eff10..53d4a5ea38 100755 --- a/run_tests.py +++ b/run_tests.py @@ -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) @@ -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) diff --git a/tests/parser/import1.py b/tests/parser/import1.py new file mode 100644 index 0000000000..5febd4313a --- /dev/null +++ b/tests/parser/import1.py @@ -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) diff --git a/tests/reference/ast_new-import1-f643fd3.json b/tests/reference/ast_new-import1-f643fd3.json new file mode 100644 index 0000000000..e6505f024e --- /dev/null +++ b/tests/reference/ast_new-import1-f643fd3.json @@ -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 +} \ No newline at end of file diff --git a/tests/reference/ast_new-import1-f643fd3.stdout b/tests/reference/ast_new-import1-f643fd3.stdout new file mode 100644 index 0000000000..210366cdb0 --- /dev/null +++ b/tests/reference/ast_new-import1-f643fd3.stdout @@ -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)] []) diff --git a/tests/tests.toml b/tests/tests.toml index 732bebf0e8..7172815e64 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -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 @@ -166,6 +168,8 @@ filename = "global_scope1.py" ast = true asr = true +# integration_tests + [[test]] filename = "../integration_tests/test_builtin.py" asr = true @@ -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 @@ -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"