Skip to content

Commit 8611737

Browse files
committed
Adds more tests
1 parent 93965d0 commit 8611737

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
- case: typeclass_concrete_generic
2+
disable_cache: false
3+
main: |
4+
from typing import List
5+
from classes import typeclass
6+
7+
class SomeDelegate(object):
8+
...
9+
10+
@typeclass
11+
def some(instance) -> int:
12+
...
13+
14+
@some.instance(List[int], delegate=SomeDelegate)
15+
def _some_list_int(instance: List[int]) -> int:
16+
...
17+
18+
some([1, 2, 3])
19+
some([])
20+
some(['a']) # E: List item 0 has incompatible type "str"; expected "int"
21+
22+
23+
- case: typeclass_concrete_generic_delegate_and_protocol
24+
disable_cache: false
25+
main: |
26+
from typing import List
27+
from classes import typeclass
28+
29+
class SomeDelegate(object):
30+
...
31+
32+
@typeclass
33+
def some(instance) -> int:
34+
...
35+
36+
@some.instance(List[int], delegate=SomeDelegate, is_protocol=True)
37+
def _some_list_int(instance: List[int]) -> int:
38+
...
39+
out: |
40+
main:11: error: Both "is_protocol" and "delegate" arguments passed, they are exclusive
41+
main:11: error: Regular types must be passed with "is_protocol=False"
42+
43+
44+
- case: typeclass_delegate_with_regular_type
45+
disable_cache: false
46+
main: |
47+
from classes import typeclass
48+
49+
class SomeDelegate(object):
50+
...
51+
52+
@typeclass
53+
def some(instance) -> int:
54+
...
55+
56+
@some.instance(int, delegate=SomeDelegate)
57+
def _some_int(instance: int) -> int:
58+
...
59+
60+
some(1)

0 commit comments

Comments
 (0)