From 8506de27fa216a4fdf247d0ae42191d93d23d8da Mon Sep 17 00:00:00 2001 From: Shaikh Ubaid Date: Fri, 28 Apr 2023 04:43:46 +0530 Subject: [PATCH] TEST: Enable test and update ref tests --- run_tests.py | 10 + .../asr_json-modules_02-70a491a.json | 13 + .../asr_json-modules_02-70a491a.stdout | 1015 +++++++++++++++++ tests/tests.toml | 1 + 4 files changed, 1039 insertions(+) create mode 100644 tests/reference/asr_json-modules_02-70a491a.json create mode 100644 tests/reference/asr_json-modules_02-70a491a.stdout diff --git a/run_tests.py b/run_tests.py index 63310c7510..1d78d8fcb4 100755 --- a/run_tests.py +++ b/run_tests.py @@ -21,6 +21,7 @@ def is_included(backend): ast = is_included("ast") ast_new = is_included("ast_new") asr = is_included("asr") + asr_json = is_included("asr_json") llvm = is_included("llvm") llvm_dbg = is_included("llvm_dbg") cpp = is_included("cpp") @@ -80,6 +81,15 @@ def is_included(backend): update_reference, extra_args) + if asr_json: + run_test( + filename, + "asr_json", + "lpython --show-asr --json {infile} -o {outfile}", + filename, + update_reference, + extra_args) + if pass_ is not None: cmd = "lpython --pass=" + pass_ + \ " --show-asr --indent --no-color {infile} -o {outfile}" diff --git a/tests/reference/asr_json-modules_02-70a491a.json b/tests/reference/asr_json-modules_02-70a491a.json new file mode 100644 index 0000000000..dfc608ea56 --- /dev/null +++ b/tests/reference/asr_json-modules_02-70a491a.json @@ -0,0 +1,13 @@ +{ + "basename": "asr_json-modules_02-70a491a", + "cmd": "lpython --show-asr --json {infile} -o {outfile}", + "infile": "tests/../integration_tests/modules_02.py", + "infile_hash": "dcb00ac27cbbcdec61d81f1df9e852ba81a2197e7804ec89cab76e44", + "outfile": null, + "outfile_hash": null, + "stdout": "asr_json-modules_02-70a491a.stdout", + "stdout_hash": "adc3ed3cc499317e76d8755750cbd9eee8f78810d3b83ecf6cfcef15", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr_json-modules_02-70a491a.stdout b/tests/reference/asr_json-modules_02-70a491a.stdout new file mode 100644 index 0000000000..d127615c82 --- /dev/null +++ b/tests/reference/asr_json-modules_02-70a491a.stdout @@ -0,0 +1,1015 @@ +{ + "node": "TranslationUnit", + "fields": { + "global_scope": { + "node": "SymbolTable1", + "fields": { + "_global_symbols": { + "node": "Module", + "fields": { + "symtab": { + "node": "SymbolTable11", + "fields": { + "_lpython_main_program": { + "node": "Function", + "fields": { + "symtab": { + "node": "SymbolTable10", + "fields": {} + }, + "name": "_lpython_main_program", + "function_signature": { + "node": "FunctionType", + "fields": { + "arg_types": [], + "return_var_type": [], + "abi": "Source", + "deftype": "Implementation", + "bindc_name": [], + "elemental": false, + "pure": false, + "module": false, + "inline": false, + "static": false, + "type_params": [], + "restrictions": [], + "is_restriction": false + }, + "loc": { + "first": 0, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } + }, + "dependencies": [ + "main0" + ], + "args": [], + "body": [ + { + "node": "SubroutineCall", + "fields": { + "name": "main0 (SymbolTable11)", + "original_name": [], + "args": [], + "dt": [] + }, + "loc": { + "first": 119, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 10, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } + } + ], + "return_var": [], + "access": "Public", + "deterministic": false, + "side_effect_free": false, + "c_header": [] + }, + "loc": { + "first": 0, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } + }, + "f": { + "node": "ExternalSymbol", + "fields": { + "parent_symtab": 11, + "name": "f", + "external": "f (SymbolTable3)", + "module_name": "modules_02b", + "scope_names": [], + "original_name": "f", + "access": "Public" + }, + "loc": { + "first": 154, + "last": 186, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 3, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 5, + "last_column": 16 + } + }, + "main0": { + "node": "Function", + "fields": { + "symtab": { + "node": "SymbolTable8", + "fields": { + "x": { + "node": "Variable", + "fields": { + "parent_symtab": 8, + "name": "x", + "dependencies": [], + "intent": "Local", + "symbolic_value": [], + "value": [], + "storage": "Default", + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 71, + "last": 73, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 5, + "first_column": 8, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 5, + "last_column": 10 + } + }, + "abi": "Source", + "access": "Public", + "presence": "Required", + "value_attr": false + }, + "loc": { + "first": 68, + "last": 73, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 5, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 5, + "last_column": 10 + } + } + } + }, + "name": "main0", + "function_signature": { + "node": "FunctionType", + "fields": { + "arg_types": [], + "return_var_type": [], + "abi": "Source", + "deftype": "Implementation", + "bindc_name": [], + "elemental": false, + "pure": false, + "module": false, + "inline": false, + "static": false, + "type_params": [], + "restrictions": [], + "is_restriction": false + }, + "loc": { + "first": 51, + "last": 116, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 4, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 8, + "last_column": 7 + } + }, + "dependencies": [ + "f" + ], + "args": [], + "body": [ + { + "node": "Assignment", + "fields": { + "target": { + "node": "Var", + "fields": { + "v": "x (SymbolTable8)" + }, + "loc": { + "first": 79, + "last": 79, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 5 + } + }, + "value": { + "node": "IntegerBinOp", + "fields": { + "left": { + "node": "IntegerBinOp", + "fields": { + "left": { + "node": "IntegerConstant", + "fields": { + "n": 2, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 84, + "last": 84, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 10 + } + } + }, + "loc": { + "first": 84, + "last": 84, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 10 + } + }, + "op": "Add", + "right": { + "node": "IntegerConstant", + "fields": { + "n": 3, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 86, + "last": 86, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 12, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 12 + } + } + }, + "loc": { + "first": 86, + "last": 86, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 12, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 12 + } + }, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 84, + "last": 84, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 10 + } + }, + "value": { + "node": "IntegerConstant", + "fields": { + "n": 5, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 84, + "last": 84, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 10 + } + } + }, + "loc": { + "first": 84, + "last": 86, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 12 + } + } + }, + "loc": { + "first": 84, + "last": 86, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 12 + } + }, + "op": "Mul", + "right": { + "node": "IntegerConstant", + "fields": { + "n": 5, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 89, + "last": 89, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 15, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 15 + } + } + }, + "loc": { + "first": 89, + "last": 89, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 15, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 15 + } + }, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 84, + "last": 84, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 10 + } + }, + "value": { + "node": "IntegerConstant", + "fields": { + "n": 25, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 84, + "last": 84, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 10, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 10 + } + } + }, + "loc": { + "first": 83, + "last": 89, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 9, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 15 + } + } + }, + "loc": { + "first": 83, + "last": 89, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 9, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 15 + } + }, + "overloaded": [] + }, + "loc": { + "first": 79, + "last": 89, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 6, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 6, + "last_column": 15 + } + }, + { + "node": "Assert", + "fields": { + "test": { + "node": "IntegerCompare", + "fields": { + "left": { + "node": "Var", + "fields": { + "v": "x (SymbolTable8)" + }, + "loc": { + "first": 102, + "last": 102, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 7, + "first_column": 12, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 7, + "last_column": 12 + } + }, + "op": "Eq", + "right": { + "node": "IntegerConstant", + "fields": { + "n": 25, + "type": { + "node": "Integer", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 107, + "last": 108, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 7, + "first_column": 17, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 7, + "last_column": 18 + } + } + }, + "loc": { + "first": 107, + "last": 108, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 7, + "first_column": 17, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 7, + "last_column": 18 + } + }, + "type": { + "node": "Logical", + "fields": { + "kind": 4, + "dims": [] + }, + "loc": { + "first": 102, + "last": 108, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 7, + "first_column": 12, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 7, + "last_column": 18 + } + }, + "value": [] + }, + "loc": { + "first": 102, + "last": 108, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 7, + "first_column": 12, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 7, + "last_column": 18 + } + }, + "msg": [] + }, + "loc": { + "first": 95, + "last": 108, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 7, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 7, + "last_column": 18 + } + }, + { + "node": "SubroutineCall", + "fields": { + "name": "f (SymbolTable11)", + "original_name": [], + "args": [], + "dt": [] + }, + "loc": { + "first": 114, + "last": 116, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 8, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 8, + "last_column": 7 + } + } + ], + "return_var": [], + "access": "Public", + "deterministic": false, + "side_effect_free": false, + "c_header": [] + }, + "loc": { + "first": 51, + "last": 116, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 4, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 8, + "last_column": 7 + } + } + } + }, + "name": "_global_symbols", + "dependencies": [ + "modules_02b" + ], + "loaded_from_mod": false, + "intrinsic": false + }, + "loc": { + "first": 0, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } + }, + "main_program": { + "node": "Program", + "fields": { + "symtab": { + "node": "SymbolTable9", + "fields": { + "_lpython_main_program": { + "node": "ExternalSymbol", + "fields": { + "parent_symtab": 9, + "name": "_lpython_main_program", + "external": "_lpython_main_program (SymbolTable11)", + "module_name": "_global_symbols", + "scope_names": [], + "original_name": "_lpython_main_program", + "access": "Public" + }, + "loc": { + "first": 0, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } + } + } + }, + "name": "main_program", + "dependencies": [ + "_global_symbols" + ], + "body": [ + { + "node": "SubroutineCall", + "fields": { + "name": "_lpython_main_program (SymbolTable9)", + "original_name": [], + "args": [], + "dt": [] + }, + "loc": { + "first": 0, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } + } + ] + }, + "loc": { + "first": 0, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } + }, + "modules_02b": { + "node": "Module", + "fields": { + "symtab": { + "node": "SymbolTable3", + "fields": { + "f": { + "node": "Function", + "fields": { + "symtab": { + "node": "SymbolTable7", + "fields": {} + }, + "name": "f", + "function_signature": { + "node": "FunctionType", + "fields": { + "arg_types": [], + "return_var_type": [], + "abi": "Source", + "deftype": "Implementation", + "bindc_name": [], + "elemental": false, + "pure": false, + "module": false, + "inline": false, + "static": false, + "type_params": [], + "restrictions": [], + "is_restriction": false + }, + "loc": { + "first": 154, + "last": 186, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 3, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 5, + "last_column": 16 + } + }, + "dependencies": [ + "g" + ], + "args": [], + "body": [ + { + "node": "SubroutineCall", + "fields": { + "name": "g (SymbolTable3)", + "original_name": [], + "args": [], + "dt": [] + }, + "loc": { + "first": 167, + "last": 169, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 4, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 4, + "last_column": 7 + } + }, + { + "node": "Print", + "fields": { + "fmt": [], + "values": [ + { + "node": "StringConstant", + "fields": { + "s": "f()", + "type": { + "node": "Character", + "fields": { + "kind": 1, + "len": 3, + "len_expr": [], + "dims": [] + }, + "loc": { + "first": 181, + "last": 185, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 5, + "first_column": 11, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 5, + "last_column": 15 + } + } + }, + "loc": { + "first": 181, + "last": 185, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 5, + "first_column": 11, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 5, + "last_column": 15 + } + } + ], + "separator": [], + "end": [] + }, + "loc": { + "first": 175, + "last": 186, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 5, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 5, + "last_column": 16 + } + } + ], + "return_var": [], + "access": "Public", + "deterministic": false, + "side_effect_free": false, + "c_header": [] + }, + "loc": { + "first": 154, + "last": 186, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 3, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 5, + "last_column": 16 + } + }, + "g": { + "node": "ExternalSymbol", + "fields": { + "parent_symtab": 3, + "name": "g", + "external": "g (SymbolTable5)", + "module_name": "modules_02c", + "scope_names": [], + "original_name": "g", + "access": "Public" + }, + "loc": { + "first": 188, + "last": 212, + "first_filename": "tests/../integration_tests/modules_02c.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02c.py", + "last_line": 2, + "last_column": 16 + } + } + } + }, + "name": "modules_02b", + "dependencies": [ + "modules_02c" + ], + "loaded_from_mod": false, + "intrinsic": false + }, + "loc": { + "first": 127, + "last": 186, + "first_filename": "tests/../integration_tests/modules_02b.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02b.py", + "last_line": 5, + "last_column": 16 + } + }, + "modules_02c": { + "node": "Module", + "fields": { + "symtab": { + "node": "SymbolTable5", + "fields": { + "g": { + "node": "Function", + "fields": { + "symtab": { + "node": "SymbolTable6", + "fields": {} + }, + "name": "g", + "function_signature": { + "node": "FunctionType", + "fields": { + "arg_types": [], + "return_var_type": [], + "abi": "Source", + "deftype": "Implementation", + "bindc_name": [], + "elemental": false, + "pure": false, + "module": false, + "inline": false, + "static": false, + "type_params": [], + "restrictions": [], + "is_restriction": false + }, + "loc": { + "first": 188, + "last": 212, + "first_filename": "tests/../integration_tests/modules_02c.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02c.py", + "last_line": 2, + "last_column": 16 + } + }, + "dependencies": [], + "args": [], + "body": [ + { + "node": "Print", + "fields": { + "fmt": [], + "values": [ + { + "node": "StringConstant", + "fields": { + "s": "g()", + "type": { + "node": "Character", + "fields": { + "kind": 1, + "len": 3, + "len_expr": [], + "dims": [] + }, + "loc": { + "first": 207, + "last": 211, + "first_filename": "tests/../integration_tests/modules_02c.py", + "first_line": 2, + "first_column": 11, + "last_filename": "tests/../integration_tests/modules_02c.py", + "last_line": 2, + "last_column": 15 + } + } + }, + "loc": { + "first": 207, + "last": 211, + "first_filename": "tests/../integration_tests/modules_02c.py", + "first_line": 2, + "first_column": 11, + "last_filename": "tests/../integration_tests/modules_02c.py", + "last_line": 2, + "last_column": 15 + } + } + ], + "separator": [], + "end": [] + }, + "loc": { + "first": 201, + "last": 212, + "first_filename": "tests/../integration_tests/modules_02c.py", + "first_line": 2, + "first_column": 5, + "last_filename": "tests/../integration_tests/modules_02c.py", + "last_line": 2, + "last_column": 16 + } + } + ], + "return_var": [], + "access": "Public", + "deterministic": false, + "side_effect_free": false, + "c_header": [] + }, + "loc": { + "first": 188, + "last": 212, + "first_filename": "tests/../integration_tests/modules_02c.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02c.py", + "last_line": 2, + "last_column": 16 + } + } + } + }, + "name": "modules_02c", + "dependencies": [], + "loaded_from_mod": false, + "intrinsic": false + }, + "loc": { + "first": 188, + "last": 212, + "first_filename": "tests/../integration_tests/modules_02c.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02c.py", + "last_line": 2, + "last_column": 16 + } + } + } + }, + "items": [] + }, + "loc": { + "first": 0, + "last": 125, + "first_filename": "tests/../integration_tests/modules_02.py", + "first_line": 1, + "first_column": 1, + "last_filename": "tests/../integration_tests/modules_02.py", + "last_line": 10, + "last_column": 7 + } +} diff --git a/tests/tests.toml b/tests/tests.toml index bea12f2519..d8c2232c27 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -196,6 +196,7 @@ asr = true [[test]] filename = "../integration_tests/modules_02.py" asr = true +asr_json = true [[test]] filename = "../integration_tests/test_import_02.py"