forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lcompilers#211 from Smit-create/int_test1
BUG: All tests weren't working in integration tests
- Loading branch information
Showing
26 changed files
with
75 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
from ltypes import i32 | ||
|
||
def test_float(): | ||
# TODO: the commented tests should also work | ||
i: i32 | ||
i = 34 | ||
assert float(i) == 34.0 | ||
assert float(34) == 34.0 | ||
# assert float(i) == 34.0 | ||
i = -4235 | ||
assert float(i) == -4235.0 | ||
assert float(-4235) == -4235.0 | ||
assert float(34) == 34.0 | ||
assert float(-4235) == -4235.0 | ||
|
||
|
||
test_float() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
from ltypes import f64 | ||
|
||
def test_int(): | ||
# TODO: the commented tests should also work | ||
f: f64 | ||
f = 5.678 | ||
assert int(f) == 5 | ||
assert int(5.678) == 5 | ||
# assert int(f) == 5 | ||
f = -183745.23 | ||
assert int(f) == -183745 | ||
assert int(-183745.23) == -183745 | ||
# assert int(f) == -183745 | ||
assert int(5.5) == 5 | ||
assert int(-5.5) == -5 | ||
|
||
test_int() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ def test_str_int(): | |
assert s == "-567" | ||
assert str(4) == "4" | ||
assert str(-5) == "-5" | ||
|
||
test_str_int() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
def test_pow(): | ||
a: i32 | ||
a: f64 | ||
a = pow(2, 2) | ||
|
||
|
||
def test_pow_1(a: i32, b: i32) -> i32: | ||
res: i32 | ||
def test_pow_1(a: i32, b: i32) -> f64: | ||
res: f64 | ||
res = pow(a, b) | ||
return res | ||
|
||
def main0(): | ||
test_pow() | ||
c: i32 | ||
c: f64 | ||
c = test_pow_1(1, 2) | ||
|
||
main0() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(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 ())}) []) | ||
(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 (Real 8 []) 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 []))] [] (Real 8 []) () ()) ())] 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 (Real 8 []) 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 []))] [] (Real 8 []) (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 (Real 8 []) 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 (Real 8 []) 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)] [] (Real 8 []) () ()) ()) (= (Var 3 _lpython_return_variable) (Var 3 res) ()) (Return)] (Var 3 _lpython_return_variable) Source Public Implementation ())}) []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(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.)}) []) | ||
(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_bin () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_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.)}) []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(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.)}) []) | ||
(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_bool () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_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.)}) []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(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.)}) []) | ||
(TranslationUnit (SymbolTable 1 {_lfortran_main_program: (Subroutine (SymbolTable 19 {}) _lfortran_main_program [] [(SubroutineCall 1 test_float () [] ())] Source Public Implementation () .false. .false.), lpython_builtin: (IntrinsicModule lpython_builtin), main_program: (Program (SymbolTable 18 {}) main_program [] [(SubroutineCall 1 _lfortran_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 () [(ConstantInteger 34 (Integer 4 []))] [] (Real 8 []) (ConstantReal 34.000000 (Real 8 [])) ()) Eq (ConstantReal 34.000000 (Real 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 [])) ()) ()) (= (Var 2 i) (UnaryOp USub (ConstantInteger 4235 (Integer 4 [])) (Integer 4 []) (ConstantInteger -4235 (Integer 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 [])) ()) ()) (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.)}) []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.