File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
from overload_testing import foo , test
2
- from ltypes import overload , i32
2
+ from ltypes import overload , i32 , i64
3
3
import overload_testing2
4
4
5
+
5
6
@overload
6
7
def foo1 (a : i32 , b : i32 ) -> i32 :
7
8
return a - b
@@ -14,6 +15,7 @@ def foo1(a: i32) -> i32:
14
15
def foo1 (a : str ) -> str :
15
16
return "lpython-is-fun-" + a
16
17
18
+
17
19
@overload
18
20
def test1 (a : i32 ) -> i32 :
19
21
return a + 20
@@ -25,6 +27,19 @@ def test1(a: bool) -> i32:
25
27
return - 20
26
28
27
29
30
+ @overload
31
+ def add (a : i32 ):
32
+ print (a )
33
+
34
+ @overload
35
+ def add (a : i32 , b : i32 ):
36
+ print (a + b )
37
+
38
+ @overload
39
+ def add (a : i32 , b : i64 ):
40
+ print (a + b )
41
+
42
+
28
43
def check ():
29
44
assert foo (2 ) == 4
30
45
assert foo1 (2 ) == 16
@@ -41,5 +56,11 @@ def check():
41
56
assert test (False ) == - test (True ) and test (True ) == 10
42
57
assert test1 (False ) == - test1 (True ) and test1 (True ) == 20
43
58
assert overload_testing2 .test2 (True ) == 30
59
+ # We are testing the subroutine using print to test it actually works
60
+ add (1 , 2 )
61
+ add (3 )
62
+ i : i64
63
+ i = 10
64
+ add (2 , i )
44
65
45
66
check ()
You can’t perform that action at this time.
0 commit comments