From 5ddd129b218e94038af446374a6b3c332bc36a07 Mon Sep 17 00:00:00 2001 From: Khushi Agrawal Date: Thu, 7 Mar 2024 12:22:32 +0530 Subject: [PATCH 1/3] register tests/expr17.py --- tests/reference/asr-expr17-6705097.json | 13 ++ tests/reference/asr-expr17-6705097.stdout | 121 +++++++++++++++++++ tests/reference/ast-expr17-c844e67.json | 13 ++ tests/reference/ast-expr17-c844e67.stdout | 104 ++++++++++++++++ tests/reference/cpp-expr17-8e3c418.json | 13 ++ tests/reference/cpp-expr17-8e3c418.stdout | 37 ++++++ tests/reference/llvm-expr17-4ac02aa.json | 13 ++ tests/reference/llvm-expr17-4ac02aa.stdout | 10 ++ tests/reference/python-expr17-3b84714.json | 13 ++ tests/reference/python-expr17-3b84714.stdout | 14 +++ tests/tests.toml | 8 ++ 11 files changed, 359 insertions(+) create mode 100644 tests/reference/asr-expr17-6705097.json create mode 100644 tests/reference/asr-expr17-6705097.stdout create mode 100644 tests/reference/ast-expr17-c844e67.json create mode 100644 tests/reference/ast-expr17-c844e67.stdout create mode 100644 tests/reference/cpp-expr17-8e3c418.json create mode 100644 tests/reference/cpp-expr17-8e3c418.stdout create mode 100644 tests/reference/llvm-expr17-4ac02aa.json create mode 100644 tests/reference/llvm-expr17-4ac02aa.stdout create mode 100644 tests/reference/python-expr17-3b84714.json create mode 100644 tests/reference/python-expr17-3b84714.stdout diff --git a/tests/reference/asr-expr17-6705097.json b/tests/reference/asr-expr17-6705097.json new file mode 100644 index 0000000000..2993ab3a38 --- /dev/null +++ b/tests/reference/asr-expr17-6705097.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-expr17-6705097", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/expr17.py", + "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-expr17-6705097.stdout", + "stdout_hash": "a040b3e82ccf704971a72ab2b5a7e532b7a54922e66fb790c10a1e11", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-expr17-6705097.stdout b/tests/reference/asr-expr17-6705097.stdout new file mode 100644 index 0000000000..4cd222ccbe --- /dev/null +++ b/tests/reference/asr-expr17-6705097.stdout @@ -0,0 +1,121 @@ +(TranslationUnit + (SymbolTable + 1 + { + __main__: + (Module + (SymbolTable + 2 + { + if_check: + (Function + (SymbolTable + 3 + { + a: + (Variable + 3 + a + [] + Local + () + () + Default + (Integer 4) + () + Source + Public + Required + .false. + ) + }) + if_check + (FunctionType + [] + () + Source + Implementation + () + .false. + .false. + .false. + .false. + .false. + [] + .false. + ) + [] + [] + [(= + (Var 3 a) + (IntegerConstant 4 (Integer 4)) + () + ) + (If + (IntegerCompare + (Var 3 a) + Lt + (IntegerConstant 0 (Integer 4)) + (Logical 4) + () + ) + [(Print + [(StringConstant + "negative value" + (Character 1 14 ()) + )] + () + () + )] + [(If + (IntegerCompare + (Var 3 a) + Gt + (IntegerConstant 0 (Integer 4)) + (Logical 4) + () + ) + [(Print + [(StringConstant + "positive value" + (Character 1 14 ()) + )] + () + () + )] + [(Print + [(StringConstant + "zero" + (Character 1 4 ()) + )] + () + () + )] + )] + )] + () + Public + .false. + .false. + () + ) + }) + __main__ + [] + .false. + .false. + ), + main_program: + (Program + (SymbolTable + 4 + { + + }) + main_program + [] + [] + ) + }) + [] +) diff --git a/tests/reference/ast-expr17-c844e67.json b/tests/reference/ast-expr17-c844e67.json new file mode 100644 index 0000000000..873ee3b383 --- /dev/null +++ b/tests/reference/ast-expr17-c844e67.json @@ -0,0 +1,13 @@ +{ + "basename": "ast-expr17-c844e67", + "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", + "infile": "tests/expr17.py", + "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", + "outfile": null, + "outfile_hash": null, + "stdout": "ast-expr17-c844e67.stdout", + "stdout_hash": "788d0bd4c77e189c8ea0fe88146961060c6867d3d88b2f78eda9e76f", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/ast-expr17-c844e67.stdout b/tests/reference/ast-expr17-c844e67.stdout new file mode 100644 index 0000000000..0aa3a96975 --- /dev/null +++ b/tests/reference/ast-expr17-c844e67.stdout @@ -0,0 +1,104 @@ +(Module + [(FunctionDef + if_check + ([] + [] + [] + [] + [] + [] + []) + [(AnnAssign + (Name + a + Store + ) + (Name + i32 + Load + ) + () + 1 + ) + (Assign + [(Name + a + Store + )] + (ConstantInt + 4 + () + ) + () + ) + (If + (Compare + (Name + a + Load + ) + Lt + [(ConstantInt + 0 + () + )] + ) + [(Expr + (Call + (Name + print + Load + ) + [(ConstantStr + "negative value" + () + )] + [] + ) + )] + [(If + (Compare + (Name + a + Load + ) + Gt + [(ConstantInt + 0 + () + )] + ) + [(Expr + (Call + (Name + print + Load + ) + [(ConstantStr + "positive value" + () + )] + [] + ) + )] + [(Expr + (Call + (Name + print + Load + ) + [(ConstantStr + "zero" + () + )] + [] + ) + )] + )] + )] + [] + () + () + )] + [] +) diff --git a/tests/reference/cpp-expr17-8e3c418.json b/tests/reference/cpp-expr17-8e3c418.json new file mode 100644 index 0000000000..ae6d963b98 --- /dev/null +++ b/tests/reference/cpp-expr17-8e3c418.json @@ -0,0 +1,13 @@ +{ + "basename": "cpp-expr17-8e3c418", + "cmd": "lpython --no-color --show-cpp {infile}", + "infile": "tests/expr17.py", + "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", + "outfile": null, + "outfile_hash": null, + "stdout": "cpp-expr17-8e3c418.stdout", + "stdout_hash": "7ac638e8146f048bd5444436ee2b2ac4f85ffa7a1d791cf526adacb4", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/cpp-expr17-8e3c418.stdout b/tests/reference/cpp-expr17-8e3c418.stdout new file mode 100644 index 0000000000..ea744708f9 --- /dev/null +++ b/tests/reference/cpp-expr17-8e3c418.stdout @@ -0,0 +1,37 @@ +#include +#include +#include +#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; +} + +// Forward declarations +namespace { +} + +// Implementations +namespace { + +void main2() { +} + +} +int main(int argc, char* argv[]) +{ + Kokkos::initialize(argc, argv); + main2(); + Kokkos::finalize(); + return 0; +} diff --git a/tests/reference/llvm-expr17-4ac02aa.json b/tests/reference/llvm-expr17-4ac02aa.json new file mode 100644 index 0000000000..d09f37052f --- /dev/null +++ b/tests/reference/llvm-expr17-4ac02aa.json @@ -0,0 +1,13 @@ +{ + "basename": "llvm-expr17-4ac02aa", + "cmd": "lpython --no-color --show-llvm {infile} -o {outfile}", + "infile": "tests/expr17.py", + "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", + "outfile": null, + "outfile_hash": null, + "stdout": "llvm-expr17-4ac02aa.stdout", + "stdout_hash": "15764832892f7e0cd2a438b247a148564f5f83b3a00ca929bd9cc625", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/llvm-expr17-4ac02aa.stdout b/tests/reference/llvm-expr17-4ac02aa.stdout new file mode 100644 index 0000000000..084a225695 --- /dev/null +++ b/tests/reference/llvm-expr17-4ac02aa.stdout @@ -0,0 +1,10 @@ +; ModuleID = 'LFortran' +source_filename = "LFortran" + +define i32 @main(i32 %0, i8** %1) { +.entry: + call void @_lpython_set_argv(i32 %0, i8** %1) + ret i32 0 +} + +declare void @_lpython_set_argv(i32, i8**) diff --git a/tests/reference/python-expr17-3b84714.json b/tests/reference/python-expr17-3b84714.json new file mode 100644 index 0000000000..11933a5b96 --- /dev/null +++ b/tests/reference/python-expr17-3b84714.json @@ -0,0 +1,13 @@ +{ + "basename": "python-expr17-3b84714", + "cmd": "lpython --no-color --show-python {infile}", + "infile": "tests/expr17.py", + "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", + "outfile": null, + "outfile_hash": null, + "stdout": "python-expr17-3b84714.stdout", + "stdout_hash": "c5754f71e1cd9a019d7289d5ccee634a42d75ac775b0e115eea48f03", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/python-expr17-3b84714.stdout b/tests/reference/python-expr17-3b84714.stdout new file mode 100644 index 0000000000..48b07875e4 --- /dev/null +++ b/tests/reference/python-expr17-3b84714.stdout @@ -0,0 +1,14 @@ +def if_check(): + a: i32 + a = 4 + if (a) < (0): + print("negative value") + else: + if (a) > (0): + print("positive value") + else: + print("zero") + + + + diff --git a/tests/tests.toml b/tests/tests.toml index 9be71acb27..558b3bd8df 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -140,6 +140,14 @@ cpp = true filename = "expr16.py" asr = true +[[test]] +filename = "expr17.py" +asr = true +ast = true +cpp = true +llvm = true +python = true + [[test]] filename = "expr_01.py" ast = true From 39935ba0de8c5341222bdaa20e440139fbb35b6d Mon Sep 17 00:00:00 2001 From: Khushi Agrawal Date: Thu, 7 Mar 2024 12:31:13 +0530 Subject: [PATCH 2/3] remove cpp entry --- tests/reference/cpp-expr17-8e3c418.json | 13 -------- tests/reference/cpp-expr17-8e3c418.stdout | 37 ----------------------- tests/tests.toml | 1 - 3 files changed, 51 deletions(-) delete mode 100644 tests/reference/cpp-expr17-8e3c418.json delete mode 100644 tests/reference/cpp-expr17-8e3c418.stdout diff --git a/tests/reference/cpp-expr17-8e3c418.json b/tests/reference/cpp-expr17-8e3c418.json deleted file mode 100644 index ae6d963b98..0000000000 --- a/tests/reference/cpp-expr17-8e3c418.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "basename": "cpp-expr17-8e3c418", - "cmd": "lpython --no-color --show-cpp {infile}", - "infile": "tests/expr17.py", - "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", - "outfile": null, - "outfile_hash": null, - "stdout": "cpp-expr17-8e3c418.stdout", - "stdout_hash": "7ac638e8146f048bd5444436ee2b2ac4f85ffa7a1d791cf526adacb4", - "stderr": null, - "stderr_hash": null, - "returncode": 0 -} \ No newline at end of file diff --git a/tests/reference/cpp-expr17-8e3c418.stdout b/tests/reference/cpp-expr17-8e3c418.stdout deleted file mode 100644 index ea744708f9..0000000000 --- a/tests/reference/cpp-expr17-8e3c418.stdout +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include -#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; -} - -// Forward declarations -namespace { -} - -// Implementations -namespace { - -void main2() { -} - -} -int main(int argc, char* argv[]) -{ - Kokkos::initialize(argc, argv); - main2(); - Kokkos::finalize(); - return 0; -} diff --git a/tests/tests.toml b/tests/tests.toml index 558b3bd8df..a6786f2a22 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -144,7 +144,6 @@ asr = true filename = "expr17.py" asr = true ast = true -cpp = true llvm = true python = true From a1b7fc6c9ff8c626f2f9acd6cb52e8ec55ced3e9 Mon Sep 17 00:00:00 2001 From: Khushi Agrawal Date: Thu, 7 Mar 2024 13:19:22 +0530 Subject: [PATCH 3/3] only tests python --- tests/reference/asr-expr17-6705097.json | 13 --- tests/reference/asr-expr17-6705097.stdout | 121 --------------------- tests/reference/ast-expr17-c844e67.json | 13 --- tests/reference/ast-expr17-c844e67.stdout | 104 ------------------ tests/reference/llvm-expr17-4ac02aa.json | 13 --- tests/reference/llvm-expr17-4ac02aa.stdout | 10 -- tests/tests.toml | 3 - 7 files changed, 277 deletions(-) delete mode 100644 tests/reference/asr-expr17-6705097.json delete mode 100644 tests/reference/asr-expr17-6705097.stdout delete mode 100644 tests/reference/ast-expr17-c844e67.json delete mode 100644 tests/reference/ast-expr17-c844e67.stdout delete mode 100644 tests/reference/llvm-expr17-4ac02aa.json delete mode 100644 tests/reference/llvm-expr17-4ac02aa.stdout diff --git a/tests/reference/asr-expr17-6705097.json b/tests/reference/asr-expr17-6705097.json deleted file mode 100644 index 2993ab3a38..0000000000 --- a/tests/reference/asr-expr17-6705097.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "basename": "asr-expr17-6705097", - "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", - "infile": "tests/expr17.py", - "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", - "outfile": null, - "outfile_hash": null, - "stdout": "asr-expr17-6705097.stdout", - "stdout_hash": "a040b3e82ccf704971a72ab2b5a7e532b7a54922e66fb790c10a1e11", - "stderr": null, - "stderr_hash": null, - "returncode": 0 -} \ No newline at end of file diff --git a/tests/reference/asr-expr17-6705097.stdout b/tests/reference/asr-expr17-6705097.stdout deleted file mode 100644 index 4cd222ccbe..0000000000 --- a/tests/reference/asr-expr17-6705097.stdout +++ /dev/null @@ -1,121 +0,0 @@ -(TranslationUnit - (SymbolTable - 1 - { - __main__: - (Module - (SymbolTable - 2 - { - if_check: - (Function - (SymbolTable - 3 - { - a: - (Variable - 3 - a - [] - Local - () - () - Default - (Integer 4) - () - Source - Public - Required - .false. - ) - }) - if_check - (FunctionType - [] - () - Source - Implementation - () - .false. - .false. - .false. - .false. - .false. - [] - .false. - ) - [] - [] - [(= - (Var 3 a) - (IntegerConstant 4 (Integer 4)) - () - ) - (If - (IntegerCompare - (Var 3 a) - Lt - (IntegerConstant 0 (Integer 4)) - (Logical 4) - () - ) - [(Print - [(StringConstant - "negative value" - (Character 1 14 ()) - )] - () - () - )] - [(If - (IntegerCompare - (Var 3 a) - Gt - (IntegerConstant 0 (Integer 4)) - (Logical 4) - () - ) - [(Print - [(StringConstant - "positive value" - (Character 1 14 ()) - )] - () - () - )] - [(Print - [(StringConstant - "zero" - (Character 1 4 ()) - )] - () - () - )] - )] - )] - () - Public - .false. - .false. - () - ) - }) - __main__ - [] - .false. - .false. - ), - main_program: - (Program - (SymbolTable - 4 - { - - }) - main_program - [] - [] - ) - }) - [] -) diff --git a/tests/reference/ast-expr17-c844e67.json b/tests/reference/ast-expr17-c844e67.json deleted file mode 100644 index 873ee3b383..0000000000 --- a/tests/reference/ast-expr17-c844e67.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "basename": "ast-expr17-c844e67", - "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", - "infile": "tests/expr17.py", - "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", - "outfile": null, - "outfile_hash": null, - "stdout": "ast-expr17-c844e67.stdout", - "stdout_hash": "788d0bd4c77e189c8ea0fe88146961060c6867d3d88b2f78eda9e76f", - "stderr": null, - "stderr_hash": null, - "returncode": 0 -} \ No newline at end of file diff --git a/tests/reference/ast-expr17-c844e67.stdout b/tests/reference/ast-expr17-c844e67.stdout deleted file mode 100644 index 0aa3a96975..0000000000 --- a/tests/reference/ast-expr17-c844e67.stdout +++ /dev/null @@ -1,104 +0,0 @@ -(Module - [(FunctionDef - if_check - ([] - [] - [] - [] - [] - [] - []) - [(AnnAssign - (Name - a - Store - ) - (Name - i32 - Load - ) - () - 1 - ) - (Assign - [(Name - a - Store - )] - (ConstantInt - 4 - () - ) - () - ) - (If - (Compare - (Name - a - Load - ) - Lt - [(ConstantInt - 0 - () - )] - ) - [(Expr - (Call - (Name - print - Load - ) - [(ConstantStr - "negative value" - () - )] - [] - ) - )] - [(If - (Compare - (Name - a - Load - ) - Gt - [(ConstantInt - 0 - () - )] - ) - [(Expr - (Call - (Name - print - Load - ) - [(ConstantStr - "positive value" - () - )] - [] - ) - )] - [(Expr - (Call - (Name - print - Load - ) - [(ConstantStr - "zero" - () - )] - [] - ) - )] - )] - )] - [] - () - () - )] - [] -) diff --git a/tests/reference/llvm-expr17-4ac02aa.json b/tests/reference/llvm-expr17-4ac02aa.json deleted file mode 100644 index d09f37052f..0000000000 --- a/tests/reference/llvm-expr17-4ac02aa.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "basename": "llvm-expr17-4ac02aa", - "cmd": "lpython --no-color --show-llvm {infile} -o {outfile}", - "infile": "tests/expr17.py", - "infile_hash": "105d03de28e04eac6f02555286cf2b954caa81d7135618017aeefe79", - "outfile": null, - "outfile_hash": null, - "stdout": "llvm-expr17-4ac02aa.stdout", - "stdout_hash": "15764832892f7e0cd2a438b247a148564f5f83b3a00ca929bd9cc625", - "stderr": null, - "stderr_hash": null, - "returncode": 0 -} \ No newline at end of file diff --git a/tests/reference/llvm-expr17-4ac02aa.stdout b/tests/reference/llvm-expr17-4ac02aa.stdout deleted file mode 100644 index 084a225695..0000000000 --- a/tests/reference/llvm-expr17-4ac02aa.stdout +++ /dev/null @@ -1,10 +0,0 @@ -; ModuleID = 'LFortran' -source_filename = "LFortran" - -define i32 @main(i32 %0, i8** %1) { -.entry: - call void @_lpython_set_argv(i32 %0, i8** %1) - ret i32 0 -} - -declare void @_lpython_set_argv(i32, i8**) diff --git a/tests/tests.toml b/tests/tests.toml index a6786f2a22..972c72bf91 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -142,9 +142,6 @@ asr = true [[test]] filename = "expr17.py" -asr = true -ast = true -llvm = true python = true [[test]]