Skip to content

Commit

Permalink
test for overload with attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit-create committed Mar 18, 2022
1 parent 31307dc commit 97c85db
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions integration_tests/overload_testing2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from ltypes import i32, overload

@overload
def foo2(a: i32, b: i32) -> i32:
return a + b

@overload
def foo2(a: i32) -> i32:
return a**3

@overload
def foo2(a: str) -> str:
return "lpython-super-fun-" + a

@overload
def test2(a: i32) -> i32:
return a + 30

@overload
def test2(a: bool) -> i32:
if a:
return 30
return -30
6 changes: 6 additions & 0 deletions integration_tests/test_generics_01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from overload_testing import foo, test
from ltypes import overload, i32
import overload_testing2

@overload
def foo1(a: i32, b: i32) -> i32:
Expand Down Expand Up @@ -27,13 +28,18 @@ def test1(a: bool) -> i32:
def check():
assert foo(2) == 4
assert foo1(2) == 16
assert overload_testing2.foo2(2) == 8
assert foo(2, 10) == 20
assert foo1(2, 10) == -8
assert overload_testing2.foo2(2, 10) == 12
assert foo("hello") == "lpython-hello"
assert foo1("hello") == "lpython-is-fun-hello"
assert overload_testing2.foo2("hello") == "lpython-super-fun-hello"
assert test(10) == 20
assert test1(10) == 30
assert overload_testing2.test2(10) == 40
assert test(False) == -test(True) and test(True) == 10
assert test1(False) == -test1(True) and test1(True) == 20
assert overload_testing2.test2(True) == 30

check()

0 comments on commit 97c85db

Please sign in to comment.