diff --git a/integration_tests/run_tests.py b/integration_tests/run_tests.py index 0b7868e462..aa70e4bd27 100755 --- a/integration_tests/run_tests.py +++ b/integration_tests/run_tests.py @@ -24,6 +24,7 @@ "test_builtin_len.py", "test_builtin_float.py", "test_builtin_str_02.py", + "test_builtin_round.py", "test_math1.py", "test_math_02.py", "test_c_interop_01.py", diff --git a/integration_tests/test_builtin_round.py b/integration_tests/test_builtin_round.py new file mode 100644 index 0000000000..a6458ed15b --- /dev/null +++ b/integration_tests/test_builtin_round.py @@ -0,0 +1,26 @@ +from ltypes import f64 + +def test_round(): + f: f64 + f = 5.678 + print(round(f)) + f = -183745.23 + print(round(f)) + f = 44.34 + print(round(f)) + f = 0.5 + print(round(f)) + f = -50.5 + print(round(f)) + f = 1.5 + print(round(f)) + assert round(13.001) == 13 + assert round(-40.49999) == -40 + assert round(0.5) == 0 + assert round(-0.5) == 0 + assert round(1.5) == 2 + assert round(50.5) == 50 + assert round(56.78) == 57 + + +test_round() diff --git a/src/lpython/semantics/python_comptime_eval.h b/src/lpython/semantics/python_comptime_eval.h index 5acb80ff90..2f204851ad 100644 --- a/src/lpython/semantics/python_comptime_eval.h +++ b/src/lpython/semantics/python_comptime_eval.h @@ -40,6 +40,7 @@ struct PythonIntrinsicProcedures { {"pow", {m_builtin, &eval_pow}}, {"int", {m_builtin, &eval_int}}, {"float", {m_builtin, &eval_float}}, + {"round", {m_builtin, &eval_round}}, {"bin", {m_builtin, &eval_bin}}, {"hex", {m_builtin, &eval_hex}}, {"oct", {m_builtin, &eval_oct}}, @@ -409,6 +410,26 @@ struct PythonIntrinsicProcedures { } } + static ASR::expr_t *eval_round(Allocator &al, const Location &loc, Vec &args) { + LFORTRAN_ASSERT(ASRUtils::all_args_evaluated(args)); + ASR::ttype_t *type = ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4, nullptr, 0)); + if (args.size() != 1) { + throw SemanticError("round() missing required argument 'number' (pos 1)", loc); + } + ASR::expr_t* expr = args[0]; + ASR::ttype_t* t = ASRUtils::expr_type(expr); + if (ASRUtils::is_real(*t)) { + double rv = ASR::down_cast(expr)->m_r; + int64_t rounded = round(rv); + if (fabs(rv-rounded) == 0.5) + rounded = 2.0*round(rv/2.0); + return ASR::down_cast(make_ConstantInteger_t(al, loc, rounded, type)); + } else { + throw SemanticError("round() argument must be float for now, not '" + + ASRUtils::type_to_str(t) + "'", loc); + } + } + }; // ComptimeEval } // namespace LFortran diff --git a/src/runtime/lpython_builtin.py b/src/runtime/lpython_builtin.py index 365ba31534..9712abe097 100644 --- a/src/runtime/lpython_builtin.py +++ b/src/runtime/lpython_builtin.py @@ -173,3 +173,13 @@ def oct(n: i32) -> str: n = n//8 res += _values[remainder] return prep + res[::-1] + + +def round(value: f64) -> i32: + """ + Rounds a floating point number to the nearest integer. + """ + if abs(value - int(value)) <= 0.5: + return int(value) + else: + return int(value) + 1 diff --git a/tests/reference/asr-constants1-5828e8a.json b/tests/reference/asr-constants1-5828e8a.json index f6047d74b4..4b10f81acf 100644 --- a/tests/reference/asr-constants1-5828e8a.json +++ b/tests/reference/asr-constants1-5828e8a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-constants1-5828e8a.stdout", - "stdout_hash": "afdf64c50b62ecb3a51f71b729f21920178f29682559773af511c470", + "stdout_hash": "e868a321ec5699dcdd832b96904338cc235ecc63f02b7d893fb3714d", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-constants1-5828e8a.stdout b/tests/reference/asr-constants1-5828e8a.stdout index bc4b39ba63..7c539474fb 100644 --- a/tests/reference/asr-constants1-5828e8a.stdout +++ b/tests/reference/asr-constants1-5828e8a.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 26 {}) main_program [] []), test_abs: (Subroutine (SymbolTable 4 {abs: (ExternalSymbol 4 abs 13 abs lpython_builtin [] abs Private), b: (Variable 4 b Local () () Default (Real 4 []) Source Public Required .false.)}) test_abs [] [(= (Var 4 b) (ImplicitCast (FunctionCall 4 abs () [(ConstantReal 3.450000 (Real 8 []))] [] (Real 8 []) (ConstantReal 3.450000 (Real 8 [])) ()) RealToReal (Real 4 []) ()) ()) (= (Var 4 b) (ImplicitCast (FunctionCall 4 abs () [(UnaryOp USub (ConstantReal 5346.340000 (Real 8 [])) (Real 8 []) (ConstantReal -5346.340000 (Real 8 [])))] [] (Real 8 []) (ConstantReal 5346.340000 (Real 8 [])) ()) RealToReal (Real 4 []) ()) ())] Source Public Implementation () .false. .false.), test_bool: (Subroutine (SymbolTable 6 {a: (Variable 6 a Local () () Default (Logical 1 []) Source Public Required .false.), bool: (ExternalSymbol 6 bool 13 bool lpython_builtin [] bool Private)}) test_bool [] [(= (Var 6 a) (FunctionCall 6 bool () [(ConstantInteger 0 (Integer 4 []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantString "" (Character 1 0 () []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantComplex 0.000000 0.000000 (Complex 8 []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) ()) (Assert (Compare (Var 6 a) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantString "t" (Character 1 1 () []))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantReal 2.300000 (Real 8 []))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) ()) (Assert (Compare (Var 6 a) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), test_boz: (Subroutine (SymbolTable 2 {b: (Variable 2 b Local () () Default (Character 1 -2 () []) Source Public Required .false.), bin: (ExternalSymbol 2 bin 13 bin lpython_builtin [] bin Private), hex: (ExternalSymbol 2 hex 13 hex lpython_builtin [] hex Private), oct: (ExternalSymbol 2 oct 13 oct lpython_builtin [] oct Private)}) test_boz [] [(= (Var 2 b) (FunctionCall 2 bin () [(ConstantInteger 5 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0b101" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 bin () [(ConstantInteger 64 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0b1000000" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 bin () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0b1000010110" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 oct () [(ConstantInteger 8 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0o10" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 oct () [(ConstantInteger 56 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0o70" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 oct () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0o1026" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 hex () [(ConstantInteger 42 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0x2a" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 hex () [(ConstantInteger 12648430 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0xc0ffee" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 hex () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0x216" (Character 1 1 () [])) ()) ())] Source Public Implementation () .false. .false.), test_callable: (Subroutine (SymbolTable 8 {a: (Variable 8 a Local () () Default (Logical 1 []) Source Public Required .false.), b: (Variable 8 b Local () () Default (Integer 4 []) Source Public Required .false.)}) test_callable [] [(= (Var 8 b) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 8 a) (ConstantLogical .true. (Logical 1 [])) ()) (Assert (Compare (Var 8 a) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 8 a) (ConstantLogical .false. (Logical 1 [])) ()) (Assert (Compare (Var 8 a) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 8 a) (ConstantLogical .false. (Logical 1 [])) ()) (Assert (Compare (Var 8 a) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), test_divmod: (Subroutine (SymbolTable 11 {a: (Variable 11 a Local () () Default (Integer 4 []) Source Public Required .false.)}) test_divmod [] [(= (Var 11 a) (ConstantTuple [(ConstantInteger 3 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger -3 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger 0 (Integer 4 [])) (ConstantInteger 4 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger 0 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ())] Source Public Implementation () .false. .false.), test_float: (Subroutine (SymbolTable 10 {a: (Variable 10 a Local () () Default (Real 8 []) Source Public Required .false.), float: (ExternalSymbol 10 float 13 float lpython_builtin [] float Private)}) test_float [] [(= (Var 10 a) (FunctionCall 10 float () [] [] (Real 8 []) (ConstantReal 0.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantReal 4.560000 (Real 8 []))] [] (Real 8 []) (ConstantReal 4.560000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantInteger 5 (Integer 4 []))] [] (Real 8 []) (ConstantReal 5.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] [] (Real 8 []) (ConstantReal -1.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantLogical .true. (Logical 1 []))] [] (Real 8 []) (ConstantReal 1.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantLogical .false. (Logical 1 []))] [] (Real 8 []) (ConstantReal 0.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantString "5346" (Character 1 4 () []))] [] (Real 8 []) (ConstantReal 5346.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantString "423.534" (Character 1 7 () []))] [] (Real 8 []) (ConstantReal 423.533997 (Real 8 [])) ()) ())] Source Public Implementation () .false. .false.), test_int: (Subroutine (SymbolTable 9 {a: (Variable 9 a Local () () Default (Integer 8 []) Source Public Required .false.), int: (ExternalSymbol 9 int 13 int lpython_builtin [] int Private)}) test_int [] [(= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantReal 4.560000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantInteger 5 (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 5 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(UnaryOp USub (ConstantReal 5.000010 (Real 8 [])) (Real 8 []) (ConstantReal -5.000010 (Real 8 [])))] [] (Integer 4 []) (ConstantInteger -5 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantLogical .true. (Logical 1 []))] [] (Integer 4 []) (ConstantInteger 1 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantLogical .false. (Logical 1 []))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantString "5346" (Character 1 4 () []))] [] (Integer 4 []) (ConstantInteger 5346 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ())] Source Public Implementation () .false. .false.), test_len: (Subroutine (SymbolTable 5 {a: (Variable 5 a Local () () Default (Integer 4 []) Source Public Required .false.), len: (ExternalSymbol 5 len 13 len lpython_builtin [] len Private)}) test_len [] [(= (Var 5 a) (FunctionCall 5 len () [(ConstantString "" (Character 1 0 () []))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantString "test" (Character 1 4 () []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantString "this is a test" (Character 1 14 () []))] [] (Integer 4 []) (ConstantInteger 14 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantTuple [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 []) (Integer 4 [])]))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantTuple [(ConstantTuple [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantReal 3.400000 (Real 8 []))] (Tuple [(Character 1 1 () []) (Character 1 1 () []) (Real 8 [])])) (ConstantTuple [(ConstantString "c" (Character 1 1 () [])) (ConstantInteger 3 (Integer 4 [])) (ConstantReal 5.600000 (Real 8 []))] (Tuple [(Character 1 1 () []) (Integer 4 []) (Real 8 [])]))] (Tuple [(Tuple [(Character 1 1 () []) (Character 1 1 () []) (Real 8 [])]) (Tuple [(Character 1 1 () []) (Integer 4 []) (Real 8 [])])]))] [] (Integer 4 []) (ConstantInteger 2 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantArray [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantArray [(ConstantArray [(UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 []))) (UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 []))) (UnaryOp USub (ConstantInteger 6 (Integer 4 [])) (Integer 4 []) (ConstantInteger -6 (Integer 4 [])))] (Integer 4 [])) (ConstantArray [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 []))) (UnaryOp USub (ConstantInteger 2 (Integer 4 [])) (Integer 4 []) (ConstantInteger -2 (Integer 4 []))) (UnaryOp USub (ConstantInteger 3 (Integer 4 [])) (Integer 4 []) (ConstantInteger -3 (Integer 4 [])))] (Integer 4 []))] (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 2 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantSet [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (Set (Integer 4 [])))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantDictionary [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantString "c" (Character 1 1 () []))] (Dict (Integer 4 []) (Character 1 1 () [])))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_ord_chr: (Subroutine (SymbolTable 3 {a: (Variable 3 a Local () () Default (Integer 4 []) Source Public Required .false.), chr: (ExternalSymbol 3 chr 13 chr lpython_builtin [] chr Private), ord: (ExternalSymbol 3 ord 13 ord lpython_builtin [] ord Private), s: (Variable 3 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_ord_chr [] [(= (Var 3 a) (FunctionCall 3 ord () [(ConstantString "5" (Character 1 1 () []))] [] (Integer 4 []) (ConstantInteger 53 (Integer 4 [])) ()) ()) (= (Var 3 s) (FunctionCall 3 chr () [(ConstantInteger 43 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "+" (Character 1 1 () [])) ()) ())] Source Public Implementation () .false. .false.), test_str: (Subroutine (SymbolTable 7 {s: (Variable 7 s Local () () Default (Character 1 -2 () []) Source Public Required .false.), str: (ExternalSymbol 7 str 13 str lpython_builtin [] str Private)}) test_str [] [(= (Var 7 s) (FunctionCall 7 str () [] [] (Character 1 -2 () []) (ConstantString "" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantInteger 5 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "5" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-4" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantReal 5.600000 (Real 8 []))] [] (Character 1 -2 () []) (ConstantString "5.600000" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantLogical .true. (Logical 1 []))] [] (Character 1 -2 () []) (ConstantString "True" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantLogical .false. (Logical 1 []))] [] (Character 1 -2 () []) (ConstantString "False" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantString "5346" (Character 1 4 () []))] [] (Character 1 -2 () []) (ConstantString "5346" (Character 1 1 () [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 27 {}) main_program [] []), test_abs: (Subroutine (SymbolTable 4 {abs: (ExternalSymbol 4 abs 13 abs lpython_builtin [] abs Private), b: (Variable 4 b Local () () Default (Real 4 []) Source Public Required .false.)}) test_abs [] [(= (Var 4 b) (ImplicitCast (FunctionCall 4 abs () [(ConstantReal 3.450000 (Real 8 []))] [] (Real 8 []) (ConstantReal 3.450000 (Real 8 [])) ()) RealToReal (Real 4 []) ()) ()) (= (Var 4 b) (ImplicitCast (FunctionCall 4 abs () [(UnaryOp USub (ConstantReal 5346.340000 (Real 8 [])) (Real 8 []) (ConstantReal -5346.340000 (Real 8 [])))] [] (Real 8 []) (ConstantReal 5346.340000 (Real 8 [])) ()) RealToReal (Real 4 []) ()) ())] Source Public Implementation () .false. .false.), test_bool: (Subroutine (SymbolTable 6 {a: (Variable 6 a Local () () Default (Logical 1 []) Source Public Required .false.), bool: (ExternalSymbol 6 bool 13 bool lpython_builtin [] bool Private)}) test_bool [] [(= (Var 6 a) (FunctionCall 6 bool () [(ConstantInteger 0 (Integer 4 []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantString "" (Character 1 0 () []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantComplex 0.000000 0.000000 (Complex 8 []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) ()) (Assert (Compare (Var 6 a) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantString "t" (Character 1 1 () []))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) ()) (= (Var 6 a) (FunctionCall 6 bool () [(ConstantReal 2.300000 (Real 8 []))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) ()) (Assert (Compare (Var 6 a) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), test_boz: (Subroutine (SymbolTable 2 {b: (Variable 2 b Local () () Default (Character 1 -2 () []) Source Public Required .false.), bin: (ExternalSymbol 2 bin 13 bin lpython_builtin [] bin Private), hex: (ExternalSymbol 2 hex 13 hex lpython_builtin [] hex Private), oct: (ExternalSymbol 2 oct 13 oct lpython_builtin [] oct Private)}) test_boz [] [(= (Var 2 b) (FunctionCall 2 bin () [(ConstantInteger 5 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0b101" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 bin () [(ConstantInteger 64 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0b1000000" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 bin () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0b1000010110" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 oct () [(ConstantInteger 8 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0o10" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 oct () [(ConstantInteger 56 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0o70" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 oct () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0o1026" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 hex () [(ConstantInteger 42 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0x2a" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 hex () [(ConstantInteger 12648430 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0xc0ffee" (Character 1 1 () [])) ()) ()) (= (Var 2 b) (FunctionCall 2 hex () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0x216" (Character 1 1 () [])) ()) ())] Source Public Implementation () .false. .false.), test_callable: (Subroutine (SymbolTable 8 {a: (Variable 8 a Local () () Default (Logical 1 []) Source Public Required .false.), b: (Variable 8 b Local () () Default (Integer 4 []) Source Public Required .false.)}) test_callable [] [(= (Var 8 b) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 8 a) (ConstantLogical .true. (Logical 1 [])) ()) (Assert (Compare (Var 8 a) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 8 a) (ConstantLogical .false. (Logical 1 [])) ()) (Assert (Compare (Var 8 a) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 8 a) (ConstantLogical .false. (Logical 1 [])) ()) (Assert (Compare (Var 8 a) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.), test_divmod: (Subroutine (SymbolTable 11 {a: (Variable 11 a Local () () Default (Integer 4 []) Source Public Required .false.)}) test_divmod [] [(= (Var 11 a) (ConstantTuple [(ConstantInteger 3 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger -3 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger 0 (Integer 4 [])) (ConstantInteger 4 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ()) (= (Var 11 a) (ConstantTuple [(ConstantInteger 0 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 [])])) ())] Source Public Implementation () .false. .false.), test_float: (Subroutine (SymbolTable 10 {a: (Variable 10 a Local () () Default (Real 8 []) Source Public Required .false.), float: (ExternalSymbol 10 float 13 float lpython_builtin [] float Private)}) test_float [] [(= (Var 10 a) (FunctionCall 10 float () [] [] (Real 8 []) (ConstantReal 0.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantReal 4.560000 (Real 8 []))] [] (Real 8 []) (ConstantReal 4.560000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantInteger 5 (Integer 4 []))] [] (Real 8 []) (ConstantReal 5.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] [] (Real 8 []) (ConstantReal -1.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantLogical .true. (Logical 1 []))] [] (Real 8 []) (ConstantReal 1.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantLogical .false. (Logical 1 []))] [] (Real 8 []) (ConstantReal 0.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantString "5346" (Character 1 4 () []))] [] (Real 8 []) (ConstantReal 5346.000000 (Real 8 [])) ()) ()) (= (Var 10 a) (FunctionCall 10 float () [(ConstantString "423.534" (Character 1 7 () []))] [] (Real 8 []) (ConstantReal 423.533997 (Real 8 [])) ()) ())] Source Public Implementation () .false. .false.), test_int: (Subroutine (SymbolTable 9 {a: (Variable 9 a Local () () Default (Integer 8 []) Source Public Required .false.), int: (ExternalSymbol 9 int 13 int lpython_builtin [] int Private)}) test_int [] [(= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantReal 4.560000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantInteger 5 (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 5 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(UnaryOp USub (ConstantReal 5.000010 (Real 8 [])) (Real 8 []) (ConstantReal -5.000010 (Real 8 [])))] [] (Integer 4 []) (ConstantInteger -5 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantLogical .true. (Logical 1 []))] [] (Integer 4 []) (ConstantInteger 1 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantLogical .false. (Logical 1 []))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ()) (= (Var 9 a) (ImplicitCast (FunctionCall 9 int () [(ConstantString "5346" (Character 1 4 () []))] [] (Integer 4 []) (ConstantInteger 5346 (Integer 4 [])) ()) IntegerToInteger (Integer 8 []) ()) ())] Source Public Implementation () .false. .false.), test_len: (Subroutine (SymbolTable 5 {a: (Variable 5 a Local () () Default (Integer 4 []) Source Public Required .false.), len: (ExternalSymbol 5 len 13 len lpython_builtin [] len Private)}) test_len [] [(= (Var 5 a) (FunctionCall 5 len () [(ConstantString "" (Character 1 0 () []))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantString "test" (Character 1 4 () []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantString "this is a test" (Character 1 14 () []))] [] (Integer 4 []) (ConstantInteger 14 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantTuple [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (Tuple [(Integer 4 []) (Integer 4 []) (Integer 4 [])]))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantTuple [(ConstantTuple [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantReal 3.400000 (Real 8 []))] (Tuple [(Character 1 1 () []) (Character 1 1 () []) (Real 8 [])])) (ConstantTuple [(ConstantString "c" (Character 1 1 () [])) (ConstantInteger 3 (Integer 4 [])) (ConstantReal 5.600000 (Real 8 []))] (Tuple [(Character 1 1 () []) (Integer 4 []) (Real 8 [])]))] (Tuple [(Tuple [(Character 1 1 () []) (Character 1 1 () []) (Real 8 [])]) (Tuple [(Character 1 1 () []) (Integer 4 []) (Real 8 [])])]))] [] (Integer 4 []) (ConstantInteger 2 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantArray [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantArray [(ConstantArray [(UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 []))) (UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 []))) (UnaryOp USub (ConstantInteger 6 (Integer 4 [])) (Integer 4 []) (ConstantInteger -6 (Integer 4 [])))] (Integer 4 [])) (ConstantArray [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 []))) (UnaryOp USub (ConstantInteger 2 (Integer 4 [])) (Integer 4 []) (ConstantInteger -2 (Integer 4 []))) (UnaryOp USub (ConstantInteger 3 (Integer 4 [])) (Integer 4 []) (ConstantInteger -3 (Integer 4 [])))] (Integer 4 []))] (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 2 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantSet [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (Set (Integer 4 [])))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ()) (= (Var 5 a) (FunctionCall 5 len () [(ConstantDictionary [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantString "c" (Character 1 1 () []))] (Dict (Integer 4 []) (Character 1 1 () [])))] [] (Integer 4 []) (ConstantInteger 3 (Integer 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_ord_chr: (Subroutine (SymbolTable 3 {a: (Variable 3 a Local () () Default (Integer 4 []) Source Public Required .false.), chr: (ExternalSymbol 3 chr 13 chr lpython_builtin [] chr Private), ord: (ExternalSymbol 3 ord 13 ord lpython_builtin [] ord Private), s: (Variable 3 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_ord_chr [] [(= (Var 3 a) (FunctionCall 3 ord () [(ConstantString "5" (Character 1 1 () []))] [] (Integer 4 []) (ConstantInteger 53 (Integer 4 [])) ()) ()) (= (Var 3 s) (FunctionCall 3 chr () [(ConstantInteger 43 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "+" (Character 1 1 () [])) ()) ())] Source Public Implementation () .false. .false.), test_str: (Subroutine (SymbolTable 7 {s: (Variable 7 s Local () () Default (Character 1 -2 () []) Source Public Required .false.), str: (ExternalSymbol 7 str 13 str lpython_builtin [] str Private)}) test_str [] [(= (Var 7 s) (FunctionCall 7 str () [] [] (Character 1 -2 () []) (ConstantString "" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantInteger 5 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "5" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-4" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantReal 5.600000 (Real 8 []))] [] (Character 1 -2 () []) (ConstantString "5.600000" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantLogical .true. (Logical 1 []))] [] (Character 1 -2 () []) (ConstantString "True" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantLogical .false. (Logical 1 []))] [] (Character 1 -2 () []) (ConstantString "False" (Character 1 1 () [])) ()) ()) (= (Var 7 s) (FunctionCall 7 str () [(ConstantString "5346" (Character 1 4 () []))] [] (Character 1 -2 () []) (ConstantString "5346" (Character 1 1 () [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr1-8df2d66.json b/tests/reference/asr-expr1-8df2d66.json index 2c6b956165..edb1183666 100644 --- a/tests/reference/asr-expr1-8df2d66.json +++ b/tests/reference/asr-expr1-8df2d66.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr1-8df2d66.stdout", - "stdout_hash": "67a3b23f5ed48dc24c0c4561ef8326d5bc37e7f1f24443fe88528d1d", + "stdout_hash": "e8673f5c34df0acf8f7a729a6d4ddc0bde7988abe071adfc897e45e1", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr1-8df2d66.stdout b/tests/reference/asr-expr1-8df2d66.stdout index c6f0ee8b15..81334ad023 100644 --- a/tests/reference/asr-expr1-8df2d66.stdout +++ b/tests/reference/asr-expr1-8df2d66.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] []), test_namedexpr: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), ord: (ExternalSymbol 2 ord 4 ord lpython_builtin [] ord Private), x: (Variable 2 x Local () () Default (Integer 4 []) Source Public Required .false.), y: (Variable 2 y Local () () Default (Integer 4 []) Source Public Required .false.)}) test_namedexpr [] [(= (Var 2 x) (NamedExpr (Var 2 y) (ConstantInteger 0 (Integer 4 [])) (Integer 4 [])) ()) (If (NamedExpr (Var 2 a) (FunctionCall 2 ord () [(ConstantString "3" (Character 1 1 () []))] [] (Integer 4 []) (ConstantInteger 51 (Integer 4 [])) ()) (Integer 4 [])) [(= (Var 2 x) (ConstantInteger 1 (Integer 4 [])) ())] []) (WhileLoop (NamedExpr (Var 2 a) (ConstantInteger 1 (Integer 4 [])) (Integer 4 [])) [(= (Var 2 y) (ConstantInteger 1 (Integer 4 [])) ())])] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] []), test_namedexpr: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), ord: (ExternalSymbol 2 ord 4 ord lpython_builtin [] ord Private), x: (Variable 2 x Local () () Default (Integer 4 []) Source Public Required .false.), y: (Variable 2 y Local () () Default (Integer 4 []) Source Public Required .false.)}) test_namedexpr [] [(= (Var 2 x) (NamedExpr (Var 2 y) (ConstantInteger 0 (Integer 4 [])) (Integer 4 [])) ()) (If (NamedExpr (Var 2 a) (FunctionCall 2 ord () [(ConstantString "3" (Character 1 1 () []))] [] (Integer 4 []) (ConstantInteger 51 (Integer 4 [])) ()) (Integer 4 [])) [(= (Var 2 x) (ConstantInteger 1 (Integer 4 [])) ())] []) (WhileLoop (NamedExpr (Var 2 a) (ConstantInteger 1 (Integer 4 [])) (Integer 4 [])) [(= (Var 2 y) (ConstantInteger 1 (Integer 4 [])) ())])] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-expr7-480ba2f.json b/tests/reference/asr-expr7-480ba2f.json index 85e5c7af66..c440c8f440 100644 --- a/tests/reference/asr-expr7-480ba2f.json +++ b/tests/reference/asr-expr7-480ba2f.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr7-480ba2f.stdout", - "stdout_hash": "65f0b67e776362bc0264289bf7244daf9bf9e370e9a967d9550397d6", + "stdout_hash": "73eb6baf6de263f1404dfde6c129dd96208febba5f24afda6f7b6d9f", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr7-480ba2f.stdout b/tests/reference/asr-expr7-480ba2f.stdout index 19098af78a..e757ee83d6 100644 --- a/tests/reference/asr-expr7-480ba2f.stdout +++ b/tests/reference/asr-expr7-480ba2f.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 20 {}) _lfortran_main_program [] [(SubroutineCall 1 main0 () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main0: (Subroutine (SymbolTable 4 {c: (Variable 4 c Local () () Default (Integer 4 []) Source Public Required .false.)}) main0 [] [(SubroutineCall 1 test_pow () [] ()) (= (Var 4 c) (FunctionCall 1 test_pow_1 () [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 []))] [] (Integer 4 []) () ()) ())] Source Public Implementation () .false. .false.), main_program: (Program (SymbolTable 19 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_pow: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 2 pow 6 pow lpython_builtin [] pow Private)}) test_pow [] [(= (Var 2 a) (FunctionCall 2 pow () [(ConstantInteger 2 (Integer 4 [])) (ConstantInteger 2 (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_pow_1: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable ReturnVar () () Default (Integer 4 []) Source Public Required .false.), a: (Variable 3 a In () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 3 b In () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 3 pow 6 pow lpython_builtin [] pow Private), res: (Variable 3 res Local () () Default (Integer 4 []) Source Public Required .false.)}) test_pow_1 [(Var 3 a) (Var 3 b)] [(= (Var 3 res) (FunctionCall 3 pow () [(Var 3 a) (Var 3 b)] [] (Integer 4 []) () ()) ()) (= (Var 3 _lpython_return_variable) (Var 3 res) ()) (Return)] (Var 3 _lpython_return_variable) Source Public Implementation ())}) []) +(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 21 {}) _lfortran_main_program [] [(SubroutineCall 1 main0 () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main0: (Subroutine (SymbolTable 4 {c: (Variable 4 c Local () () Default (Integer 4 []) Source Public Required .false.)}) main0 [] [(SubroutineCall 1 test_pow () [] ()) (= (Var 4 c) (FunctionCall 1 test_pow_1 () [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 []))] [] (Integer 4 []) () ()) ())] Source Public Implementation () .false. .false.), main_program: (Program (SymbolTable 20 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_pow: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 2 pow 6 pow lpython_builtin [] pow Private)}) test_pow [] [(= (Var 2 a) (FunctionCall 2 pow () [(ConstantInteger 2 (Integer 4 [])) (ConstantInteger 2 (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_pow_1: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable ReturnVar () () Default (Integer 4 []) Source Public Required .false.), a: (Variable 3 a In () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 3 b In () () Default (Integer 4 []) Source Public Required .false.), pow: (ExternalSymbol 3 pow 6 pow lpython_builtin [] pow Private), res: (Variable 3 res Local () () Default (Integer 4 []) Source Public Required .false.)}) test_pow_1 [(Var 3 a) (Var 3 b)] [(= (Var 3 res) (FunctionCall 3 pow () [(Var 3 a) (Var 3 b)] [] (Integer 4 []) () ()) ()) (= (Var 3 _lpython_return_variable) (Var 3 res) ()) (Return)] (Var 3 _lpython_return_variable) Source Public Implementation ())}) []) diff --git a/tests/reference/asr-test_builtin-aa64615.json b/tests/reference/asr-test_builtin-aa64615.json index 6e5d551796..6f9b92a3fd 100644 --- a/tests/reference/asr-test_builtin-aa64615.json +++ b/tests/reference/asr-test_builtin-aa64615.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin-aa64615.stdout", - "stdout_hash": "06c7d960ecb9e0562475a7f831b964da93826fc507f6b0872cd3a9f6", + "stdout_hash": "8dad11fdecedb4fdbc9fa06b919ba8964818d07a0de8208628ea4cc3", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin-aa64615.stdout b/tests/reference/asr-test_builtin-aa64615.stdout index 0c84aa15d3..1c25ba9c8d 100644 --- a/tests/reference/asr-test_builtin-aa64615.stdout +++ b/tests/reference/asr-test_builtin-aa64615.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_ord () [] ()) (SubroutineCall 1 test_chr () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_chr: (Subroutine (SymbolTable 3 {chr: (ExternalSymbol 3 chr 5 chr lpython_builtin [] chr Private), i: (Variable 3 i Local () () Default (Integer 4 []) Source Public Required .false.), s: (Variable 3 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_chr [] [(= (Var 3 i) (ConstantInteger 48 (Integer 4 [])) ()) (= (Var 3 s) (FunctionCall 3 chr () [(Var 3 i)] [] (Character 1 -2 () []) () ()) ()) (Assert (Compare (Var 3 s) Eq (ConstantString "0" (Character 1 1 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 3 chr () [(ConstantInteger 48 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0" (Character 1 1 () [])) ()) Eq (ConstantString "0" (Character 1 1 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_ord: (Subroutine (SymbolTable 2 {i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.), ord: (ExternalSymbol 2 ord 5 ord lpython_builtin [] ord Private), s: (Variable 2 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_ord [] [(= (Var 2 s) (ConstantString "1" (Character 1 1 () [])) ()) (= (Var 2 i) (FunctionCall 2 ord () [(Var 2 s)] [] (Integer 4 []) () ()) ()) (Assert (Compare (Var 2 i) Eq (ConstantInteger 49 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 ord () [(ConstantString "1" (Character 1 1 () []))] [] (Integer 4 []) (ConstantInteger 49 (Integer 4 [])) ()) Eq (ConstantInteger 49 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 20 {}) _lfortran_main_program [] [(SubroutineCall 1 test_ord () [] ()) (SubroutineCall 1 test_chr () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 19 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_chr: (Subroutine (SymbolTable 3 {chr: (ExternalSymbol 3 chr 5 chr lpython_builtin [] chr Private), i: (Variable 3 i Local () () Default (Integer 4 []) Source Public Required .false.), s: (Variable 3 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_chr [] [(= (Var 3 i) (ConstantInteger 48 (Integer 4 [])) ()) (= (Var 3 s) (FunctionCall 3 chr () [(Var 3 i)] [] (Character 1 -2 () []) () ()) ()) (Assert (Compare (Var 3 s) Eq (ConstantString "0" (Character 1 1 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 3 chr () [(ConstantInteger 48 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0" (Character 1 1 () [])) ()) Eq (ConstantString "0" (Character 1 1 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.), test_ord: (Subroutine (SymbolTable 2 {i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.), ord: (ExternalSymbol 2 ord 5 ord lpython_builtin [] ord Private), s: (Variable 2 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_ord [] [(= (Var 2 s) (ConstantString "1" (Character 1 1 () [])) ()) (= (Var 2 i) (FunctionCall 2 ord () [(Var 2 s)] [] (Integer 4 []) () ()) ()) (Assert (Compare (Var 2 i) Eq (ConstantInteger 49 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 ord () [(ConstantString "1" (Character 1 1 () []))] [] (Integer 4 []) (ConstantInteger 49 (Integer 4 [])) ()) Eq (ConstantInteger 49 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_abs-c74d2c9.json b/tests/reference/asr-test_builtin_abs-c74d2c9.json index ea2a4fce2a..8dcec465db 100644 --- a/tests/reference/asr-test_builtin_abs-c74d2c9.json +++ b/tests/reference/asr-test_builtin_abs-c74d2c9.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_abs-c74d2c9.stdout", - "stdout_hash": "f3c851e843ddae1aa7179f4a99914aa04f0267c8505c7d3857774bc2", + "stdout_hash": "9fc3463b8b4203e5d72f0130e8a2cf2c30404a5d603441b512197c7d", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_abs-c74d2c9.stdout b/tests/reference/asr-test_builtin_abs-c74d2c9.stdout index f30478bad9..62571ac129 100644 --- a/tests/reference/asr-test_builtin_abs-c74d2c9.stdout +++ b/tests/reference/asr-test_builtin_abs-c74d2c9.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 18 {}) _lfortran_main_program [] [(SubroutineCall 1 test_abs () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_abs: (Subroutine (SymbolTable 2 {abs: (ExternalSymbol 2 abs 4 abs lpython_builtin [] abs Private), x: (Variable 2 x Local () () Default (Real 8 []) Source Public Required .false.)}) test_abs [] [(= (Var 2 x) (ConstantReal 5.500000 (Real 8 [])) ()) (Assert (Compare (FunctionCall 2 abs () [(Var 2 x)] [] (Real 8 []) () ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 x) (UnaryOp USub (ConstantReal 5.500000 (Real 8 [])) (Real 8 []) (ConstantReal -5.500000 (Real 8 []))) ()) (Assert (Compare (FunctionCall 2 abs () [(Var 2 x)] [] (Real 8 []) () ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 abs () [(ConstantReal 5.500000 (Real 8 []))] [] (Real 8 []) (ConstantReal 5.500000 (Real 8 [])) ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 abs () [(UnaryOp USub (ConstantReal 5.500000 (Real 8 [])) (Real 8 []) (ConstantReal -5.500000 (Real 8 [])))] [] (Real 8 []) (ConstantReal 5.500000 (Real 8 [])) ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_abs () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_abs: (Subroutine (SymbolTable 2 {abs: (ExternalSymbol 2 abs 4 abs lpython_builtin [] abs Private), x: (Variable 2 x Local () () Default (Real 8 []) Source Public Required .false.)}) test_abs [] [(= (Var 2 x) (ConstantReal 5.500000 (Real 8 [])) ()) (Assert (Compare (FunctionCall 2 abs () [(Var 2 x)] [] (Real 8 []) () ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 x) (UnaryOp USub (ConstantReal 5.500000 (Real 8 [])) (Real 8 []) (ConstantReal -5.500000 (Real 8 []))) ()) (Assert (Compare (FunctionCall 2 abs () [(Var 2 x)] [] (Real 8 []) () ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 abs () [(ConstantReal 5.500000 (Real 8 []))] [] (Real 8 []) (ConstantReal 5.500000 (Real 8 [])) ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 abs () [(UnaryOp USub (ConstantReal 5.500000 (Real 8 [])) (Real 8 []) (ConstantReal -5.500000 (Real 8 [])))] [] (Real 8 []) (ConstantReal 5.500000 (Real 8 [])) ()) Eq (ConstantReal 5.500000 (Real 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_bin-52ba9fa.json b/tests/reference/asr-test_builtin_bin-52ba9fa.json index 00f5cd9d8e..e0771df2a4 100644 --- a/tests/reference/asr-test_builtin_bin-52ba9fa.json +++ b/tests/reference/asr-test_builtin_bin-52ba9fa.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_bin-52ba9fa.stdout", - "stdout_hash": "18792724f44a999b523dfa1cda6886e0cf00e78c0fc64159a37f175b", + "stdout_hash": "2e72650fac268ba0176e9f858f58702af0d6aeb0ce9bb556cda52dc3", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_bin-52ba9fa.stdout b/tests/reference/asr-test_builtin_bin-52ba9fa.stdout index e375ea7fa6..4e23e40e19 100644 --- a/tests/reference/asr-test_builtin_bin-52ba9fa.stdout +++ b/tests/reference/asr-test_builtin_bin-52ba9fa.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] []), test_bin: (Subroutine (SymbolTable 2 {bin: (ExternalSymbol 2 bin 4 bin lpython_builtin [] bin Private), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) test_bin [] [(= (Var 2 i) (ConstantInteger 5 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bin () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0b101" (Character 1 5 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (ConstantInteger 64 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bin () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0b1000000" (Character 1 9 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 bin () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "-0b1000010110" (Character 1 13 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 bin () [(ConstantInteger 64 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0b1000000" (Character 1 1 () [])) ()) Eq (ConstantString "0b1000000" (Character 1 9 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 bin () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0b1000010110" (Character 1 1 () [])) ()) Eq (ConstantString "-0b1000010110" (Character 1 13 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] []), test_bin: (Subroutine (SymbolTable 2 {bin: (ExternalSymbol 2 bin 4 bin lpython_builtin [] bin Private), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) test_bin [] [(= (Var 2 i) (ConstantInteger 5 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bin () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0b101" (Character 1 5 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (ConstantInteger 64 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bin () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0b1000000" (Character 1 9 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 bin () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "-0b1000010110" (Character 1 13 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 bin () [(ConstantInteger 64 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0b1000000" (Character 1 1 () [])) ()) Eq (ConstantString "0b1000000" (Character 1 9 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 bin () [(UnaryOp USub (ConstantInteger 534 (Integer 4 [])) (Integer 4 []) (ConstantInteger -534 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0b1000010110" (Character 1 1 () [])) ()) Eq (ConstantString "-0b1000010110" (Character 1 13 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_bool-330223a.json b/tests/reference/asr-test_builtin_bool-330223a.json index a23a86420f..76a70258b7 100644 --- a/tests/reference/asr-test_builtin_bool-330223a.json +++ b/tests/reference/asr-test_builtin_bool-330223a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_bool-330223a.stdout", - "stdout_hash": "151a12279912d589ebbb83f4a3995ba5af4b0c71ba1c039b1093fef7", + "stdout_hash": "54873cf84860fba38ab4c2ba91751412b56cc4dae765068ea63bfa72", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_bool-330223a.stdout b/tests/reference/asr-test_builtin_bool-330223a.stdout index 5902cc2828..2648d1a49e 100644 --- a/tests/reference/asr-test_builtin_bool-330223a.stdout +++ b/tests/reference/asr-test_builtin_bool-330223a.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] []), test_bool: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), bool: (ExternalSymbol 2 bool 4 bool lpython_builtin [] bool Private)}) test_bool [] [(= (Var 2 a) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bool () [(Var 2 a)] [] (Logical 1 []) () ()) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 0 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bool () [(Var 2 a)] [] (Logical 1 []) () ()) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 bool () [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 bool () [(ConstantInteger 0 (Integer 4 []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] []), test_bool: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), bool: (ExternalSymbol 2 bool 4 bool lpython_builtin [] bool Private)}) test_bool [] [(= (Var 2 a) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bool () [(Var 2 a)] [] (Logical 1 []) () ()) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 0 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 bool () [(Var 2 a)] [] (Logical 1 []) () ()) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 bool () [(UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 [])))] [] (Logical 1 []) (ConstantLogical .true. (Logical 1 [])) ()) Eq (ConstantLogical .true. (Logical 1 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 bool () [(ConstantInteger 0 (Integer 4 []))] [] (Logical 1 []) (ConstantLogical .false. (Logical 1 [])) ()) Eq (ConstantLogical .false. (Logical 1 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_float-20601dd.json b/tests/reference/asr-test_builtin_float-20601dd.json index a0443bf7eb..9553c1deee 100644 --- a/tests/reference/asr-test_builtin_float-20601dd.json +++ b/tests/reference/asr-test_builtin_float-20601dd.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_float-20601dd.stdout", - "stdout_hash": "f968158f287e9459cb14cfe2396a9739a3a55531ebd18272ff4c22c1", + "stdout_hash": "16565a6f79135fe4b4817164006bf15c02263eba81a2b9e79a60284e", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_float-20601dd.stdout b/tests/reference/asr-test_builtin_float-20601dd.stdout index 41c3cbdca6..33aa352409 100644 --- a/tests/reference/asr-test_builtin_float-20601dd.stdout +++ b/tests/reference/asr-test_builtin_float-20601dd.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] []), test_float: (Subroutine (SymbolTable 2 {float: (ExternalSymbol 2 float 4 float lpython_builtin [] float Private), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) test_float [] [(= (Var 2 i) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 float () [(Var 2 i)] [] (Real 8 []) () ()) Eq (ConstantReal 34.000000 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 float () [(Var 2 i)] [] (Real 8 []) () ()) Eq (UnaryOp USub (ConstantReal 4235.000000 (Real 8 [])) (Real 8 []) (ConstantReal -4235.000000 (Real 8 []))) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 float () [(ConstantInteger 34 (Integer 4 []))] [] (Real 8 []) (ConstantReal 34.000000 (Real 8 [])) ()) Eq (ConstantReal 34.000000 (Real 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 float () [(UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 [])))] [] (Real 8 []) (ConstantReal -4235.000000 (Real 8 [])) ()) Eq (UnaryOp USub (ConstantReal 4235.000000 (Real 8 [])) (Real 8 []) (ConstantReal -4235.000000 (Real 8 []))) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] []), test_float: (Subroutine (SymbolTable 2 {float: (ExternalSymbol 2 float 4 float lpython_builtin [] float Private), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) test_float [] [(= (Var 2 i) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 float () [(Var 2 i)] [] (Real 8 []) () ()) Eq (ConstantReal 34.000000 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 float () [(Var 2 i)] [] (Real 8 []) () ()) Eq (UnaryOp USub (ConstantReal 4235.000000 (Real 8 [])) (Real 8 []) (ConstantReal -4235.000000 (Real 8 []))) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 float () [(ConstantInteger 34 (Integer 4 []))] [] (Real 8 []) (ConstantReal 34.000000 (Real 8 [])) ()) Eq (ConstantReal 34.000000 (Real 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 float () [(UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 [])))] [] (Real 8 []) (ConstantReal -4235.000000 (Real 8 [])) ()) Eq (UnaryOp USub (ConstantReal 4235.000000 (Real 8 [])) (Real 8 []) (ConstantReal -4235.000000 (Real 8 []))) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_hex-64bd268.json b/tests/reference/asr-test_builtin_hex-64bd268.json index e4dc720e11..a0a5ff0d8c 100644 --- a/tests/reference/asr-test_builtin_hex-64bd268.json +++ b/tests/reference/asr-test_builtin_hex-64bd268.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_hex-64bd268.stdout", - "stdout_hash": "222bf7134ed8ff229ef1dcddf67774de7abdfa8aadc83fac5fdab247", + "stdout_hash": "2970db8a8d46e1a936f336e3516ee8b72a6bc6209cb53cac275149d0", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_hex-64bd268.stdout b/tests/reference/asr-test_builtin_hex-64bd268.stdout index 7e134e566b..35d1e930fa 100644 --- a/tests/reference/asr-test_builtin_hex-64bd268.stdout +++ b/tests/reference/asr-test_builtin_hex-64bd268.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 18 {}) _lfortran_main_program [] [(SubroutineCall 1 test_hex () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_hex: (Subroutine (SymbolTable 2 {hex: (ExternalSymbol 2 hex 4 hex lpython_builtin [] hex Private), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) test_hex [] [(= (Var 2 i) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 hex () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0x22" (Character 1 4 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 hex () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "-0x108b" (Character 1 7 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 hex () [(ConstantInteger 34 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0x22" (Character 1 1 () [])) ()) Eq (ConstantString "0x22" (Character 1 4 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 hex () [(UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0x108b" (Character 1 1 () [])) ()) Eq (ConstantString "-0x108b" (Character 1 7 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_hex () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_hex: (Subroutine (SymbolTable 2 {hex: (ExternalSymbol 2 hex 4 hex lpython_builtin [] hex Private), i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.)}) test_hex [] [(= (Var 2 i) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 hex () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0x22" (Character 1 4 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 hex () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "-0x108b" (Character 1 7 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 hex () [(ConstantInteger 34 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0x22" (Character 1 1 () [])) ()) Eq (ConstantString "0x22" (Character 1 4 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 hex () [(UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0x108b" (Character 1 1 () [])) ()) Eq (ConstantString "-0x108b" (Character 1 7 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_int-8f88fdc.json b/tests/reference/asr-test_builtin_int-8f88fdc.json index 45a35f2999..3c5526c0c2 100644 --- a/tests/reference/asr-test_builtin_int-8f88fdc.json +++ b/tests/reference/asr-test_builtin_int-8f88fdc.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_int-8f88fdc.stdout", - "stdout_hash": "87f3b4b2932cc45371ade598965cc571322c8681c138cd61b4a06657", + "stdout_hash": "1213d4f95e3bc21fd9a8ceb29f8e10aa8722a4b3c6a620a28853ad73", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_int-8f88fdc.stdout b/tests/reference/asr-test_builtin_int-8f88fdc.stdout index 6460f4d376..10690333d5 100644 --- a/tests/reference/asr-test_builtin_int-8f88fdc.stdout +++ b/tests/reference/asr-test_builtin_int-8f88fdc.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] []), test_int: (Subroutine (SymbolTable 2 {f: (Variable 2 f Local () () Default (Real 8 []) Source Public Required .false.), int: (ExternalSymbol 2 int 4 int lpython_builtin [] int Private)}) test_int [] [(= (Var 2 f) (ConstantReal 5.678000 (Real 8 [])) ()) (Assert (Compare (FunctionCall 2 int () [(Var 2 f)] [] (Integer 4 []) () ()) Eq (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 f) (UnaryOp USub (ConstantReal 183745.230000 (Real 8 [])) (Real 8 []) (ConstantReal -183745.230000 (Real 8 []))) ()) (Assert (Compare (FunctionCall 2 int () [(Var 2 f)] [] (Integer 4 []) () ()) Eq (UnaryOp USub (ConstantInteger 183745 (Integer 4 [])) (Integer 4 []) (ConstantInteger -183745 (Integer 4 []))) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 int () [(ConstantReal 5.500000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 5 (Integer 4 [])) ()) Eq (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 int () [(UnaryOp USub (ConstantReal 5.500000 (Real 8 [])) (Real 8 []) (ConstantReal -5.500000 (Real 8 [])))] [] (Integer 4 []) (ConstantInteger -5 (Integer 4 [])) ()) Eq (UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 []))) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] []), test_int: (Subroutine (SymbolTable 2 {f: (Variable 2 f Local () () Default (Real 8 []) Source Public Required .false.), int: (ExternalSymbol 2 int 4 int lpython_builtin [] int Private)}) test_int [] [(= (Var 2 f) (ConstantReal 5.678000 (Real 8 [])) ()) (Assert (Compare (FunctionCall 2 int () [(Var 2 f)] [] (Integer 4 []) () ()) Eq (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 f) (UnaryOp USub (ConstantReal 183745.230000 (Real 8 [])) (Real 8 []) (ConstantReal -183745.230000 (Real 8 []))) ()) (Assert (Compare (FunctionCall 2 int () [(Var 2 f)] [] (Integer 4 []) () ()) Eq (UnaryOp USub (ConstantInteger 183745 (Integer 4 [])) (Integer 4 []) (ConstantInteger -183745 (Integer 4 []))) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 int () [(ConstantReal 5.500000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 5 (Integer 4 [])) ()) Eq (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 int () [(UnaryOp USub (ConstantReal 5.500000 (Real 8 [])) (Real 8 []) (ConstantReal -5.500000 (Real 8 [])))] [] (Integer 4 []) (ConstantInteger -5 (Integer 4 [])) ()) Eq (UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 []))) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_len-55b0dec.json b/tests/reference/asr-test_builtin_len-55b0dec.json index 6961ef0b85..8c2facb173 100644 --- a/tests/reference/asr-test_builtin_len-55b0dec.json +++ b/tests/reference/asr-test_builtin_len-55b0dec.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_len-55b0dec.stdout", - "stdout_hash": "f608e9caf601f75e201491bcd4a1650a5eb3c204513a681216746b8c", + "stdout_hash": "792252950d9dc927a0deabb8eb0f395733f06f8e4ac57854e55cb4ba", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_len-55b0dec.stdout b/tests/reference/asr-test_builtin_len-55b0dec.stdout index 5c916fd24b..45b846f946 100644 --- a/tests/reference/asr-test_builtin_len-55b0dec.stdout +++ b/tests/reference/asr-test_builtin_len-55b0dec.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 18 {}) _lfortran_main_program [] [(SubroutineCall 1 test_len () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_len: (Subroutine (SymbolTable 2 {len: (ExternalSymbol 2 len 4 len lpython_builtin [] len Private), s: (Variable 2 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_len [] [(= (Var 2 s) (ConstantString "abcd" (Character 1 4 () [])) ()) (Assert (Compare (FunctionCall 2 len () [(Var 2 s)] [] (Integer 4 []) () ()) Eq (ConstantInteger 4 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 s) (ConstantString "" (Character 1 0 () [])) ()) (Assert (Compare (FunctionCall 2 len () [(Var 2 s)] [] (Integer 4 []) () ()) Eq (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 len () [(ConstantString "abcd" (Character 1 4 () []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) Eq (ConstantInteger 4 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 len () [(ConstantString "" (Character 1 0 () []))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) Eq (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_len () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_len: (Subroutine (SymbolTable 2 {len: (ExternalSymbol 2 len 4 len lpython_builtin [] len Private), s: (Variable 2 s Local () () Default (Character 1 -2 () []) Source Public Required .false.)}) test_len [] [(= (Var 2 s) (ConstantString "abcd" (Character 1 4 () [])) ()) (Assert (Compare (FunctionCall 2 len () [(Var 2 s)] [] (Integer 4 []) () ()) Eq (ConstantInteger 4 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 s) (ConstantString "" (Character 1 0 () [])) ()) (Assert (Compare (FunctionCall 2 len () [(Var 2 s)] [] (Integer 4 []) () ()) Eq (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 len () [(ConstantString "abcd" (Character 1 4 () []))] [] (Integer 4 []) (ConstantInteger 4 (Integer 4 [])) ()) Eq (ConstantInteger 4 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 len () [(ConstantString "" (Character 1 0 () []))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) Eq (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_oct-20b9066.json b/tests/reference/asr-test_builtin_oct-20b9066.json index 44d2046f67..e7f34277e6 100644 --- a/tests/reference/asr-test_builtin_oct-20b9066.json +++ b/tests/reference/asr-test_builtin_oct-20b9066.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_oct-20b9066.stdout", - "stdout_hash": "de259ca941f17ca84e1a6dd031353162e1ce081ef110c2a689813073", + "stdout_hash": "714682bf10e03d1c4cdae13f942b5d7fc8bd71cc086bb67c6a9ad410", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_oct-20b9066.stdout b/tests/reference/asr-test_builtin_oct-20b9066.stdout index ef0e57bbdb..191e30644c 100644 --- a/tests/reference/asr-test_builtin_oct-20b9066.stdout +++ b/tests/reference/asr-test_builtin_oct-20b9066.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 18 {}) _lfortran_main_program [] [(SubroutineCall 1 test_oct () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_oct: (Subroutine (SymbolTable 2 {i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.), oct: (ExternalSymbol 2 oct 4 oct lpython_builtin [] oct Private)}) test_oct [] [(= (Var 2 i) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 oct () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0o42" (Character 1 4 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 oct () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "-0o10213" (Character 1 8 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 oct () [(ConstantInteger 34 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0o42" (Character 1 1 () [])) ()) Eq (ConstantString "0o42" (Character 1 4 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 oct () [(UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0o10213" (Character 1 1 () [])) ()) Eq (ConstantString "-0o10213" (Character 1 8 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_oct () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_oct: (Subroutine (SymbolTable 2 {i: (Variable 2 i Local () () Default (Integer 4 []) Source Public Required .false.), oct: (ExternalSymbol 2 oct 4 oct lpython_builtin [] oct Private)}) test_oct [] [(= (Var 2 i) (ConstantInteger 34 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 oct () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "0o42" (Character 1 4 () [])) (Logical 4 []) () ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 []))) ()) (Assert (Compare (FunctionCall 2 oct () [(Var 2 i)] [] (Character 1 -2 () []) () ()) Eq (ConstantString "-0o10213" (Character 1 8 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 oct () [(ConstantInteger 34 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "0o42" (Character 1 1 () [])) ()) Eq (ConstantString "0o42" (Character 1 4 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 oct () [(UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-0o10213" (Character 1 1 () [])) ()) Eq (ConstantString "-0o10213" (Character 1 8 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_pow-f02fcda.json b/tests/reference/asr-test_builtin_pow-f02fcda.json index 2e6b6565da..484abd0a7a 100644 --- a/tests/reference/asr-test_builtin_pow-f02fcda.json +++ b/tests/reference/asr-test_builtin_pow-f02fcda.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_pow-f02fcda.stdout", - "stdout_hash": "ec9c857cfabd443659b1478fee3ceef271af12e3b0250f187f18f67a", + "stdout_hash": "366bca5508d186fd6f7add306032f32c9528555becda10a6b18071ad", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_pow-f02fcda.stdout b/tests/reference/asr-test_builtin_pow-f02fcda.stdout index 93de4f875c..8672fb9b0f 100644 --- a/tests/reference/asr-test_builtin_pow-f02fcda.stdout +++ b/tests/reference/asr-test_builtin_pow-f02fcda.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] []), test_pow: (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.), pow: (ExternalSymbol 2 pow 4 pow lpython_builtin [] pow Private)}) test_pow [] [(= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (ConstantInteger 5 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) Eq (ConstantInteger 32 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 6 (Integer 4 [])) ()) (= (Var 2 b) (ConstantInteger 3 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) Eq (ConstantInteger 216 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (ConstantInteger 0 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) Eq (ConstantInteger 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 []))) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) IntegerToReal (Real 8 []) ()) Eq (ConstantReal 0.500000 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 6 (Integer 4 [])) ()) (= (Var 2 b) (UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 []))) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) IntegerToReal (Real 8 []) ()) Eq (ConstantReal 0.000772 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (UnaryOp USub (ConstantInteger 3 (Integer 4 [])) (Integer 4 []) (ConstantInteger -3 (Integer 4 []))) ()) (= (Var 2 b) (UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 []))) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) IntegerToReal (Real 8 []) ()) Eq (UnaryOp USub (ConstantReal 0.004115 (Real 8 [])) (Real 8 []) (ConstantReal -0.004115 (Real 8 []))) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 pow () [(ConstantInteger 0 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 1 (Integer 4 [])) ()) Eq (ConstantInteger 1 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(ConstantInteger 6 (Integer 4 [])) (UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 [])))] [] (Integer 4 []) (ConstantReal 0.000772 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Eq (ConstantReal 0.000772 (Real 8 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] []), test_pow: (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.), pow: (ExternalSymbol 2 pow 4 pow lpython_builtin [] pow Private)}) test_pow [] [(= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (ConstantInteger 5 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) Eq (ConstantInteger 32 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 6 (Integer 4 [])) ()) (= (Var 2 b) (ConstantInteger 3 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) Eq (ConstantInteger 216 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (ConstantInteger 0 (Integer 4 [])) ()) (Assert (Compare (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) Eq (ConstantInteger 1 (Integer 4 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 2 (Integer 4 [])) ()) (= (Var 2 b) (UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 []))) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) IntegerToReal (Real 8 []) ()) Eq (ConstantReal 0.500000 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (ConstantInteger 6 (Integer 4 [])) ()) (= (Var 2 b) (UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 []))) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) IntegerToReal (Real 8 []) ()) Eq (ConstantReal 0.000772 (Real 8 [])) (Logical 4 []) () ()) ()) (= (Var 2 a) (UnaryOp USub (ConstantInteger 3 (Integer 4 [])) (Integer 4 []) (ConstantInteger -3 (Integer 4 []))) ()) (= (Var 2 b) (UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 []))) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(Var 2 a) (Var 2 b)] [] (Integer 4 []) () ()) IntegerToReal (Real 8 []) ()) Eq (UnaryOp USub (ConstantReal 0.004115 (Real 8 [])) (Real 8 []) (ConstantReal -0.004115 (Real 8 []))) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 pow () [(ConstantInteger 0 (Integer 4 [])) (ConstantInteger 0 (Integer 4 []))] [] (Integer 4 []) (ConstantInteger 1 (Integer 4 [])) ()) Eq (ConstantInteger 1 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (ImplicitCast (FunctionCall 2 pow () [(ConstantInteger 6 (Integer 4 [])) (UnaryOp USub (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4 (Integer 4 [])))] [] (Integer 4 []) (ConstantReal 0.000772 (Real 8 [])) ()) IntegerToReal (Real 8 []) ()) Eq (ConstantReal 0.000772 (Real 8 [])) (Logical 4 []) () ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_round-7417a21.json b/tests/reference/asr-test_builtin_round-7417a21.json new file mode 100644 index 0000000000..985ca4b2ad --- /dev/null +++ b/tests/reference/asr-test_builtin_round-7417a21.json @@ -0,0 +1,13 @@ +{ + "basename": "asr-test_builtin_round-7417a21", + "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", + "infile": "tests/../integration_tests/test_builtin_round.py", + "infile_hash": "48e36f1b357956530982b1f1a1d91bade8f408a2fcf6eed603e5f433", + "outfile": null, + "outfile_hash": null, + "stdout": "asr-test_builtin_round-7417a21.stdout", + "stdout_hash": "adc8eaae83e7e05a70c07d34ef025ad8ad31b6f38b380ee2fd703aaf", + "stderr": null, + "stderr_hash": null, + "returncode": 0 +} \ No newline at end of file diff --git a/tests/reference/asr-test_builtin_round-7417a21.stdout b/tests/reference/asr-test_builtin_round-7417a21.stdout new file mode 100644 index 0000000000..c161b2f5ff --- /dev/null +++ b/tests/reference/asr-test_builtin_round-7417a21.stdout @@ -0,0 +1 @@ +(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_round () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_main_program () [] ())]), test_round: (Subroutine (SymbolTable 2 {f: (Variable 2 f Local () () Default (Real 8 []) Source Public Required .false.), round: (ExternalSymbol 2 round 4 round lpython_builtin [] round Private)}) test_round [] [(= (Var 2 f) (ConstantReal 5.678000 (Real 8 [])) ()) (Print () [(FunctionCall 2 round () [(Var 2 f)] [] (Integer 4 []) () ())]) (= (Var 2 f) (UnaryOp USub (ConstantReal 183745.230000 (Real 8 [])) (Real 8 []) (ConstantReal -183745.230000 (Real 8 []))) ()) (Print () [(FunctionCall 2 round () [(Var 2 f)] [] (Integer 4 []) () ())]) (= (Var 2 f) (ConstantReal 44.340000 (Real 8 [])) ()) (Print () [(FunctionCall 2 round () [(Var 2 f)] [] (Integer 4 []) () ())]) (= (Var 2 f) (ConstantReal 0.500000 (Real 8 [])) ()) (Print () [(FunctionCall 2 round () [(Var 2 f)] [] (Integer 4 []) () ())]) (= (Var 2 f) (UnaryOp USub (ConstantReal 50.500000 (Real 8 [])) (Real 8 []) (ConstantReal -50.500000 (Real 8 []))) ()) (Print () [(FunctionCall 2 round () [(Var 2 f)] [] (Integer 4 []) () ())]) (= (Var 2 f) (ConstantReal 1.500000 (Real 8 [])) ()) (Print () [(FunctionCall 2 round () [(Var 2 f)] [] (Integer 4 []) () ())]) (Assert (Compare (FunctionCall 2 round () [(ConstantReal 13.001000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 13 (Integer 4 [])) ()) Eq (ConstantInteger 13 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 round () [(UnaryOp USub (ConstantReal 40.499990 (Real 8 [])) (Real 8 []) (ConstantReal -40.499990 (Real 8 [])))] [] (Integer 4 []) (ConstantInteger -40 (Integer 4 [])) ()) Eq (UnaryOp USub (ConstantInteger 40 (Integer 4 [])) (Integer 4 []) (ConstantInteger -40 (Integer 4 []))) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 round () [(ConstantReal 0.500000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) Eq (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 round () [(UnaryOp USub (ConstantReal 0.500000 (Real 8 [])) (Real 8 []) (ConstantReal -0.500000 (Real 8 [])))] [] (Integer 4 []) (ConstantInteger 0 (Integer 4 [])) ()) Eq (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 round () [(ConstantReal 1.500000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 2 (Integer 4 [])) ()) Eq (ConstantInteger 2 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 round () [(ConstantReal 50.500000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 50 (Integer 4 [])) ()) Eq (ConstantInteger 50 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 round () [(ConstantReal 56.780000 (Real 8 []))] [] (Integer 4 []) (ConstantInteger 57 (Integer 4 [])) ()) Eq (ConstantInteger 57 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/reference/asr-test_builtin_str-580e920.json b/tests/reference/asr-test_builtin_str-580e920.json index b9d19d8663..ea0b3dee0c 100644 --- a/tests/reference/asr-test_builtin_str-580e920.json +++ b/tests/reference/asr-test_builtin_str-580e920.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_str-580e920.stdout", - "stdout_hash": "5566c7bb611858c26f835e7408c1c9b47b291080abbb05152ab7b1ea", + "stdout_hash": "53b95cf22e01809cdf5d4e10eff7f793e785ab18aac2ddddf90263e3", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_str-580e920.stdout b/tests/reference/asr-test_builtin_str-580e920.stdout index 06db47b80c..19c95941e1 100644 --- a/tests/reference/asr-test_builtin_str-580e920.stdout +++ b/tests/reference/asr-test_builtin_str-580e920.stdout @@ -1 +1 @@ -(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 17 {}) main_program [] []), test_str_int: (Subroutine (SymbolTable 2 {s: (Variable 2 s Local () () Default (Character 1 -2 () []) Source Public Required .false.), str: (ExternalSymbol 2 str 4 str lpython_builtin [] str Private)}) test_str_int [] [(= (Var 2 s) (FunctionCall 2 str () [(ConstantInteger 356 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "356" (Character 1 1 () [])) ()) ()) (Assert (Compare (Var 2 s) Eq (ConstantString "356" (Character 1 3 () [])) (Logical 4 []) () ()) ()) (= (Var 2 s) (FunctionCall 2 str () [(UnaryOp USub (ConstantInteger 567 (Integer 4 [])) (Integer 4 []) (ConstantInteger -567 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-567" (Character 1 1 () [])) ()) ()) (Assert (Compare (Var 2 s) Eq (ConstantString "-567" (Character 1 4 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 str () [(ConstantInteger 4 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "4" (Character 1 1 () [])) ()) Eq (ConstantString "4" (Character 1 1 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 str () [(UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-5" (Character 1 1 () [])) ()) Eq (ConstantString "-5" (Character 1 2 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) +(TranslationUnit (SymbolTable 1 {lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] []), test_str_int: (Subroutine (SymbolTable 2 {s: (Variable 2 s Local () () Default (Character 1 -2 () []) Source Public Required .false.), str: (ExternalSymbol 2 str 4 str lpython_builtin [] str Private)}) test_str_int [] [(= (Var 2 s) (FunctionCall 2 str () [(ConstantInteger 356 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "356" (Character 1 1 () [])) ()) ()) (Assert (Compare (Var 2 s) Eq (ConstantString "356" (Character 1 3 () [])) (Logical 4 []) () ()) ()) (= (Var 2 s) (FunctionCall 2 str () [(UnaryOp USub (ConstantInteger 567 (Integer 4 [])) (Integer 4 []) (ConstantInteger -567 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-567" (Character 1 1 () [])) ()) ()) (Assert (Compare (Var 2 s) Eq (ConstantString "-567" (Character 1 4 () [])) (Logical 4 []) () ()) ()) (Assert (Compare (FunctionCall 2 str () [(ConstantInteger 4 (Integer 4 []))] [] (Character 1 -2 () []) (ConstantString "4" (Character 1 1 () [])) ()) Eq (ConstantString "4" (Character 1 1 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (Assert (Compare (FunctionCall 2 str () [(UnaryOp USub (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -5 (Integer 4 [])))] [] (Character 1 -2 () []) (ConstantString "-5" (Character 1 1 () [])) ()) Eq (ConstantString "-5" (Character 1 2 () [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ())] Source Public Implementation () .false. .false.)}) []) diff --git a/tests/tests.toml b/tests/tests.toml index 120f07fc0f..b496b7723f 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -197,6 +197,10 @@ asr = true filename = "../integration_tests/test_builtin_float.py" asr = true +[[test]] +filename = "../integration_tests/test_builtin_round.py" +asr = true + [[test]] filename = "../integration_tests/test_builtin_bin.py" asr = true