@@ -27,7 +27,6 @@ def test_type_alias_with_literals2():
27
27
assert number_alias .is_subtype (number_lit )
28
28
29
29
def test_union_types_simple ():
30
- print ('click click click... I\' m in.' )
31
30
union_1 = tst .UnionType ([tst .NumberType (), tst .BooleanType ()])
32
31
33
32
bar_lit = tst .StringLiteralType ("bar" )
@@ -39,3 +38,22 @@ def test_union_types_simple():
39
38
assert not union_2 .is_assignable (union_1 )
40
39
assert union_3 .is_assignable (union_1 )
41
40
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