Skip to content

Commit

Permalink
Add tests and update refs.
Browse files Browse the repository at this point in the history
  • Loading branch information
akshanshbhatt committed Jul 30, 2022
1 parent 3d13974 commit 78946c0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions tests/parser/function_def3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
...
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": "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
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)] [] () ()) (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 "")])

0 comments on commit 78946c0

Please sign in to comment.