Skip to content

Commit 338420b

Browse files
alexisthedevtheosotr
authored andcommitted
Change default is_subtype function for builtin types. Add unit tests for typescript
1 parent f3ee755 commit 338420b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/test_typescript.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def test_type_alias_with_literals2():
2727
assert number_alias.is_subtype(number_lit)
2828

2929
def test_union_types_simple():
30-
print('click click click... I\'m in.')
3130
union_1 = tst.UnionType([tst.NumberType(), tst.BooleanType()])
3231

3332
bar_lit = tst.StringLiteralType("bar")
@@ -39,3 +38,22 @@ def test_union_types_simple():
3938
assert not union_2.is_assignable(union_1)
4039
assert union_3.is_assignable(union_1)
4140
assert union_1.is_assignable(union_3)
41+
42+
43+
def test_union_type_assign():
44+
union = tst.UnionType([tst.StringType(), tst.NumberType(), tst.BooleanType(), tst.ObjectType()])
45+
foo = tst.StringType()
46+
47+
assert len(union.types) == 4
48+
assert not union.is_assignable(foo)
49+
assert foo.is_assignable(union)
50+
51+
52+
def test_union_type_param():
53+
union1 = tst.UnionType([tst.NumberType(), tst.NullType()])
54+
union2 = tst.UnionType([tst.StringLiteralType("foo"), tst.NumberType()])
55+
t_param = tp.TypeParameter("T", bound=union2)
56+
57+
assert not union2.is_subtype(union1)
58+
assert not union1.is_subtype(t_param)
59+
assert not t_param.is_subtype(union1)

0 commit comments

Comments
 (0)