File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
import src .ir .typescript_types as tst
2
2
import src .ir .typescript_ast as ts_ast
3
+ import src .ir .types as tp
3
4
4
5
def test_type_alias_with_literals ():
5
6
string_alias = ts_ast .TypeAliasDeclaration ("Foo" , tst .StringType ()).get_type ()
@@ -24,3 +25,17 @@ def test_type_alias_with_literals2():
24
25
assert number_lit .is_subtype (number_alias )
25
26
assert string_alias .is_subtype (string_lit )
26
27
assert number_alias .is_subtype (number_lit )
28
+
29
+ def test_union_types_simple ():
30
+ print ('click click click... I\' m in.' )
31
+ union_1 = tst .UnionType ([tst .NumberType (), tst .BooleanType ()])
32
+
33
+ bar_lit = tst .StringLiteralType ("bar" )
34
+ union_2 = tst .UnionType ([tst .BooleanType (), bar_lit ])
35
+
36
+ union_3 = tst .UnionType ([tst .BooleanType (), tst .NumberType ()])
37
+
38
+ assert not union_1 .is_assignable (union_2 )
39
+ assert not union_2 .is_assignable (union_1 )
40
+ assert union_3 .is_assignable (union_1 )
41
+ assert union_1 .is_assignable (union_3 )
You can’t perform that action at this time.
0 commit comments