Skip to content

Commit

Permalink
Merge pull request lcompilers#60 from lcompilers/assert
Browse files Browse the repository at this point in the history
Test `assert` with a message
  • Loading branch information
Smit-create authored Jan 23, 2022
2 parents 0254325 + 4ebbcfe commit 0573e50
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/assert1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def test_assert():
a: i32
a = 5
assert a == 5
assert a == 5, 'a is not 5'
assert a != 10
4 changes: 2 additions & 2 deletions tests/reference/asr-assert1-1ce92ea.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"basename": "asr-assert1-1ce92ea",
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
"infile": "tests/assert1.py",
"infile_hash": "f147a7c915580ec3722bd549a70fb9deda56527fe564c5c6f7228066",
"infile_hash": "0ff84ea5ccd3d0815cbb66e1c3d3acd61dee7257c98aa1a27ceeef3b",
"outfile": null,
"outfile_hash": null,
"stdout": "asr-assert1-1ce92ea.stdout",
"stdout_hash": "ae1fa2a97a4a04a32a6b23b4ac4af4e984cbb1f283727212085e8f22",
"stdout_hash": "b38f40cf805183262fc3450e323fa2bf2d852ddf4167704cc51f2588",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-assert1-1ce92ea.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {test_assert: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.)}) test_assert [] [(= (Var 2 a) (ConstantInteger 5 (Integer 4 [])) ()) (Assert (Compare (Var 2 a) Eq (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (Var 2 a) NotEq (ConstantInteger 10 (Integer 4 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) [])
(TranslationUnit (SymbolTable 1 {test_assert: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.)}) test_assert [] [(= (Var 2 a) (ConstantInteger 5 (Integer 4 [])) ()) (Assert (Compare (Var 2 a) Eq (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) () ()) (ConstantString "a is not 5" (Character 1 10 () []))) (Assert (Compare (Var 2 a) NotEq (ConstantInteger 10 (Integer 4 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) [])
4 changes: 2 additions & 2 deletions tests/reference/ast-assert1-b0154ee.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"basename": "ast-assert1-b0154ee",
"cmd": "lpython --show-ast --no-color {infile} -o {outfile}",
"infile": "tests/assert1.py",
"infile_hash": "f147a7c915580ec3722bd549a70fb9deda56527fe564c5c6f7228066",
"infile_hash": "0ff84ea5ccd3d0815cbb66e1c3d3acd61dee7257c98aa1a27ceeef3b",
"outfile": null,
"outfile_hash": null,
"stdout": "ast-assert1-b0154ee.stdout",
"stdout_hash": "4a87bac65d736f8e6f2977af53c12b1f5584e2ad24c70ac40922d17b",
"stdout_hash": "e6f540e08fe6dc2e755b22dcd009be2c88e32d1a3775139f7493501e",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/ast-assert1-b0154ee.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(Module [(FunctionDef test_assert ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (ConstantInt 5 ()) ()) (Assert (Compare (Name a Load) Eq [(ConstantInt 5 ())]) ()) (Assert (Compare (Name a Load) NotEq [(ConstantInt 10 ())]) ())] [] () ())] [])
(Module [(FunctionDef test_assert ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (ConstantInt 5 ()) ()) (Assert (Compare (Name a Load) Eq [(ConstantInt 5 ())]) (ConstantStr "a is not 5" ())) (Assert (Compare (Name a Load) NotEq [(ConstantInt 10 ())]) ())] [] () ())] [])

0 comments on commit 0573e50

Please sign in to comment.