forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lcompilers#794 from Thirumalai-Shaktivel/tests
Split statement tests into different tests
- Loading branch information
Showing
17 changed files
with
108 additions
and
75 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
for i in range(N): # type: parallel | ||
c[i] = a[i] + scalar * b[i] | ||
|
||
i: i32 | ||
for i in range(10): | ||
if 2 > i : pass | ||
if i > 5 : break | ||
if i == 5 and i < 10 : i = 3 | ||
|
||
# Fow showing the parsing order of 'in' in for-loop and 'in' in expr is correct | ||
# and there is no conflict. Otherwise, the code below is gibberish. | ||
for i in a in list1: | ||
pass | ||
|
||
for item in list1: | ||
if item in list2: | ||
pass | ||
|
||
if a in list1 and b not in list2 or c in list3: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
if type(x) is int: | ||
pass | ||
|
||
if ((2 + 3)/2 - 1 is 5) is True: | ||
pass | ||
|
||
if x is not type(float): | ||
pass | ||
|
||
if x is \ | ||
not type(int): | ||
pass | ||
|
||
a = [1, 2, 3] | ||
|
||
if a not in [1, 2]: | ||
pass | ||
|
||
if (a not in [1, 2]) not \ | ||
in [True, False]: | ||
pass | ||
|
||
if field in ["vararg", "kwarg"]: | ||
if value is None: | ||
pass | ||
|
||
if (a in list1): | ||
pass | ||
|
||
# Ternary operator (Conditional expressions) | ||
b = 6 if a == 2 else 8 | ||
|
||
'true' if True else 'false' | ||
|
||
result = x if not (a > b) else y | ||
|
||
print(a,"is greater") if (a > b) else print(b,"is Greater") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...eference/ast_new-statements2-c4cdc5f.json → tests/reference/ast_new-boolOp1-478328f.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(Module [(Assign [(Name fruits Store)] (ListComp (Name f Load) [((Name f Store) (Name fruit_list Load) [(Call (Attribute (Name f Load) startswith Load) [(ConstantStr "a" ())] [])] 0)]) ()) (Assign [(Name fruit_list Store)] (ListComp (Name fruit Load) [((Name fruit Store) (Name fruits Load) [] 0)]) ()) (Assign [(Name sum_cord Store)] (ListComp (BinOp (Name x Load) Add (Name y Load)) [((Tuple [(Name x Store) (Name y Store)] Store) (Name points Load) [(BoolOp And [(Compare (Name x Load) Gt [(ConstantInt 0 ())]) (Compare (Name y Load) Gt [(ConstantInt 0 ())])])] 0)]) ()) (Assign [(Name transform_1 Store)] (ListComp (BinOp (BinOp (ConstantInt 2 ()) Mult (Name x Load)) Add (ConstantInt 6 ())) [((Name x Store) (Call (Name range Load) [(ConstantInt 10 ())] []) [] 0)]) ()) (Assign [(Name distance_orig Store)] (ListComp (BinOp (BinOp (BinOp (Name x Load) Pow (ConstantInt 2 ())) Add (BinOp (Name y Load) Pow (ConstantInt 2 ()))) Add (BinOp (Name z Load) Pow (ConstantInt 2 ()))) [((Tuple [(Name x Store) (Name y Store) (Name z Store)] Store) (Name points Load) [] 0)]) ()) (Assign [(Name odd_elements Store)] (ListComp (Name i Load) [((Name i Store) (Name main_list Load) [(BinOp (Name i Load) BitAnd (ConstantInt 1 ()))] 0)]) ()) (Assign [(Name first_ten_elements Store)] (ListComp (Name i Load) [((Name i Load) (Call (Name range Load) [(ConstantInt 10 ())] []) [] 0)]) ()) (Assign [(Name another_ten_elements Store)] (ListComp (Name i Load) [((Name i Load) (Call (Name range Load) [(ConstantInt 10 ())] []) [] 0)]) ())] []) | ||
(Module [(Assign [(Name fruits Store)] (ListComp (Name f Load) [((Name f Store) (Name fruit_list Load) [(Call (Attribute (Name f Load) startswith Load) [(ConstantStr "a" ())] [])] 0)]) ()) (Assign [(Name fruit_list Store)] (ListComp (Name fruit Load) [((Name fruit Store) (Name fruits Load) [] 0)]) ()) (Assign [(Name sum_cord Store)] (ListComp (BinOp (Name x Load) Add (Name y Load)) [((Tuple [(Name x Store) (Name y Store)] Store) (Name points Load) [(BoolOp And [(Compare (Name x Load) Gt [(ConstantInt 0 ())]) (Compare (Name y Load) Gt [(ConstantInt 0 ())])])] 0)]) ()) (Assign [(Name transform_1 Store)] (ListComp (BinOp (BinOp (ConstantInt 2 ()) Mult (Name x Load)) Add (ConstantInt 6 ())) [((Name x Store) (Call (Name range Load) [(ConstantInt 10 ())] []) [] 0)]) ()) (Assign [(Name distance_orig Store)] (ListComp (BinOp (BinOp (BinOp (Name x Load) Pow (ConstantInt 2 ())) Add (BinOp (Name y Load) Pow (ConstantInt 2 ()))) Add (BinOp (Name z Load) Pow (ConstantInt 2 ()))) [((Tuple [(Name x Store) (Name y Store) (Name z Store)] Store) (Name points Load) [] 0)]) ()) (Assign [(Name odd_elements Store)] (ListComp (Name i Load) [((Name i Store) (Name main_list Load) [(BinOp (Name i Load) BitAnd (ConstantInt 1 ()))] 0)]) ()) (Assign [(Name first_ten_elements Store)] (ListComp (Name i Load) [((Name i Load) (Call (Name range Load) [(ConstantInt 10 ())] []) [] 0)]) ()) (Assign [(Name another_ten_elements Store)] (ListComp (Name i Load) [((Name i Load) (Call (Name range Load) [(ConstantInt 10 ())] []) [] 0)]) ()) (Assign [(Name comp Store)] (ListComp (BinOp (Name i Load) Pow (ConstantInt 2 ())) [((Name i Store) (Call (Name range Load) [(ConstantInt 10 ())] []) [(BoolOp And [(Compare (Name i Load) NotIn [(List [(ConstantInt 3 ()) (ConstantInt 5 ()) (ConstantInt 7 ())] Load)]) (Compare (Name i Load) In [(Name list3 Load)])])] 0)]) ())] []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"basename": "ast_new-for2-af08901", | ||
"cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}", | ||
"infile": "tests/parser/for2.py", | ||
"infile_hash": "616253e2fd47c83340ea3676a4ea26dfa7c5ee87fdbb078da17e211c", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "ast_new-for2-af08901.stdout", | ||
"stdout_hash": "9fd9f42e5a4baf4fdc6eaf5d3de80b209eba47dbce388f434b24fa3f", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(Module [(For (Name i Store) (Call (Name range Load) [(Name N Load)] []) [(Assign [(Subscript (Name c Load) (Name i Load) Store)] (BinOp (Subscript (Name a Load) (Name i Load) Load) Add (BinOp (Name scalar Load) Mult (Subscript (Name b Load) (Name i Load) Load))) ())] [] "parallel") (AnnAssign (Name i Store) (Name i32 Load) () 1) (For (Name i Store) (Call (Name range Load) [(ConstantInt 10 ())] []) [(If (Compare (ConstantInt 2 ()) Gt [(Name i Load)]) [(Pass)] []) (If (Compare (Name i Load) Gt [(ConstantInt 5 ())]) [(Break)] []) (If (BoolOp And [(Compare (Name i Load) Eq [(ConstantInt 5 ())]) (Compare (Name i Load) Lt [(ConstantInt 10 ())])]) [(Assign [(Name i Store)] (ConstantInt 3 ()) ())] [])] [] ()) (For (Name i Store) (Compare (Name a Load) In [(Name list1 Load)]) [(Pass)] [] ()) (For (Name item Store) (Name list1 Load) [(If (Compare (Name item Load) In [(Name list2 Load)]) [(Pass)] [])] [] ()) (If (BoolOp Or [(BoolOp And [(Compare (Name a Load) In [(Name list1 Load)]) (Compare (Name b Load) NotIn [(Name list2 Load)])]) (Compare (Name c Load) In [(Name list3 Load)])]) [(Pass)] [])] []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"basename": "ast_new-if2-c3b6022", | ||
"cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}", | ||
"infile": "tests/parser/if2.py", | ||
"infile_hash": "9ee68bb91c6a02de890b0ec3d50f2e84fff0a2e1d464d28b01cc42c1", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "ast_new-if2-c3b6022.stdout", | ||
"stdout_hash": "7f83bcd67bc168b35686f4218e6dc8c9ac4ee8fdb1ae3c1ca6da137d", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(Module [(If (Compare (Call (Name type Load) [(Name x Load)] []) Is [(Name int Load)]) [(Pass)] []) (If (Compare (Compare (BinOp (BinOp (BinOp (ConstantInt 2 ()) Add (ConstantInt 3 ())) Div (ConstantInt 2 ())) Sub (ConstantInt 1 ())) Is [(ConstantInt 5 ())]) Is [(ConstantBool .true. ())]) [(Pass)] []) (If (Compare (Name x Load) IsNot [(Call (Name type Load) [(Name float Load)] [])]) [(Pass)] []) (If (Compare (Name x Load) IsNot [(Call (Name type Load) [(Name int Load)] [])]) [(Pass)] []) (Assign [(Name a Store)] (List [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load) ()) (If (Compare (Name a Load) NotIn [(List [(ConstantInt 1 ()) (ConstantInt 2 ())] Load)]) [(Pass)] []) (If (Compare (Compare (Name a Load) NotIn [(List [(ConstantInt 1 ()) (ConstantInt 2 ())] Load)]) NotIn [(List [(ConstantBool .true. ()) (ConstantBool .false. ())] Load)]) [(Pass)] []) (If (Compare (Name field Load) In [(List [(ConstantStr "vararg" ()) (ConstantStr "kwarg" ())] Load)]) [(If (Compare (Name value Load) Is [(ConstantNone ())]) [(Pass)] [])] []) (If (Compare (Name a Load) In [(Name list1 Load)]) [(Pass)] []) (Assign [(Name b Store)] (IfExp (Compare (Name a Load) Eq [(ConstantInt 2 ())]) (ConstantInt 6 ()) (ConstantInt 8 ())) ()) (Expr (IfExp (ConstantBool .true. ()) (ConstantStr "true" ()) (ConstantStr "false" ()))) (Assign [(Name result Store)] (IfExp (UnaryOp Not (Compare (Name a Load) Gt [(Name b Load)])) (Name x Load) (Name y Load)) ()) (Expr (IfExp (Compare (Name a Load) Gt [(Name b Load)]) (Call (Name print Load) [(Name a Load) (ConstantStr "is greater" ())] []) (Call (Name print Load) [(Name b Load) (ConstantStr "is Greater" ())] [])))] []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.