diff --git a/src/lpython/semantics/python_comptime_eval.h b/src/lpython/semantics/python_comptime_eval.h index 5acb80ff90..5b9dea7ec0 100644 --- a/src/lpython/semantics/python_comptime_eval.h +++ b/src/lpython/semantics/python_comptime_eval.h @@ -96,24 +96,30 @@ struct PythonIntrinsicProcedures { if (args.size() != 1) { throw SemanticError("Intrinsic abs function accepts exactly 1 argument", loc); } - ASR::expr_t* trig_arg = args[0]; + ASR::expr_t* arg = args[0]; ASR::ttype_t* t = ASRUtils::expr_type(args[0]); - if (ASR::is_a(*t)) { - double rv = ASR::down_cast(trig_arg)->m_r; + ASR::ttype_t *int_type = ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4, nullptr, 0)); + ASR::ttype_t *real_type = ASRUtils::TYPE(ASR::make_Real_t(al, loc, 8, nullptr, 0)); + if (ASRUtils::is_real(*t)) { + double rv = ASR::down_cast(arg)->m_r; double val = std::abs(rv); - return ASR::down_cast(ASR::make_ConstantReal_t(al, loc, val, t)); - } else if (ASR::is_a(*t)) { - int64_t rv = ASR::down_cast(trig_arg)->m_n; + return ASR::down_cast(ASR::make_ConstantReal_t(al, loc, val, real_type)); + } else if (ASRUtils::is_integer(*t)) { + int64_t rv = ASR::down_cast(arg)->m_n; int64_t val = std::abs(rv); - return ASR::down_cast(ASR::make_ConstantInteger_t(al, loc, val, t)); - } else if (ASR::is_a(*t)) { - double re = ASR::down_cast(trig_arg)->m_re; - double im = ASR::down_cast(trig_arg)->m_im; + return ASR::down_cast(ASR::make_ConstantInteger_t(al, loc, val, int_type)); + } else if (ASRUtils::is_logical(*t)) { + bool rv = ASR::down_cast(arg)->m_value; + int8_t val = rv ? 1 : 0; + return ASR::down_cast(ASR::make_ConstantInteger_t(al, loc, val, int_type)); + } else if (ASRUtils::is_complex(*t)) { + double re = ASR::down_cast(arg)->m_re; + double im = ASR::down_cast(arg)->m_im; std::complex x(re, im); double result = std::abs(x); - return ASR::down_cast(ASR::make_ConstantReal_t(al, loc, result, t)); + return ASR::down_cast(ASR::make_ConstantReal_t(al, loc, result, real_type)); } else { - throw SemanticError("Argument of the abs function must be Integer, Real or Complex", loc); + throw SemanticError("Argument of the abs function must be Integer, Real, Logical, or Complex.", loc); } } diff --git a/tests/constants1.py b/tests/constants1.py index fd3471d782..9735371d3e 100644 --- a/tests/constants1.py +++ b/tests/constants1.py @@ -19,15 +19,15 @@ def test_ord_chr(): def test_abs(): - # a: i32 - # a = abs(5) - # a = abs(-500) - # a = abs(False) - # a = abs(True) + a: i32 + a = abs(5) + a = abs(-500) + a = abs(False) + a = abs(True) b: f32 b = abs(3.45) b = abs(-5346.34) - # b = abs(complex(3.45, 5.6)) + b = abs(complex(3.45, 5.6)) def test_len(): diff --git a/tests/reference/asr-constants1-5828e8a.json b/tests/reference/asr-constants1-5828e8a.json index f6047d74b4..0e8629eedc 100644 --- a/tests/reference/asr-constants1-5828e8a.json +++ b/tests/reference/asr-constants1-5828e8a.json @@ -2,11 +2,11 @@ "basename": "asr-constants1-5828e8a", "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", "infile": "tests/constants1.py", - "infile_hash": "6adf0c1cf8ec1667bf19edaf62d087483e6229370ed0f10a207ee0b4", + "infile_hash": "96e60b5d3b6cb09a1198932629c9974ac3cf8854e3b1c7ba8959ea83", "outfile": null, "outfile_hash": null, "stdout": "asr-constants1-5828e8a.stdout", - "stdout_hash": "afdf64c50b62ecb3a51f71b729f21920178f29682559773af511c470", + "stdout_hash": "6183731c70508ffbf40925fd0bc831a41578990f8e3ba1eb7ad59521", "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..94531fddc0 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 26 {}) main_program [] []), test_abs: (Subroutine (SymbolTable 4 {a: (Variable 4 a Local () () Default (Integer 4 []) Source Public Required .false.), 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 a) (FunctionCall 4 abs () [(ConstantInteger 5 (Integer 4 []))] [] (Real 8 []) (ConstantInteger 5 (Integer 4 [])) ()) ()) (= (Var 4 a) (FunctionCall 4 abs () [(UnaryOp USub (ConstantInteger 500 (Integer 4 [])) (Integer 4 []) (ConstantInteger -500 (Integer 4 [])))] [] (Real 8 []) (ConstantInteger 500 (Integer 4 [])) ()) ()) (= (Var 4 a) (FunctionCall 4 abs () [(ConstantLogical .false. (Logical 1 []))] [] (Real 8 []) (ConstantInteger 0 (Integer 4 [])) ()) ()) (= (Var 4 a) (FunctionCall 4 abs () [(ConstantLogical .true. (Logical 1 []))] [] (Real 8 []) (ConstantInteger 1 (Integer 4 [])) ()) ()) (= (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 []) ()) ()) (= (Var 4 b) (ImplicitCast (FunctionCall 4 abs () [(ConstantComplex 3.450000 5.600000 (Complex 8 []))] [] (Real 8 []) (ConstantReal 6.577424 (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/ast-constants1-91cb6ff.json b/tests/reference/ast-constants1-91cb6ff.json index 15253b852c..59c4d37347 100644 --- a/tests/reference/ast-constants1-91cb6ff.json +++ b/tests/reference/ast-constants1-91cb6ff.json @@ -2,11 +2,11 @@ "basename": "ast-constants1-91cb6ff", "cmd": "lpython --show-ast --no-color {infile} -o {outfile}", "infile": "tests/constants1.py", - "infile_hash": "6adf0c1cf8ec1667bf19edaf62d087483e6229370ed0f10a207ee0b4", + "infile_hash": "96e60b5d3b6cb09a1198932629c9974ac3cf8854e3b1c7ba8959ea83", "outfile": null, "outfile_hash": null, "stdout": "ast-constants1-91cb6ff.stdout", - "stdout_hash": "3c238eeeb457cbc223572db7626e55d0b8fdff79b1d03393d7734a66", + "stdout_hash": "e7906b7058bcb0974b8d5bf25eff5d2841d308688c9689dd4bd7b65b", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast-constants1-91cb6ff.stdout b/tests/reference/ast-constants1-91cb6ff.stdout index 97d6c4bc95..06b29efc7d 100644 --- a/tests/reference/ast-constants1-91cb6ff.stdout +++ b/tests/reference/ast-constants1-91cb6ff.stdout @@ -1 +1 @@ -(Module [(FunctionDef test_boz ([] [] [] [] [] [] []) [(AnnAssign (Name b Store) (Name str Load) () 1) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 64 ())] []) ()) (Assign [(Name b Store)] (Call (Name bin Load) [(UnaryOp USub (ConstantInt 534 ()))] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 8 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 56 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(UnaryOp USub (ConstantInt 534 ()))] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 42 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 12648430 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(UnaryOp USub (ConstantInt 534 ()))] []) ())] [] () ()) (FunctionDef test_ord_chr ([] [] [] [] [] [] []) [(AnnAssign (Name s Store) (Name str Load) () 1) (AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name ord Load) [(ConstantStr "5" ())] []) ()) (Assign [(Name s Store)] (Call (Name chr Load) [(ConstantInt 43 ())] []) ())] [] () ()) (FunctionDef test_abs ([] [] [] [] [] [] []) [(AnnAssign (Name b Store) (Name f32 Load) () 1) (Assign [(Name b Store)] (Call (Name abs Load) [(ConstantFloat 3.450000 ())] []) ()) (Assign [(Name b Store)] (Call (Name abs Load) [(UnaryOp USub (ConstantFloat 5346.340000 ()))] []) ())] [] () ()) (FunctionDef test_len ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name len Load) [(ConstantStr "" ())] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(ConstantStr "test" ())] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(ConstantStr "this is a test" ())] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Tuple [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Tuple [(Tuple [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantFloat 3.400000 ())] Load) (Tuple [(ConstantStr "c" ()) (ConstantInt 3 ()) (ConstantFloat 5.600000 ())] Load)] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(List [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(List [(List [(UnaryOp USub (ConstantInt 4 ())) (UnaryOp USub (ConstantInt 5 ())) (UnaryOp USub (ConstantInt 6 ()))] Load) (List [(UnaryOp USub (ConstantInt 1 ())) (UnaryOp USub (ConstantInt 2 ())) (UnaryOp USub (ConstantInt 3 ()))] Load)] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Set [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())])] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Dict [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantStr "c" ())])] []) ())] [] () ()) (FunctionDef test_bool ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name bool Load) () 1) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantInt 0 ())] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(UnaryOp USub (ConstantInt 1 ()))] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantStr "" ())] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(Call (Name complex Load) [(ConstantInt 0 ()) (ConstantInt 0 ())] [])] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .false. ())]) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantStr "t" ())] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantFloat 2.300000 ())] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .true. ())]) ())] [] () ()) (FunctionDef test_str ([] [] [] [] [] [] []) [(AnnAssign (Name s Store) (Name str Load) () 1) (Assign [(Name s Store)] (Call (Name str Load) [] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(UnaryOp USub (ConstantInt 4 ()))] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantFloat 5.600000 ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantBool .true. ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantBool .false. ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantStr "5346" ())] []) ())] [] () ()) (FunctionDef test_callable ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name bool Load) () 1) (AnnAssign (Name b Store) (Name i32 Load) () 1) (Assign [(Name b Store)] (ConstantInt 2 ()) ()) (Assign [(Name a Store)] (Call (Name callable Load) [(Name test_len Load)] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .true. ())]) ()) (Assign [(Name a Store)] (Call (Name callable Load) [(Name b Load)] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .false. ())]) ()) (Assign [(Name a Store)] (Call (Name callable Load) [(ConstantStr "c" ())] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .false. ())]) ())] [] () ()) (FunctionDef test_int ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i64 Load) () 1) (Assign [(Name a Store)] (Call (Name int Load) [] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantFloat 4.560000 ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(UnaryOp USub (ConstantFloat 5.000010 ()))] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantBool .true. ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantBool .false. ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantStr "5346" ())] []) ())] [] () ()) (FunctionDef test_float ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name f64 Load) () 1) (Assign [(Name a Store)] (Call (Name float Load) [] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantFloat 4.560000 ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(UnaryOp USub (ConstantInt 1 ()))] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantBool .true. ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantBool .false. ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantStr "5346" ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantStr "423.534" ())] []) ())] [] () ()) (FunctionDef test_divmod ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 9 ()) (ConstantInt 3 ())] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 9 ()) (UnaryOp USub (ConstantInt 3 ()))] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 3 ()) (ConstantInt 3 ())] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 4 ()) (ConstantInt 5 ())] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 0 ()) (ConstantInt 5 ())] []) ())] [] () ())] []) +(Module [(FunctionDef test_boz ([] [] [] [] [] [] []) [(AnnAssign (Name b Store) (Name str Load) () 1) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name b Store)] (Call (Name bin Load) [(ConstantInt 64 ())] []) ()) (Assign [(Name b Store)] (Call (Name bin Load) [(UnaryOp USub (ConstantInt 534 ()))] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 8 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(ConstantInt 56 ())] []) ()) (Assign [(Name b Store)] (Call (Name oct Load) [(UnaryOp USub (ConstantInt 534 ()))] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 42 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(ConstantInt 12648430 ())] []) ()) (Assign [(Name b Store)] (Call (Name hex Load) [(UnaryOp USub (ConstantInt 534 ()))] []) ())] [] () ()) (FunctionDef test_ord_chr ([] [] [] [] [] [] []) [(AnnAssign (Name s Store) (Name str Load) () 1) (AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name ord Load) [(ConstantStr "5" ())] []) ()) (Assign [(Name s Store)] (Call (Name chr Load) [(ConstantInt 43 ())] []) ())] [] () ()) (FunctionDef test_abs ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name abs Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name a Store)] (Call (Name abs Load) [(UnaryOp USub (ConstantInt 500 ()))] []) ()) (Assign [(Name a Store)] (Call (Name abs Load) [(ConstantBool .false. ())] []) ()) (Assign [(Name a Store)] (Call (Name abs Load) [(ConstantBool .true. ())] []) ()) (AnnAssign (Name b Store) (Name f32 Load) () 1) (Assign [(Name b Store)] (Call (Name abs Load) [(ConstantFloat 3.450000 ())] []) ()) (Assign [(Name b Store)] (Call (Name abs Load) [(UnaryOp USub (ConstantFloat 5346.340000 ()))] []) ()) (Assign [(Name b Store)] (Call (Name abs Load) [(Call (Name complex Load) [(ConstantFloat 3.450000 ()) (ConstantFloat 5.600000 ())] [])] []) ())] [] () ()) (FunctionDef test_len ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name len Load) [(ConstantStr "" ())] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(ConstantStr "test" ())] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(ConstantStr "this is a test" ())] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Tuple [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Tuple [(Tuple [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantFloat 3.400000 ())] Load) (Tuple [(ConstantStr "c" ()) (ConstantInt 3 ()) (ConstantFloat 5.600000 ())] Load)] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(List [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(List [(List [(UnaryOp USub (ConstantInt 4 ())) (UnaryOp USub (ConstantInt 5 ())) (UnaryOp USub (ConstantInt 6 ()))] Load) (List [(UnaryOp USub (ConstantInt 1 ())) (UnaryOp USub (ConstantInt 2 ())) (UnaryOp USub (ConstantInt 3 ()))] Load)] Load)] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Set [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())])] []) ()) (Assign [(Name a Store)] (Call (Name len Load) [(Dict [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())] [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantStr "c" ())])] []) ())] [] () ()) (FunctionDef test_bool ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name bool Load) () 1) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantInt 0 ())] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(UnaryOp USub (ConstantInt 1 ()))] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantStr "" ())] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(Call (Name complex Load) [(ConstantInt 0 ()) (ConstantInt 0 ())] [])] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .false. ())]) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantStr "t" ())] []) ()) (Assign [(Name a Store)] (Call (Name bool Load) [(ConstantFloat 2.300000 ())] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .true. ())]) ())] [] () ()) (FunctionDef test_str ([] [] [] [] [] [] []) [(AnnAssign (Name s Store) (Name str Load) () 1) (Assign [(Name s Store)] (Call (Name str Load) [] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(UnaryOp USub (ConstantInt 4 ()))] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantFloat 5.600000 ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantBool .true. ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantBool .false. ())] []) ()) (Assign [(Name s Store)] (Call (Name str Load) [(ConstantStr "5346" ())] []) ())] [] () ()) (FunctionDef test_callable ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name bool Load) () 1) (AnnAssign (Name b Store) (Name i32 Load) () 1) (Assign [(Name b Store)] (ConstantInt 2 ()) ()) (Assign [(Name a Store)] (Call (Name callable Load) [(Name test_len Load)] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .true. ())]) ()) (Assign [(Name a Store)] (Call (Name callable Load) [(Name b Load)] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .false. ())]) ()) (Assign [(Name a Store)] (Call (Name callable Load) [(ConstantStr "c" ())] []) ()) (Assert (Compare (Name a Load) Eq [(ConstantBool .false. ())]) ())] [] () ()) (FunctionDef test_int ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i64 Load) () 1) (Assign [(Name a Store)] (Call (Name int Load) [] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantFloat 4.560000 ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(UnaryOp USub (ConstantFloat 5.000010 ()))] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantBool .true. ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantBool .false. ())] []) ()) (Assign [(Name a Store)] (Call (Name int Load) [(ConstantStr "5346" ())] []) ())] [] () ()) (FunctionDef test_float ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name f64 Load) () 1) (Assign [(Name a Store)] (Call (Name float Load) [] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantFloat 4.560000 ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantInt 5 ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(UnaryOp USub (ConstantInt 1 ()))] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantBool .true. ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantBool .false. ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantStr "5346" ())] []) ()) (Assign [(Name a Store)] (Call (Name float Load) [(ConstantStr "423.534" ())] []) ())] [] () ()) (FunctionDef test_divmod ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 9 ()) (ConstantInt 3 ())] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 9 ()) (UnaryOp USub (ConstantInt 3 ()))] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 3 ()) (ConstantInt 3 ())] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 4 ()) (ConstantInt 5 ())] []) ()) (Assign [(Name a Store)] (Call (Name divmod Load) [(ConstantInt 0 ()) (ConstantInt 5 ())] []) ())] [] () ())] [])