Skip to content

Commit

Permalink
Add tests and update references.
Browse files Browse the repository at this point in the history
  • Loading branch information
akshanshbhatt committed Jul 29, 2022
1 parent 7599fb9 commit d06e83a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
30 changes: 30 additions & 0 deletions tests/parser/function_def3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,33 @@ def test_1(x): # type: ignore[misc]

def test_2(y): # type: ignore
pass


def func(
a, # type: str
b=80, # type: int
c: str = '-', # type: str
):
pass


def abc(

a,
b, # type: int
c=['-'], # type: list[str]


): # type: (...) -> str
return


def test_01(a, # type:int
b=0
):
pass


def test_02(a, # type:int
b):
pass
4 changes: 2 additions & 2 deletions tests/reference/ast_new-function_def3-f66064a.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "2e55ea25a4cf63a6d5438ec2ccf663aedf889395148374e6b863cc4c",
"infile_hash": "92f1995802c2cf446ff865c20616ac65d9c3bd2c52357710d970db4f",
"outfile": null,
"outfile_hash": null,
"stdout": "ast_new-function_def3-f66064a.stdout",
"stdout_hash": "9e09443830a29fefc7d794c93e6192049d7ce5d10ed7ccd398e53728",
"stdout_hash": "05191d8dc81986b7c1eec58c9415d3a78e08543fc621fb873afbd6f1",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast_new-function_def3-f66064a.stdout
Original file line number Diff line number Diff line change
@@ -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)] [] () ())] [(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)] [] () ())] [(TypeIgnore 0 "[misc]") (TypeIgnore 0 "")])

0 comments on commit d06e83a

Please sign in to comment.