Skip to content

Commit

Permalink
Add and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit-create committed Apr 12, 2022
1 parent fbaf77d commit ee8a94e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tests/list1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ def test_List():
# ragged list
e: list[list[str]]
e = [['a', 'b', 'c'], ['d', 'e']]

a.append(10)
4 changes: 2 additions & 2 deletions tests/reference/asr-list1-770ba33.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"basename": "asr-list1-770ba33",
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
"infile": "tests/list1.py",
"infile_hash": "0b28eb905e0a7b2b4656d1aa6a43a844be4a8f4764712a5fea66c32d",
"infile_hash": "df91bd49dc08b10d57b426299d48a1975ba1834f49373f63898dced6",
"outfile": null,
"outfile_hash": null,
"stdout": "asr-list1-770ba33.stdout",
"stdout_hash": "2e94ad9aa2d6c65274c7b74296efe4380c9516b2e02657ae92108631",
"stdout_hash": "be455489b0dcdaa25cc0286c238a8d54daddbf2797ec0d4c7395a1cb",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-list1-770ba33.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {main_program: (Program (SymbolTable 3 {}) main_program [] []), test_List: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (List (Integer 4 [])) Source Public Required .false.), b: (Variable 2 b Local () () Default (List (Character 1 -2 () [])) Source Public Required .false.), c: (Variable 2 c Local () () Default (List (List (Integer 4 []))) Source Public Required .false.), d: (Variable 2 d Local () () Default (Integer 4 []) Source Public Required .false.), e: (Variable 2 e Local () () Default (List (List (Character 1 -2 () []))) Source Public Required .false.)}) test_List [] [(= (Var 2 a) (ConstantList [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (List (Integer 4 []))) ()) (= (Var 2 a) (ConstantList [(UnaryOp USub (ConstantInteger 3 (Integer 4 [])) (Integer 4 []) (ConstantInteger -3 (Integer 4 []))) (UnaryOp USub (ConstantInteger 2 (Integer 4 [])) (Integer 4 []) (ConstantInteger -2 (Integer 4 []))) (UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] (List (Integer 4 []))) ()) (= (Var 2 b) (ConstantList [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantString "c" (Character 1 1 () []))] (List (Character 1 1 () []))) ()) (= (Var 2 c) (ConstantList [(ConstantList [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (List (Integer 4 []))) (ConstantList [(ConstantInteger 4 (Integer 4 [])) (ConstantInteger 5 (Integer 4 [])) (ConstantInteger 6 (Integer 4 []))] (List (Integer 4 [])))] (List (List (Integer 4 [])))) ()) (= (Var 2 d) (ArrayRef 2 a [(() (BinOp (ConstantInteger 2 (Integer 4 [])) Add (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) () ()) ())] (Integer 4 []) ()) ()) (= (Var 2 e) (ConstantList [(ConstantList [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantString "c" (Character 1 1 () []))] (List (Character 1 1 () []))) (ConstantList [(ConstantString "d" (Character 1 1 () [])) (ConstantString "e" (Character 1 1 () []))] (List (Character 1 1 () [])))] (List (List (Character 1 1 () [])))) ())] Source Public Implementation () .false. .false.)}) [])
(TranslationUnit (SymbolTable 1 {main_program: (Program (SymbolTable 3 {}) main_program [] []), test_List: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (List (Integer 4 [])) Source Public Required .false.), b: (Variable 2 b Local () () Default (List (Character 1 -2 () [])) Source Public Required .false.), c: (Variable 2 c Local () () Default (List (List (Integer 4 []))) Source Public Required .false.), d: (Variable 2 d Local () () Default (Integer 4 []) Source Public Required .false.), e: (Variable 2 e Local () () Default (List (List (Character 1 -2 () []))) Source Public Required .false.)}) test_List [] [(= (Var 2 a) (ConstantList [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (List (Integer 4 []))) ()) (= (Var 2 a) (ConstantList [(UnaryOp USub (ConstantInteger 3 (Integer 4 [])) (Integer 4 []) (ConstantInteger -3 (Integer 4 []))) (UnaryOp USub (ConstantInteger 2 (Integer 4 [])) (Integer 4 []) (ConstantInteger -2 (Integer 4 []))) (UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] (List (Integer 4 []))) ()) (= (Var 2 b) (ConstantList [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantString "c" (Character 1 1 () []))] (List (Character 1 1 () []))) ()) (= (Var 2 c) (ConstantList [(ConstantList [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (List (Integer 4 []))) (ConstantList [(ConstantInteger 4 (Integer 4 [])) (ConstantInteger 5 (Integer 4 [])) (ConstantInteger 6 (Integer 4 []))] (List (Integer 4 [])))] (List (List (Integer 4 [])))) ()) (= (Var 2 d) (ArrayRef 2 a [(() (BinOp (ConstantInteger 2 (Integer 4 [])) Add (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) () ()) ())] (Integer 4 []) ()) ()) (= (Var 2 e) (ConstantList [(ConstantList [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantString "c" (Character 1 1 () []))] (List (Character 1 1 () []))) (ConstantList [(ConstantString "d" (Character 1 1 () [])) (ConstantString "e" (Character 1 1 () []))] (List (Character 1 1 () [])))] (List (List (Character 1 1 () [])))) ()) (ListAppend 2 a (ConstantInteger 10 (Integer 4 [])))] Source Public Implementation () .false. .false.)}) [])
4 changes: 2 additions & 2 deletions tests/reference/ast-list1-9ce2da0.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"basename": "ast-list1-9ce2da0",
"cmd": "lpython --show-ast --no-color {infile} -o {outfile}",
"infile": "tests/list1.py",
"infile_hash": "0b28eb905e0a7b2b4656d1aa6a43a844be4a8f4764712a5fea66c32d",
"infile_hash": "df91bd49dc08b10d57b426299d48a1975ba1834f49373f63898dced6",
"outfile": null,
"outfile_hash": null,
"stdout": "ast-list1-9ce2da0.stdout",
"stdout_hash": "8774570ba739706780cffe8376e5d92eeea86a685ccd2202b8823365",
"stdout_hash": "3beda3d02d306557a577db995370defdad5dd26b8da03b4aaeedbf37",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast-list1-9ce2da0.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(Module [(FunctionDef test_List ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Subscript (Name list Load) (Name i32 Load) Load) () 1) (Assign [(Name a Store)] (List [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load) ()) (Assign [(Name a Store)] (List [(UnaryOp USub (ConstantInt 3 ())) (UnaryOp USub (ConstantInt 2 ())) (UnaryOp USub (ConstantInt 1 ()))] Load) ()) (AnnAssign (Name b Store) (Subscript (Name list Load) (Name str Load) Load) () 1) (Assign [(Name b Store)] (List [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantStr "c" ())] Load) ()) (AnnAssign (Name c Store) (Subscript (Name list Load) (Subscript (Name list Load) (Name i32 Load) Load) Load) () 1) (Assign [(Name c Store)] (List [(List [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load) (List [(ConstantInt 4 ()) (ConstantInt 5 ()) (ConstantInt 6 ())] Load)] Load) ()) (AnnAssign (Name d Store) (Name i32 Load) () 1) (Assign [(Name d Store)] (Subscript (Name a Load) (ConstantInt 2 ()) Load) ()) (AnnAssign (Name e Store) (Subscript (Name list Load) (Subscript (Name list Load) (Name str Load) Load) Load) () 1) (Assign [(Name e Store)] (List [(List [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantStr "c" ())] Load) (List [(ConstantStr "d" ()) (ConstantStr "e" ())] Load)] Load) ())] [] () ())] [])
(Module [(FunctionDef test_List ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Subscript (Name list Load) (Name i32 Load) Load) () 1) (Assign [(Name a Store)] (List [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load) ()) (Assign [(Name a Store)] (List [(UnaryOp USub (ConstantInt 3 ())) (UnaryOp USub (ConstantInt 2 ())) (UnaryOp USub (ConstantInt 1 ()))] Load) ()) (AnnAssign (Name b Store) (Subscript (Name list Load) (Name str Load) Load) () 1) (Assign [(Name b Store)] (List [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantStr "c" ())] Load) ()) (AnnAssign (Name c Store) (Subscript (Name list Load) (Subscript (Name list Load) (Name i32 Load) Load) Load) () 1) (Assign [(Name c Store)] (List [(List [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load) (List [(ConstantInt 4 ()) (ConstantInt 5 ()) (ConstantInt 6 ())] Load)] Load) ()) (AnnAssign (Name d Store) (Name i32 Load) () 1) (Assign [(Name d Store)] (Subscript (Name a Load) (ConstantInt 2 ()) Load) ()) (AnnAssign (Name e Store) (Subscript (Name list Load) (Subscript (Name list Load) (Name str Load) Load) Load) () 1) (Assign [(Name e Store)] (List [(List [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantStr "c" ())] Load) (List [(ConstantStr "d" ()) (ConstantStr "e" ())] Load)] Load) ()) (Expr (Call (Attribute (Name a Load) append Load) [(ConstantInt 10 ())] []))] [] () ())] [])

0 comments on commit ee8a94e

Please sign in to comment.