From 78946c0672172e3c359b860d53f75f30191ada79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aksh=C4=81nsh?= <53227127+akshanshbhatt@users.noreply.github.com> Date: Sat, 30 Jul 2022 13:09:20 +0530 Subject: [PATCH] Add tests and update refs. --- tests/parser/function_def3.py | 25 +++++++++++++++++++ .../ast_new-function_def3-f66064a.json | 4 +-- .../ast_new-function_def3-f66064a.stdout | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tests/parser/function_def3.py b/tests/parser/function_def3.py index d7c1de9746..4eca08a908 100644 --- a/tests/parser/function_def3.py +++ b/tests/parser/function_def3.py @@ -47,3 +47,28 @@ def test_01(a, # type:int def test_02(a, # type:int b): pass + + +# TODO: Make the commented out example work. + +def quantiles(dist, /, *, n): + ... + +# def quantiles(dist, /, *, n=4, method='exclusive'): +# ... + +def func(self, param1, param2, /, param3, *, param4, param5): + ... + +# def func(self, param1, param2, /, param3=7, *, param4, param5): +# ... + +# def func(self, param1, param2, /, param3, param3_1=2, *, param4, param5): +# ... + + +def add(a, b, *, c, d): + ... + +def func(*, param4, param5): + ... diff --git a/tests/reference/ast_new-function_def3-f66064a.json b/tests/reference/ast_new-function_def3-f66064a.json index 45b3780547..c18b15d11e 100644 --- a/tests/reference/ast_new-function_def3-f66064a.json +++ b/tests/reference/ast_new-function_def3-f66064a.json @@ -2,11 +2,11 @@ "basename": "ast_new-function_def3-f66064a", "cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}", "infile": "tests/parser/function_def3.py", - "infile_hash": "92f1995802c2cf446ff865c20616ac65d9c3bd2c52357710d970db4f", + "infile_hash": "79fb58198269d957ba2c41c73e063be2ea15ec7aacc1e71c01a52bc9", "outfile": null, "outfile_hash": null, "stdout": "ast_new-function_def3-f66064a.stdout", - "stdout_hash": "05191d8dc81986b7c1eec58c9415d3a78e08543fc621fb873afbd6f1", + "stdout_hash": "cf8836b917795c14543a318aeb2a1d7546d9d0807efd50ca80c4d9ab", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast_new-function_def3-f66064a.stdout b/tests/reference/ast_new-function_def3-f66064a.stdout index 61d85ac014..69851c906d 100644 --- a/tests/reference/ast_new-function_def3-f66064a.stdout +++ b/tests/reference/ast_new-function_def3-f66064a.stdout @@ -1 +1 @@ -(Module [(FunctionDef main0 ([] [(i () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef example ([] [(text () ()) (width () ()) (fill_char () ())] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Return ())] [] () "(...) -> str") (Expr (Call (Name example Load) [(Name text Load)] [(width (ConstantInt 80 ())) (fill_char (ConstantStr "-" ()))])) (FunctionDef test_1 ([] [(x () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_2 ([] [(y () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef func ([] [(a () "str") (b () "int") (c (Name str Load) "str")] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Pass)] [] () ()) (FunctionDef abc ([] [(a () ()) (b () "int") (c () "list[str]")] [] [] [] [] [(List [(ConstantStr "-" ())] Load)]) [(Return ())] [] () "(...) -> str") (FunctionDef test_01 ([] [(a () "int") (b () ())] [] [] [] [] [(ConstantInt 0 ())]) [(Pass)] [] () ()) (FunctionDef test_02 ([] [(a () "int") (b () ())] [] [] [] [] []) [(Pass)] [] () ())] [(TypeIgnore 0 "[misc]") (TypeIgnore 0 "")]) +(Module [(FunctionDef main0 ([] [(i () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef example ([] [(text () ()) (width () ()) (fill_char () ())] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Return ())] [] () "(...) -> str") (Expr (Call (Name example Load) [(Name text Load)] [(width (ConstantInt 80 ())) (fill_char (ConstantStr "-" ()))])) (FunctionDef test_1 ([] [(x () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef test_2 ([] [(y () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef func ([] [(a () "str") (b () "int") (c (Name str Load) "str")] [] [] [] [] [(ConstantInt 80 ()) (ConstantStr "-" ())]) [(Pass)] [] () ()) (FunctionDef abc ([] [(a () ()) (b () "int") (c () "list[str]")] [] [] [] [] [(List [(ConstantStr "-" ())] Load)]) [(Return ())] [] () "(...) -> str") (FunctionDef test_01 ([] [(a () "int") (b () ())] [] [] [] [] [(ConstantInt 0 ())]) [(Pass)] [] () ()) (FunctionDef test_02 ([] [(a () "int") (b () ())] [] [] [] [] []) [(Pass)] [] () ()) (FunctionDef quantiles ([(dist () ())] [] [] [(n () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([(self () ()) (param1 () ()) (param2 () ())] [(param3 () ())] [] [(param4 () ()) (param5 () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef add ([] [(a () ()) (b () ())] [] [(c () ()) (d () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ()) (FunctionDef func ([] [] [] [(param4 () ()) (param5 () ())] [] [] []) [(Expr (ConstantEllipsis ()))] [] () ())] [(TypeIgnore 0 "[misc]") (TypeIgnore 0 "")])