From a035963459b5b5b7f546324505c7ae51237b1a5e Mon Sep 17 00:00:00 2001 From: Smit-create Date: Wed, 19 Jan 2022 09:50:46 +0530 Subject: [PATCH] Add tests --- tests/assert1.py | 5 ++ tests/assign1.py | 13 +++++ tests/constants1.py | 7 +++ tests/expr2.py | 8 +++ tests/expr3.py | 11 ++++ tests/expr4.py | 6 ++ tests/expr5.py | 7 +++ tests/expr6.py | 5 ++ tests/expr7.py | 9 +++ tests/loop1.py | 18 ++++++ tests/loop2.py | 7 +++ tests/loop3.py | 5 ++ tests/reference/asr-assert1-1ce92ea.json | 13 +++++ tests/reference/asr-assert1-1ce92ea.stdout | 1 + tests/reference/asr-assign1-886f049.json | 13 +++++ tests/reference/asr-assign1-886f049.stdout | 1 + tests/reference/asr-constants1-5828e8a.json | 4 +- tests/reference/asr-constants1-5828e8a.stdout | 2 +- tests/reference/asr-expr2-2e78a12.json | 13 +++++ tests/reference/asr-expr2-2e78a12.stdout | 1 + tests/reference/asr-expr3-10eb0a4.json | 13 +++++ tests/reference/asr-expr3-10eb0a4.stdout | 1 + tests/reference/asr-expr4-cef6743.json | 13 +++++ tests/reference/asr-expr4-cef6743.stdout | 1 + tests/reference/asr-expr5-645ffcc.json | 13 +++++ tests/reference/asr-expr5-645ffcc.stdout | 1 + tests/reference/asr-expr6-368e5ed.json | 13 +++++ tests/reference/asr-expr6-368e5ed.stdout | 1 + tests/reference/asr-expr7-480ba2f.json | 13 +++++ tests/reference/asr-expr7-480ba2f.stdout | 1 + tests/reference/asr-loop1-10d3109.json | 13 +++++ tests/reference/asr-loop1-10d3109.stdout | 1 + tests/reference/asr-loop2-e874469.json | 13 +++++ tests/reference/asr-loop2-e874469.stdout | 1 + tests/reference/asr-loop3-a579196.json | 13 +++++ tests/reference/asr-loop3-a579196.stdout | 1 + tests/reference/ast-assert1-b0154ee.json | 13 +++++ tests/reference/ast-assert1-b0154ee.stdout | 1 + tests/reference/ast-assign1-2a4c9ed.json | 13 +++++ tests/reference/ast-assign1-2a4c9ed.stdout | 1 + tests/reference/ast-constants1-91cb6ff.json | 4 +- tests/reference/ast-constants1-91cb6ff.stdout | 2 +- tests/reference/ast-expr2-6642d4a.json | 13 +++++ tests/reference/ast-expr2-6642d4a.stdout | 1 + tests/reference/ast-expr3-c3dcaab.json | 13 +++++ tests/reference/ast-expr3-c3dcaab.stdout | 1 + tests/reference/ast-expr4-49316cb.json | 13 +++++ tests/reference/ast-expr4-49316cb.stdout | 1 + tests/reference/ast-expr5-bbc6e71.json | 13 +++++ tests/reference/ast-expr5-bbc6e71.stdout | 1 + tests/reference/ast-expr6-0b12a67.json | 13 +++++ tests/reference/ast-expr6-0b12a67.stdout | 1 + tests/reference/ast-expr7-fe52776.json | 13 +++++ tests/reference/ast-expr7-fe52776.stdout | 1 + tests/reference/ast-loop1-194a137.json | 13 +++++ tests/reference/ast-loop1-194a137.stdout | 1 + tests/reference/ast-loop2-63bf329.json | 13 +++++ tests/reference/ast-loop2-63bf329.stdout | 1 + tests/reference/ast-loop3-f7e0393.json | 13 +++++ tests/reference/ast-loop3-f7e0393.stdout | 1 + tests/reference/cpp-expr2-09c05ad.json | 13 +++++ tests/reference/cpp-expr2-09c05ad.stdout | 27 +++++++++ tests/reference/cpp-expr7-529bd53.json | 13 +++++ tests/reference/cpp-expr7-529bd53.stdout | 29 ++++++++++ tests/reference/cpp-loop1-0a8cf3b.json | 13 +++++ tests/reference/cpp-loop1-0a8cf3b.stdout | 41 +++++++++++++ tests/tests.toml | 57 +++++++++++++++++++ 67 files changed, 608 insertions(+), 6 deletions(-) create mode 100644 tests/assert1.py create mode 100644 tests/assign1.py create mode 100644 tests/expr2.py create mode 100644 tests/expr3.py create mode 100644 tests/expr4.py create mode 100644 tests/expr5.py create mode 100644 tests/expr6.py create mode 100644 tests/expr7.py create mode 100644 tests/loop1.py create mode 100644 tests/loop2.py create mode 100644 tests/loop3.py create mode 100644 tests/reference/asr-assert1-1ce92ea.json create mode 100644 tests/reference/asr-assert1-1ce92ea.stdout create mode 100644 tests/reference/asr-assign1-886f049.json create mode 100644 tests/reference/asr-assign1-886f049.stdout create mode 100644 tests/reference/asr-expr2-2e78a12.json create mode 100644 tests/reference/asr-expr2-2e78a12.stdout create mode 100644 tests/reference/asr-expr3-10eb0a4.json create mode 100644 tests/reference/asr-expr3-10eb0a4.stdout create mode 100644 tests/reference/asr-expr4-cef6743.json create mode 100644 tests/reference/asr-expr4-cef6743.stdout create mode 100644 tests/reference/asr-expr5-645ffcc.json create mode 100644 tests/reference/asr-expr5-645ffcc.stdout create mode 100644 tests/reference/asr-expr6-368e5ed.json create mode 100644 tests/reference/asr-expr6-368e5ed.stdout create mode 100644 tests/reference/asr-expr7-480ba2f.json create mode 100644 tests/reference/asr-expr7-480ba2f.stdout create mode 100644 tests/reference/asr-loop1-10d3109.json create mode 100644 tests/reference/asr-loop1-10d3109.stdout create mode 100644 tests/reference/asr-loop2-e874469.json create mode 100644 tests/reference/asr-loop2-e874469.stdout create mode 100644 tests/reference/asr-loop3-a579196.json create mode 100644 tests/reference/asr-loop3-a579196.stdout create mode 100644 tests/reference/ast-assert1-b0154ee.json create mode 100644 tests/reference/ast-assert1-b0154ee.stdout create mode 100644 tests/reference/ast-assign1-2a4c9ed.json create mode 100644 tests/reference/ast-assign1-2a4c9ed.stdout create mode 100644 tests/reference/ast-expr2-6642d4a.json create mode 100644 tests/reference/ast-expr2-6642d4a.stdout create mode 100644 tests/reference/ast-expr3-c3dcaab.json create mode 100644 tests/reference/ast-expr3-c3dcaab.stdout create mode 100644 tests/reference/ast-expr4-49316cb.json create mode 100644 tests/reference/ast-expr4-49316cb.stdout create mode 100644 tests/reference/ast-expr5-bbc6e71.json create mode 100644 tests/reference/ast-expr5-bbc6e71.stdout create mode 100644 tests/reference/ast-expr6-0b12a67.json create mode 100644 tests/reference/ast-expr6-0b12a67.stdout create mode 100644 tests/reference/ast-expr7-fe52776.json create mode 100644 tests/reference/ast-expr7-fe52776.stdout create mode 100644 tests/reference/ast-loop1-194a137.json create mode 100644 tests/reference/ast-loop1-194a137.stdout create mode 100644 tests/reference/ast-loop2-63bf329.json create mode 100644 tests/reference/ast-loop2-63bf329.stdout create mode 100644 tests/reference/ast-loop3-f7e0393.json create mode 100644 tests/reference/ast-loop3-f7e0393.stdout create mode 100644 tests/reference/cpp-expr2-09c05ad.json create mode 100644 tests/reference/cpp-expr2-09c05ad.stdout create mode 100644 tests/reference/cpp-expr7-529bd53.json create mode 100644 tests/reference/cpp-expr7-529bd53.stdout create mode 100644 tests/reference/cpp-loop1-0a8cf3b.json create mode 100644 tests/reference/cpp-loop1-0a8cf3b.stdout diff --git a/tests/assert1.py b/tests/assert1.py new file mode 100644 index 0000000000..f6bd9b1de7 --- /dev/null +++ b/tests/assert1.py @@ -0,0 +1,5 @@ +def test_assert(): + a: i32 + a = 5 + assert a == 5 + assert a != 10 diff --git a/tests/assign1.py b/tests/assign1.py new file mode 100644 index 0000000000..eb98283cc3 --- /dev/null +++ b/tests/assign1.py @@ -0,0 +1,13 @@ +def test_augassign(): + r: i32 + s: i32 + r = 0 + r += 4 + s = 5 + r *= s + r -= 2 + s = 10 + r /= s + a: str + a = "" + a += "test" diff --git a/tests/constants1.py b/tests/constants1.py index 366b270856..bba187adf1 100644 --- a/tests/constants1.py +++ b/tests/constants1.py @@ -6,3 +6,10 @@ def test_boz(): b = oct(56) b = hex(42) b = hex(12648430) + + +def test_ord_chr(): + s: str + a: i32 + a = ord('5') + s = chr(43) diff --git a/tests/expr2.py b/tests/expr2.py new file mode 100644 index 0000000000..5fd66ba605 --- /dev/null +++ b/tests/expr2.py @@ -0,0 +1,8 @@ +def test_boolOp(): + a: bool + b: bool + a = False + b = True + a = a and b + b = a or True + a = a or b diff --git a/tests/expr3.py b/tests/expr3.py new file mode 100644 index 0000000000..cd52d3b903 --- /dev/null +++ b/tests/expr3.py @@ -0,0 +1,11 @@ +def test_cast(): + a: i32 + b: f32 + a = 2 + b = 4.2 + a *= b + b += 1 + a = 5 + a -= 3.9 + a /= b + b = 3/4 diff --git a/tests/expr4.py b/tests/expr4.py new file mode 100644 index 0000000000..030b93569e --- /dev/null +++ b/tests/expr4.py @@ -0,0 +1,6 @@ +def test_del(): + a: i32 + b: i32 + a = 4 + b = 20 + del a, b diff --git a/tests/expr5.py b/tests/expr5.py new file mode 100644 index 0000000000..ce9fe91e09 --- /dev/null +++ b/tests/expr5.py @@ -0,0 +1,7 @@ +def test_strOP(): + s: str + s = 'a' * 2 + s = 4 * 'bb' + s = 3 * 'a' * 3 + s = '3' + '4' + s += 'test' diff --git a/tests/expr6.py b/tests/expr6.py new file mode 100644 index 0000000000..289c2578eb --- /dev/null +++ b/tests/expr6.py @@ -0,0 +1,5 @@ +def test_ifexp(): + a: i32 + a = 2 + b: i32 + b = 6 if a == 2 else 8 diff --git a/tests/expr7.py b/tests/expr7.py new file mode 100644 index 0000000000..d008ebc32c --- /dev/null +++ b/tests/expr7.py @@ -0,0 +1,9 @@ +def test_pow(): + a: i32 + a = pow(2, 2) + + +def test_pow_1(a: i32, b: i32) -> i32: + res: i32 + res = pow(a, b) + return res diff --git a/tests/loop1.py b/tests/loop1.py new file mode 100644 index 0000000000..aaae9d2d6b --- /dev/null +++ b/tests/loop1.py @@ -0,0 +1,18 @@ +def test_factorial_1(x: i32) -> i32: + if x < 0: + return 0 + result: i32 + result = 1 + while x > 0: + result = result * x + x -= 1 + return result + + +def test_factorial_2(x: i32) -> i32: + result: i32 + result = 1 + i: i32 + for i in range(1, x + 1): + result = result * i + return result diff --git a/tests/loop2.py b/tests/loop2.py new file mode 100644 index 0000000000..bf2a7b1bd7 --- /dev/null +++ b/tests/loop2.py @@ -0,0 +1,7 @@ +def test_for(): + i: i32 + for i in range(0, 10): + if i == 0: + continue + if i > 5: + break diff --git a/tests/loop3.py b/tests/loop3.py new file mode 100644 index 0000000000..fd73a974f1 --- /dev/null +++ b/tests/loop3.py @@ -0,0 +1,5 @@ +def test_pass(): + a: i32 + a = 1 + while a > 0: + pass diff --git a/tests/reference/asr-assert1-1ce92ea.json b/tests/reference/asr-assert1-1ce92ea.json new file mode 100644 index 0000000000..5957626d9b --- /dev/null +++ b/tests/reference/asr-assert1-1ce92ea.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-assert1-1ce92ea", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/assert1.py", + "infile_hash": "f147a7c915580ec3722bd549a70fb9deda56527fe564c5c6f7228066", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-assert1-1ce92ea.stdout", + "stdout_hash": "ae1fa2a97a4a04a32a6b23b4ac4af4e984cbb1f283727212085e8f22", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-assert1-1ce92ea.stdout b/tests/reference/asr-assert1-1ce92ea.stdout new file mode 100644 index 0000000000..e505e65b8c --- /dev/null +++ b/tests/reference/asr-assert1-1ce92ea.stdout @@ -0,0 +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.)}) []) diff --git a/tests/reference/asr-assign1-886f049.json b/tests/reference/asr-assign1-886f049.json new file mode 100644 index 0000000000..ca886ec494 --- /dev/null +++ b/tests/reference/asr-assign1-886f049.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-assign1-886f049", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/assign1.py", + "infile_hash": "3b82a73e457bd65e85828b72d56596ca927e7c661e333691f154912b", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-assign1-886f049.stdout", + "stdout_hash": "2093d0bf986c2069ffb0b0785cd198349c92cc5fc4c96241c0641483", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-assign1-886f049.stdout b/tests/reference/asr-assign1-886f049.stdout new file mode 100644 index 0000000000..d3d38e7bb7 --- /dev/null +++ b/tests/reference/asr-assign1-886f049.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_augassign: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Character 1 -2 () []) Source Public Required .false.), r: (Variable 2 r Local () () Default (Integer 4 []) Source Public Required .false.), s: (Variable 2 s Local () () Default (Integer 4 []) Source Public Required .false.)}) test_augassign [] [(= (Var 2 r) (ConstantInteger 0 (Integer 4 [])) ()) (= (Var 2 r) (BinOp (Var 2 r) Add (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) () ()) ()) (= (Var 2 s) (ConstantInteger 5 (Integer 4 [])) ()) (= (Var 2 r) (BinOp (Var 2 r) Mul (Var 2 s) (Integer 4 []) () ()) ()) (= (Var 2 r) (BinOp (Var 2 r) Sub (ConstantInteger 2 (Integer 4 [])) (Integer 4 []) () ()) ()) (= (Var 2 s) (ConstantInteger 10 (Integer 4 [])) ()) (= (Var 2 r) (BinOp (ImplicitCast (Var 2 r) IntegerToReal (Real 8 []) ()) Div (ImplicitCast (Var 2 s) IntegerToReal (Real 8 []) ()) (Real 8 []) () ()) ()) (= (Var 2 a) (ConstantString "" (Character 1 0 () [])) ()) (= (Var 2 a) (StrOp (Var 2 a) Concat (ConstantString "test" (Character 1 4 () [])) (Character 1 -2 () []) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-constants1-5828e8a.json b/tests/reference/asr-constants1-5828e8a.json index f0f41837f6..dddb9a868f 100644 --- a/tests/reference/asr-constants1-5828e8a.json +++ b/tests/reference/asr-constants1-5828e8a.json @@ -2,11 +2,11 @@ "basename": "asr-constants1-5828e8a", "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", "infile": "tests/constants1.py", - "infile_hash": "673145c1bcbf90af453feda6f0abfeaaae3c2f04a191b32500fa0217", + "infile_hash": "c5648d1d7f443b239f85aff60c596e54e57a93f7fe6db70bee361ebc", "outfile": null, "outfile_hash": null, "stdout": "asr-constants1-5828e8a.stdout", - "stdout_hash": "f4c61aa7b0774713ef08431e7e89d0f6fa451e95fb3774aaa242abf8", + "stdout_hash": "bfc4ff0ae50d14d5062d0cd3a899614f7a74da4c7caa355ee39062d7", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-constants1-5828e8a.stdout b/tests/reference/asr-constants1-5828e8a.stdout index 6f94d66750..6b128ec91a 100644 --- a/tests/reference/asr-constants1-5828e8a.stdout +++ b/tests/reference/asr-constants1-5828e8a.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {test_boz: (Subroutine (SymbolTable 2 {b: (Variable 2 b Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_boz [] [(= (Var 2 b) (ConstantString "0b101" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0b1000000" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0o10" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0o70" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0x2a" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0xc0ffee" (Character 1 1 () [])) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {test_boz: (Subroutine (SymbolTable 2 {b: (Variable 2 b Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_boz [] [(= (Var 2 b) (ConstantString "0b101" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0b1000000" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0o10" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0o70" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0x2a" (Character 1 1 () [])) ()) (= (Var 2 b) (ConstantString "0xc0ffee" (Character 1 1 () [])) ())] Source Public Implementation () .false. .false.), test_ord_chr: (Subroutine (SymbolTable 3 {a: (Variable 3 a Local () () Default (Integer 4 []) Source Public Required .false.), s: (Variable 3 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_ord_chr [] [(= (Var 3 a) (ConstantInteger 53 (Integer 4 [])) ()) (= (Var 3 s) (ConstantString "+" (Character 1 1 () [])) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr2-2e78a12.json b/tests/reference/asr-expr2-2e78a12.json new file mode 100644 index 0000000000..b0f2512dd0 --- /dev/null +++ b/tests/reference/asr-expr2-2e78a12.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr2-2e78a12", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/expr2.py", + "infile_hash": "cded400dff0cf5559a8f8793a05743a98d813344a6a666799e98e994", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr2-2e78a12.stdout", + "stdout_hash": "3734e76d28a7a236562438ddb6e20143939a7b7e85246fa981aca8bf", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr2-2e78a12.stdout b/tests/reference/asr-expr2-2e78a12.stdout new file mode 100644 index 0000000000..8d83056910 --- /dev/null +++ b/tests/reference/asr-expr2-2e78a12.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_boolOp: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Logical 1 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Logical 1 []) Source Public Required .false.)}) test_boolOp [] [(= (Var 2 a) (ConstantLogical .false. (Logical 1 [])) ()) (= (Var 2 b) (ConstantLogical .true. (Logical 1 [])) ()) (= (Var 2 a) (BoolOp (Var 2 a) And (Var 2 b) (Logical 1 []) ()) ()) (= (Var 2 b) (BoolOp (Var 2 a) Or (ConstantLogical .true. (Logical 1 [])) (Logical 1 []) ()) ()) (= (Var 2 a) (BoolOp (Var 2 a) Or (Var 2 b) (Logical 1 []) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr3-10eb0a4.json b/tests/reference/asr-expr3-10eb0a4.json new file mode 100644 index 0000000000..86599ede8c --- /dev/null +++ b/tests/reference/asr-expr3-10eb0a4.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr3-10eb0a4", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/expr3.py", + "infile_hash": "e480142391a42a92a9b87984232e7f7aaf3cfe146149597619e337e6", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr3-10eb0a4.stdout", + "stdout_hash": "b390039fa8bc8662b08d292bc7b9d28308a2a090d9fab2091e440151", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr3-10eb0a4.stdout b/tests/reference/asr-expr3-10eb0a4.stdout new file mode 100644 index 0000000000..397755d90c --- /dev/null +++ b/tests/reference/asr-expr3-10eb0a4.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_cast: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Real 4 []) Source Public Required .false.)}) test_cast [] [(= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (ConstantReal 4.200000 (Real 8 [])) ()) (= (Var 2 a) (BinOp (ImplicitCast (Var 2 a) IntegerToReal (Real 4 []) ()) Mul (Var 2 b) (Real 4 []) () ()) ()) (= (Var 2 b) (BinOp (Var 2 b) Add (ImplicitCast (ConstantInteger 1 (Integer 4 [])) IntegerToReal (Real 4 []) ()) (Real 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 5 (Integer 4 [])) ()) (= (Var 2 a) (BinOp (ImplicitCast (Var 2 a) IntegerToReal (Real 8 []) ()) Sub (ConstantReal 3.900000 (Real 8 [])) (Real 8 []) () ()) ()) (= (Var 2 a) (BinOp (ImplicitCast (Var 2 a) IntegerToReal (Real 8 []) ()) Div (Var 2 b) (Real 8 []) () ()) ()) (= (Var 2 b) (BinOp (ImplicitCast (ConstantInteger 3 (Integer 4 [])) IntegerToReal (Real 8 []) ()) Div (ImplicitCast (ConstantInteger 4 (Integer 4 [])) IntegerToReal (Real 8 []) ()) (Real 8 []) () ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr4-cef6743.json b/tests/reference/asr-expr4-cef6743.json new file mode 100644 index 0000000000..11e5a97726 --- /dev/null +++ b/tests/reference/asr-expr4-cef6743.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr4-cef6743", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/expr4.py", + "infile_hash": "5cba7a5d589f54fc31463e48903d5b46604fb64e3e64ba215339047c", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr4-cef6743.stdout", + "stdout_hash": "5583d9fc67140d17b34b6274070c79ae86d8f77069d7142f15712f96", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr4-cef6743.stdout b/tests/reference/asr-expr4-cef6743.stdout new file mode 100644 index 0000000000..5d545dc51d --- /dev/null +++ b/tests/reference/asr-expr4-cef6743.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_del: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Integer 4 []) Source Public Required .false.)}) test_del [] [(= (Var 2 a) (ConstantInteger 4 (Integer 4 [])) ()) (= (Var 2 b) (ConstantInteger 20 (Integer 4 [])) ()) (ExplicitDeallocate [2 a 2 b])] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr5-645ffcc.json b/tests/reference/asr-expr5-645ffcc.json new file mode 100644 index 0000000000..e021e6cfd5 --- /dev/null +++ b/tests/reference/asr-expr5-645ffcc.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr5-645ffcc", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/expr5.py", + "infile_hash": "07f99b669d2c4a308fbaf871751d58e8642bba8a44694d4ee0091af1", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr5-645ffcc.stdout", + "stdout_hash": "c607265fa6b01ba1b5ea13fab3721e5904c6ab51d45d86dea4f4eb26", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr5-645ffcc.stdout b/tests/reference/asr-expr5-645ffcc.stdout new file mode 100644 index 0000000000..6107796a5b --- /dev/null +++ b/tests/reference/asr-expr5-645ffcc.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_strOP: (Subroutine (SymbolTable 2 {s: (Variable 2 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_strOP [] [(= (Var 2 s) (StrOp (ConstantString "a" (Character 1 1 () [])) Repeat (ConstantInteger 2 (Integer 4 [])) (Character 1 1 () []) ()) ()) (= (Var 2 s) (StrOp (ConstantInteger 4 (Integer 4 [])) Repeat (ConstantString "bb" (Character 1 2 () [])) (Character 1 2 () []) ()) ()) (= (Var 2 s) (StrOp (StrOp (ConstantInteger 3 (Integer 4 [])) Repeat (ConstantString "a" (Character 1 1 () [])) (Character 1 1 () []) ()) Repeat (ConstantInteger 3 (Integer 4 [])) (Character 1 1 () []) ()) ()) (= (Var 2 s) (StrOp (ConstantString "3" (Character 1 1 () [])) Concat (ConstantString "4" (Character 1 1 () [])) (Character 1 1 () []) ()) ()) (= (Var 2 s) (StrOp (Var 2 s) Concat (ConstantString "test" (Character 1 4 () [])) (Character 1 -2 () []) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr6-368e5ed.json b/tests/reference/asr-expr6-368e5ed.json new file mode 100644 index 0000000000..ccca85bd58 --- /dev/null +++ b/tests/reference/asr-expr6-368e5ed.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr6-368e5ed", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/expr6.py", + "infile_hash": "ccd80815d3d381662236e18e3e512367820c95ff3968061cbbab5cd9", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr6-368e5ed.stdout", + "stdout_hash": "fc356cbd04af62a67da22c0cd467f41c174960047f06997b33293ee9", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr6-368e5ed.stdout b/tests/reference/asr-expr6-368e5ed.stdout new file mode 100644 index 0000000000..39d6f42212 --- /dev/null +++ b/tests/reference/asr-expr6-368e5ed.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_ifexp: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Integer 4 []) Source Public Required .false.)}) test_ifexp [] [(= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (IfExp (Compare (Var 2 a) Eq (ConstantInteger 2 (Integer 4 [])) (Logical 4 []) () ()) (ConstantInteger 6 (Integer 4 [])) (ConstantInteger 8 (Integer 4 [])) (Integer 4 [])) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr7-480ba2f.json b/tests/reference/asr-expr7-480ba2f.json new file mode 100644 index 0000000000..28aa9a2062 --- /dev/null +++ b/tests/reference/asr-expr7-480ba2f.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr7-480ba2f", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/expr7.py", + "infile_hash": "028150c053641a5eb79affc1224b5616a2639c9d5a4e2bd2624fc18e", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr7-480ba2f.stdout", + "stdout_hash": "c64379b5a8ed70894842b37c9c76b9c84a1859aea05b6c4da9b8fa7c", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr7-480ba2f.stdout b/tests/reference/asr-expr7-480ba2f.stdout new file mode 100644 index 0000000000..a968d8db30 --- /dev/null +++ b/tests/reference/asr-expr7-480ba2f.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_pow: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.)}) test_pow [] [(= (Var 2 a) (BinOp (ConstantInteger 2 (Integer 4 [])) Pow (ConstantInteger 2 (Integer 4 [])) (Integer 4 []) () ()) ())] Source Public Implementation () .false. .false.), test_pow_1: (Subroutine (SymbolTable 3 {a: (Variable 3 a In () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 3 b In () () Default (Integer 4 []) Source Public Required .false.), res: (Variable 3 res Local () () Default (Integer 4 []) Source Public Required .false.)}) test_pow_1 [(Var 3 a) (Var 3 b)] [(= (Var 3 res) (BinOp (Var 3 a) Pow (Var 3 b) (Integer 4 []) () ()) ()) (Return)] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-loop1-10d3109.json b/tests/reference/asr-loop1-10d3109.json new file mode 100644 index 0000000000..f599d7609e --- /dev/null +++ b/tests/reference/asr-loop1-10d3109.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-loop1-10d3109", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/loop1.py", + "infile_hash": "74a4bee448a718086f59e717b68c1cd7bbcb50e5de72ec0b86e25c51", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-loop1-10d3109.stdout", + "stdout_hash": "d5aba71aced70a3037cab7b7ca2b52af2354e6af1e2a1f8e139b598c", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-loop1-10d3109.stdout b/tests/reference/asr-loop1-10d3109.stdout new file mode 100644 index 0000000000..db8ff7bd76 --- /dev/null +++ b/tests/reference/asr-loop1-10d3109.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_factorial_1: (Subroutine (SymbolTable 2 {result: (Variable 2 result Local () () Default (Integer 4 []) Source Public Required .false.), x: (Variable 2 x In () () Default (Integer 4 []) Source Public Required .false.)}) test_factorial_1 [(Var 2 x)] [(If (Compare (Var 2 x) Lt (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) () ()) [(Return)] []) (= (Var 2 result) (ConstantInteger 1 (Integer 4 [])) ()) (WhileLoop (Compare (Var 2 x) Gt (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) () ()) [(= (Var 2 result) (BinOp (Var 2 result) Mul (Var 2 x) (Integer 4 []) () ()) ()) (= (Var 2 x) (BinOp (Var 2 x) Sub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) () ()) ())]) (Return)] Source Public Implementation () .false. .false.), test_factorial_2: (Subroutine (SymbolTable 3 {i: (Variable 3 i Local () () Default (Integer 4 []) Source Public Required .false.), result: (Variable 3 result Local () () Default (Integer 4 []) Source Public Required .false.), x: (Variable 3 x In () () Default (Integer 4 []) Source Public Required .false.)}) test_factorial_2 [(Var 3 x)] [(= (Var 3 result) (ConstantInteger 1 (Integer 4 [])) ()) (DoLoop ((Var 3 i) (ConstantInteger 1 (Integer 4 [])) (BinOp (Var 3 x) Add (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) () ()) (ConstantInteger 1 (Integer 4 []))) [(= (Var 3 result) (BinOp (Var 3 result) Mul (Var 3 i) (Integer 4 []) () ()) ())]) (Return)] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-loop2-e874469.json b/tests/reference/asr-loop2-e874469.json new file mode 100644 index 0000000000..69c848595b --- /dev/null +++ b/tests/reference/asr-loop2-e874469.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-loop2-e874469", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/loop2.py", + "infile_hash": "ca62d52ec7887e3a455cec87a0e49102e94e96db925f6c37edb792e7", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-loop2-e874469.stdout", + "stdout_hash": "03f169279ca3496703b5a91f94c46bb5f0b555329f9a4bf02b2939a2", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-loop2-e874469.stdout b/tests/reference/asr-loop2-e874469.stdout new file mode 100644 index 0000000000..ccf98547b9 --- /dev/null +++ b/tests/reference/asr-loop2-e874469.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_for: (Subroutine (SymbolTable 2 {i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) test_for [] [(DoLoop ((Var 2 i) (ConstantInteger 0 (Integer 4 [])) (ConstantInteger 10 (Integer 4 [])) (ConstantInteger 1 (Integer 4 []))) [(If (Compare (Var 2 i) Eq (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) () ()) [(Cycle)] []) (If (Compare (Var 2 i) Gt (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) () ()) [(Exit)] [])])] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-loop3-a579196.json b/tests/reference/asr-loop3-a579196.json new file mode 100644 index 0000000000..c6d92d22e6 --- /dev/null +++ b/tests/reference/asr-loop3-a579196.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-loop3-a579196", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/loop3.py", + "infile_hash": "498c7c40ca352ed21dde33c128aff4d59d3c329e770e3a2ff3eb3fad", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-loop3-a579196.stdout", + "stdout_hash": "a7166e69aec2f4d924ccd850da945e18bd053e0e20fdf12c7af81094", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-loop3-a579196.stdout b/tests/reference/asr-loop3-a579196.stdout new file mode 100644 index 0000000000..37310b8557 --- /dev/null +++ b/tests/reference/asr-loop3-a579196.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {test_pass: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.)}) test_pass [] [(= (Var 2 a) (ConstantInteger 1 (Integer 4 [])) ()) (WhileLoop (Compare (Var 2 a) Gt (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) () ()) [])] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/ast-assert1-b0154ee.json b/tests/reference/ast-assert1-b0154ee.json new file mode 100644 index 0000000000..ff9325ec64 --- /dev/null +++ b/tests/reference/ast-assert1-b0154ee.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-assert1-b0154ee", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/assert1.py", + "infile_hash": "f147a7c915580ec3722bd549a70fb9deda56527fe564c5c6f7228066", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-assert1-b0154ee.stdout", + "stdout_hash": "4a87bac65d736f8e6f2977af53c12b1f5584e2ad24c70ac40922d17b", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-assert1-b0154ee.stdout b/tests/reference/ast-assert1-b0154ee.stdout new file mode 100644 index 0000000000..fcd75a911b --- /dev/null +++ b/tests/reference/ast-assert1-b0154ee.stdout @@ -0,0 +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 ())]) ())] [] () ())] []) diff --git a/tests/reference/ast-assign1-2a4c9ed.json b/tests/reference/ast-assign1-2a4c9ed.json new file mode 100644 index 0000000000..d61de29aed --- /dev/null +++ b/tests/reference/ast-assign1-2a4c9ed.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-assign1-2a4c9ed", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/assign1.py", + "infile_hash": "3b82a73e457bd65e85828b72d56596ca927e7c661e333691f154912b", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-assign1-2a4c9ed.stdout", + "stdout_hash": "19d9109b08fcd6ce10cf3f4290371653b686d1d70c702195c3337fad", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-assign1-2a4c9ed.stdout b/tests/reference/ast-assign1-2a4c9ed.stdout new file mode 100644 index 0000000000..ac99ce30a7 --- /dev/null +++ b/tests/reference/ast-assign1-2a4c9ed.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_augassign ([] [] [] [] [] [] []) [(AnnAssign (Name r Store) (Name i32 Load) () 1) (AnnAssign (Name s Store) (Name i32 Load) () 1) (Assign [(Name r Store)] (ConstantInt 0 ()) ()) (AugAssign (Name r Store) Add (ConstantInt 4 ())) (Assign [(Name s Store)] (ConstantInt 5 ()) ()) (AugAssign (Name r Store) Mult (Name s Load)) (AugAssign (Name r Store) Sub (ConstantInt 2 ())) (Assign [(Name s Store)] (ConstantInt 10 ()) ()) (AugAssign (Name r Store) Div (Name s Load)) (AnnAssign (Name a Store) (Name str Load) () 1) (Assign [(Name a Store)] (ConstantStr "" ()) ()) (AugAssign (Name a Store) Add (ConstantStr "test" ()))] [] () ())] []) diff --git a/tests/reference/ast-constants1-91cb6ff.json b/tests/reference/ast-constants1-91cb6ff.json index dfdf018d5e..15d996fd70 100644 --- a/tests/reference/ast-constants1-91cb6ff.json +++ b/tests/reference/ast-constants1-91cb6ff.json @@ -2,11 +2,11 @@ "basename": "ast-constants1-91cb6ff", "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", "infile": "tests/constants1.py", - "infile_hash": "673145c1bcbf90af453feda6f0abfeaaae3c2f04a191b32500fa0217", + "infile_hash": "c5648d1d7f443b239f85aff60c596e54e57a93f7fe6db70bee361ebc", "outfile": null, "outfile_hash": null, "stdout": "ast-constants1-91cb6ff.stdout", - "stdout_hash": "fe8c6fe87fb9f1cd76bef15da15d474bcb2c7612769010d2e90aaa9b", + "stdout_hash": "48737b48909c8152a8e35d8122c64ad05b46c34665734586f81dd8ec", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast-constants1-91cb6ff.stdout b/tests/reference/ast-constants1-91cb6ff.stdout index 70bd881150..1cb469ce55 100644 --- a/tests/reference/ast-constants1-91cb6ff.stdout +++ b/tests/reference/ast-constants1-91cb6ff.stdout @@ -1 +1 @@ -(Module [(FunctionDef test_boz ([] [] [] [] [] [] []) [(AnnAssign (Name b Store) (Name str Load) () 1) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 64 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 8 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 56 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 42 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 12648430 ())] []) ())] [] () ())] []) +(Module [(FunctionDef test_boz ([] [] [] [] [] [] []) [(AnnAssign (Name b Store) (Name str Load) () 1) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 64 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 8 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 56 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 42 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 12648430 ())] []) ())] [] () ()) (FunctionDef test_ord_chr ([] [] [] [] [] [] []) [(AnnAssign (Name s Store) (Name str Load) () 1) (AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name ord Load) [(ConstantStr "5" ())] []) ()) (Assign [(Name s Store)] (Call (Name chr Load) [(ConstantInt 43 ())] []) ())] [] () ())] []) diff --git a/tests/reference/ast-expr2-6642d4a.json b/tests/reference/ast-expr2-6642d4a.json new file mode 100644 index 0000000000..e9d60e2c24 --- /dev/null +++ b/tests/reference/ast-expr2-6642d4a.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-expr2-6642d4a", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/expr2.py", + "infile_hash": "cded400dff0cf5559a8f8793a05743a98d813344a6a666799e98e994", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-expr2-6642d4a.stdout", + "stdout_hash": "45b0ac96530a1d80511113a6e59899c272ccda2d40bfa3ad71a1239b", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-expr2-6642d4a.stdout b/tests/reference/ast-expr2-6642d4a.stdout new file mode 100644 index 0000000000..33b1b59719 --- /dev/null +++ b/tests/reference/ast-expr2-6642d4a.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_boolOp ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name bool Load) () 1) (AnnAssign (Name b Store) (Name bool Load) () 1) (Assign [(Name a Store)] (ConstantBool .false. ()) ()) (Assign [(Name b Store)] (ConstantBool .true. ()) ()) (Assign [(Name a Store)] (BoolOp And [(Name a Load) (Name b Load)]) ()) (Assign [(Name b Store)] (BoolOp Or [(Name a Load) (ConstantBool .true. ())]) ()) (Assign [(Name a Store)] (BoolOp Or [(Name a Load) (Name b Load)]) ())] [] () ())] []) diff --git a/tests/reference/ast-expr3-c3dcaab.json b/tests/reference/ast-expr3-c3dcaab.json new file mode 100644 index 0000000000..7d7fab88fa --- /dev/null +++ b/tests/reference/ast-expr3-c3dcaab.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-expr3-c3dcaab", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/expr3.py", + "infile_hash": "e480142391a42a92a9b87984232e7f7aaf3cfe146149597619e337e6", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-expr3-c3dcaab.stdout", + "stdout_hash": "7f4ed03f63d9e0696b5cc7aa904e2cc1a8be0d2eff37d81577aad3d3", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-expr3-c3dcaab.stdout b/tests/reference/ast-expr3-c3dcaab.stdout new file mode 100644 index 0000000000..e69b9d54e2 --- /dev/null +++ b/tests/reference/ast-expr3-c3dcaab.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_cast ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (AnnAssign (Name b Store) (Name f32 Load) () 1) (Assign [(Name a Store)] (ConstantInt 2 ()) ()) (Assign [(Name b Store)] (ConstantFloat 4.200000 ()) ()) (AugAssign (Name a Store) Mult (Name b Load)) (AugAssign (Name b Store) Add (ConstantInt 1 ())) (Assign [(Name a Store)] (ConstantInt 5 ()) ()) (AugAssign (Name a Store) Sub (ConstantFloat 3.900000 ())) (AugAssign (Name a Store) Div (Name b Load)) (Assign [(Name b Store)] (BinOp (ConstantInt 3 ()) Div (ConstantInt 4 ())) ())] [] () ())] []) diff --git a/tests/reference/ast-expr4-49316cb.json b/tests/reference/ast-expr4-49316cb.json new file mode 100644 index 0000000000..616e5f940c --- /dev/null +++ b/tests/reference/ast-expr4-49316cb.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-expr4-49316cb", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/expr4.py", + "infile_hash": "5cba7a5d589f54fc31463e48903d5b46604fb64e3e64ba215339047c", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-expr4-49316cb.stdout", + "stdout_hash": "0021b494511ff634740b74baed3fcad55b0559c874433a63756f257d", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-expr4-49316cb.stdout b/tests/reference/ast-expr4-49316cb.stdout new file mode 100644 index 0000000000..295392bbee --- /dev/null +++ b/tests/reference/ast-expr4-49316cb.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_del ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (AnnAssign (Name b Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (ConstantInt 4 ()) ()) (Assign [(Name b Store)] (ConstantInt 20 ()) ()) (Delete [(Name a Del) (Name b Del)])] [] () ())] []) diff --git a/tests/reference/ast-expr5-bbc6e71.json b/tests/reference/ast-expr5-bbc6e71.json new file mode 100644 index 0000000000..1eeec10bc2 --- /dev/null +++ b/tests/reference/ast-expr5-bbc6e71.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-expr5-bbc6e71", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/expr5.py", + "infile_hash": "07f99b669d2c4a308fbaf871751d58e8642bba8a44694d4ee0091af1", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-expr5-bbc6e71.stdout", + "stdout_hash": "e9ad7601c1003e633f5eb7215a82a72abe4d8d6f9b88e0ed24952472", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-expr5-bbc6e71.stdout b/tests/reference/ast-expr5-bbc6e71.stdout new file mode 100644 index 0000000000..21bfe30a3a --- /dev/null +++ b/tests/reference/ast-expr5-bbc6e71.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_strOP ([] [] [] [] [] [] []) [(AnnAssign (Name s Store) (Name str Load) () 1) (Assign [(Name s Store)] (BinOp (ConstantStr "a" ()) Mult (ConstantInt 2 ())) ()) (Assign [(Name s Store)] (BinOp (ConstantInt 4 ()) Mult (ConstantStr "bb" ())) ()) (Assign [(Name s Store)] (BinOp (BinOp (ConstantInt 3 ()) Mult (ConstantStr "a" ())) Mult (ConstantInt 3 ())) ()) (Assign [(Name s Store)] (BinOp (ConstantStr "3" ()) Add (ConstantStr "4" ())) ()) (AugAssign (Name s Store) Add (ConstantStr "test" ()))] [] () ())] []) diff --git a/tests/reference/ast-expr6-0b12a67.json b/tests/reference/ast-expr6-0b12a67.json new file mode 100644 index 0000000000..cdfd0d8e73 --- /dev/null +++ b/tests/reference/ast-expr6-0b12a67.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-expr6-0b12a67", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/expr6.py", + "infile_hash": "ccd80815d3d381662236e18e3e512367820c95ff3968061cbbab5cd9", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-expr6-0b12a67.stdout", + "stdout_hash": "8cc5bc1c128930ce95f37e9918027598ba92845ad3f949ac4a9ab760", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-expr6-0b12a67.stdout b/tests/reference/ast-expr6-0b12a67.stdout new file mode 100644 index 0000000000..73dd345e1e --- /dev/null +++ b/tests/reference/ast-expr6-0b12a67.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_ifexp ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (ConstantInt 2 ()) ()) (AnnAssign (Name b Store) (Name i32 Load) () 1) (Assign [(Name b Store)] (IfExp (Compare (Name a Load) Eq [(ConstantInt 2 ())]) (ConstantInt 6 ()) (ConstantInt 8 ())) ())] [] () ())] []) diff --git a/tests/reference/ast-expr7-fe52776.json b/tests/reference/ast-expr7-fe52776.json new file mode 100644 index 0000000000..0260f013f6 --- /dev/null +++ b/tests/reference/ast-expr7-fe52776.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-expr7-fe52776", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/expr7.py", + "infile_hash": "028150c053641a5eb79affc1224b5616a2639c9d5a4e2bd2624fc18e", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-expr7-fe52776.stdout", + "stdout_hash": "e0535aa1561e00f0e9a30106da62cebcf62a4a299875546651e59b22", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-expr7-fe52776.stdout b/tests/reference/ast-expr7-fe52776.stdout new file mode 100644 index 0000000000..507f78821a --- /dev/null +++ b/tests/reference/ast-expr7-fe52776.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_pow ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name pow Load) [(ConstantInt 2 ()) (ConstantInt 2 ())] []) ())] [] () ()) (FunctionDef test_pow_1 ([] [(a (Name i32 Load) ()) (b (Name i32 Load) ())] [] [] [] [] []) [(AnnAssign (Name res Store) (Name i32 Load) () 1) (Assign [(Name res Store)] (Call (Name pow Load) [(Name a Load) (Name b Load)] []) ()) (Return (Name res Load))] [] (Name i32 Load) ())] []) diff --git a/tests/reference/ast-loop1-194a137.json b/tests/reference/ast-loop1-194a137.json new file mode 100644 index 0000000000..7249427fa5 --- /dev/null +++ b/tests/reference/ast-loop1-194a137.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-loop1-194a137", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/loop1.py", + "infile_hash": "74a4bee448a718086f59e717b68c1cd7bbcb50e5de72ec0b86e25c51", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-loop1-194a137.stdout", + "stdout_hash": "f1c67e4d3cc48bdb7d88813ca253f6a451d2e3561ed4661115b30b36", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-loop1-194a137.stdout b/tests/reference/ast-loop1-194a137.stdout new file mode 100644 index 0000000000..96e57f8146 --- /dev/null +++ b/tests/reference/ast-loop1-194a137.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_factorial_1 ([] [(x (Name i32 Load) ())] [] [] [] [] []) [(If (Compare (Name x Load) Lt [(ConstantInt 0 ())]) [(Return (ConstantInt 0 ()))] []) (AnnAssign (Name result Store) (Name i32 Load) () 1) (Assign [(Name result Store)] (ConstantInt 1 ()) ()) (While (Compare (Name x Load) Gt [(ConstantInt 0 ())]) [(Assign [(Name result Store)] (BinOp (Name result Load) Mult (Name x Load)) ()) (AugAssign (Name x Store) Sub (ConstantInt 1 ()))] []) (Return (Name result Load))] [] (Name i32 Load) ()) (FunctionDef test_factorial_2 ([] [(x (Name i32 Load) ())] [] [] [] [] []) [(AnnAssign (Name result Store) (Name i32 Load) () 1) (Assign [(Name result Store)] (ConstantInt 1 ()) ()) (AnnAssign (Name i Store) (Name i32 Load) () 1) (For (Name i Store) (Call (Name range Load) [(ConstantInt 1 ()) (BinOp (Name x Load) Add (ConstantInt 1 ()))] []) [(Assign [(Name result Store)] (BinOp (Name result Load) Mult (Name i Load)) ())] [] ()) (Return (Name result Load))] [] (Name i32 Load) ())] []) diff --git a/tests/reference/ast-loop2-63bf329.json b/tests/reference/ast-loop2-63bf329.json new file mode 100644 index 0000000000..35a41db39b --- /dev/null +++ b/tests/reference/ast-loop2-63bf329.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-loop2-63bf329", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/loop2.py", + "infile_hash": "ca62d52ec7887e3a455cec87a0e49102e94e96db925f6c37edb792e7", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-loop2-63bf329.stdout", + "stdout_hash": "946697009bcccd7ecbec9f12306b187e3cf9ee31fb9d86f2ad33b43c", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-loop2-63bf329.stdout b/tests/reference/ast-loop2-63bf329.stdout new file mode 100644 index 0000000000..041c6e8e2b --- /dev/null +++ b/tests/reference/ast-loop2-63bf329.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_for ([] [] [] [] [] [] []) [(AnnAssign (Name i Store) (Name i32 Load) () 1) (For (Name i Store) (Call (Name range Load) [(ConstantInt 0 ()) (ConstantInt 10 ())] []) [(If (Compare (Name i Load) Eq [(ConstantInt 0 ())]) [(Continue)] []) (If (Compare (Name i Load) Gt [(ConstantInt 5 ())]) [(Break)] [])] [] ())] [] () ())] []) diff --git a/tests/reference/ast-loop3-f7e0393.json b/tests/reference/ast-loop3-f7e0393.json new file mode 100644 index 0000000000..ebff9d08a1 --- /dev/null +++ b/tests/reference/ast-loop3-f7e0393.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-loop3-f7e0393", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/loop3.py", + "infile_hash": "498c7c40ca352ed21dde33c128aff4d59d3c329e770e3a2ff3eb3fad", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-loop3-f7e0393.stdout", + "stdout_hash": "be67a3e6ee1476ffdec959b2875d68f1d4fe16418327c746d3e64a14", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-loop3-f7e0393.stdout b/tests/reference/ast-loop3-f7e0393.stdout new file mode 100644 index 0000000000..301bace0af --- /dev/null +++ b/tests/reference/ast-loop3-f7e0393.stdout @@ -0,0 +1 @@ +(Module [(FunctionDef test_pass ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (ConstantInt 1 ()) ()) (While (Compare (Name a Load) Gt [(ConstantInt 0 ())]) [(Pass)] [])] [] () ())] []) diff --git a/tests/reference/cpp-expr2-09c05ad.json b/tests/reference/cpp-expr2-09c05ad.json new file mode 100644 index 0000000000..fad867f987 --- /dev/null +++ b/tests/reference/cpp-expr2-09c05ad.json @@ -0,0 +1,13 @@ +{ + "basename": "cpp-expr2-09c05ad", + "cmd": "lpython --no-color --show-cpp {infile}", + "infile": "tests/expr2.py", + "infile_hash": "cded400dff0cf5559a8f8793a05743a98d813344a6a666799e98e994", + "outfile": null, + "outfile_hash": null, + "stdout": "cpp-expr2-09c05ad.stdout", + "stdout_hash": "6d6b7b5a6aa1705250c2627ff642b2dcd0ac185737253a166dd2e05e", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/cpp-expr2-09c05ad.stdout b/tests/reference/cpp-expr2-09c05ad.stdout new file mode 100644 index 0000000000..bce8302119 --- /dev/null +++ b/tests/reference/cpp-expr2-09c05ad.stdout @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include + +template +Kokkos::View from_std_vector(const std::vector &v) +{ + Kokkos::View r("r", v.size()); + for (size_t i=0; i < v.size(); i++) { + r(i) = v[i]; + } + return r; +} + +void test_boolOp() +{ + bool a; + bool b; + a = false; + b = true; + a = (a) && (b); + b = (a) || (true); + a = (a) || (b); +} + diff --git a/tests/reference/cpp-expr7-529bd53.json b/tests/reference/cpp-expr7-529bd53.json new file mode 100644 index 0000000000..7afc9c04c2 --- /dev/null +++ b/tests/reference/cpp-expr7-529bd53.json @@ -0,0 +1,13 @@ +{ + "basename": "cpp-expr7-529bd53", + "cmd": "lpython --no-color --show-cpp {infile}", + "infile": "tests/expr7.py", + "infile_hash": "028150c053641a5eb79affc1224b5616a2639c9d5a4e2bd2624fc18e", + "outfile": null, + "outfile_hash": null, + "stdout": "cpp-expr7-529bd53.stdout", + "stdout_hash": "3f93dd9eea1d97b33cdb277f1948e7c0b28b6187557ec3952fe77a5f", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/cpp-expr7-529bd53.stdout b/tests/reference/cpp-expr7-529bd53.stdout new file mode 100644 index 0000000000..cab78d67c1 --- /dev/null +++ b/tests/reference/cpp-expr7-529bd53.stdout @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include + +template +Kokkos::View from_std_vector(const std::vector &v) +{ + Kokkos::View r("r", v.size()); + for (size_t i=0; i < v.size(); i++) { + r(i) = v[i]; + } + return r; +} + +void test_pow() +{ + int a; + a = std::pow(2, 2); +} + +void test_pow_1(int a, int b) +{ + int res; + res = std::pow(a, b); + return; +} + diff --git a/tests/reference/cpp-loop1-0a8cf3b.json b/tests/reference/cpp-loop1-0a8cf3b.json new file mode 100644 index 0000000000..d3652035e1 --- /dev/null +++ b/tests/reference/cpp-loop1-0a8cf3b.json @@ -0,0 +1,13 @@ +{ + "basename": "cpp-loop1-0a8cf3b", + "cmd": "lpython --no-color --show-cpp {infile}", + "infile": "tests/loop1.py", + "infile_hash": "74a4bee448a718086f59e717b68c1cd7bbcb50e5de72ec0b86e25c51", + "outfile": null, + "outfile_hash": null, + "stdout": "cpp-loop1-0a8cf3b.stdout", + "stdout_hash": "20366c1e6e352072af16b1b972f5816af4b4db5869683c8f7c04f42f", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/cpp-loop1-0a8cf3b.stdout b/tests/reference/cpp-loop1-0a8cf3b.stdout new file mode 100644 index 0000000000..50f1ff8369 --- /dev/null +++ b/tests/reference/cpp-loop1-0a8cf3b.stdout @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include + +template +Kokkos::View from_std_vector(const std::vector &v) +{ + Kokkos::View r("r", v.size()); + for (size_t i=0; i < v.size(); i++) { + r(i) = v[i]; + } + return r; +} + +void test_factorial_1(int x) +{ + int result; + if (x < 0) { + return; + }; + result = 1; + while (x > 0) { + result = result*x; + x = x - 1; + }; + return; +} + +void test_factorial_2(int x) +{ + int i; + int result; + result = 1; + for (i=1; i<=x + 1; i++) { + result = result*i; + }; + return; +} + diff --git a/tests/tests.toml b/tests/tests.toml index e1106479b9..22107ad894 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -25,8 +25,65 @@ ast = true asr = true [[test]] +filename = "expr2.py" +ast = true +asr = true +cpp = true + +[[test]] +filename = "expr3.py" +ast = true +asr = true + +[[test]] +filename = "expr4.py" +ast = true +asr = true + +[[test]] +filename = "expr5.py" +ast = true +asr = true + +[[test]] +filename = "expr6.py" +ast = true +asr = true + +[[test]] +filename = "expr7.py" +ast = true +asr = true +cpp = true +[[test]] filename = "expr_01.py" ast = true asr = true llvm = true + +[[test]] +filename = "loop1.py" +ast = true +asr = true +cpp = true + +[[test]] +filename = "loop2.py" +ast = true +asr = true + +[[test]] +filename = "loop3.py" +ast = true +asr = true + +[[test]] +filename = "assert1.py" +ast = true +asr = true + +[[test]] +filename = "assign1.py" +ast = true +asr = true