def test_html_tags(): check_expr_type( """ div :foo "bar" span "Some Text" """, Tuple.typed(Markup, [ Symbol.typed(HTML_TAG_TYPE, 'div'), Keyword('foo'), String.typed(StringType, 'bar'), Tuple.typed(Markup, [ Symbol.typed(HTML_TAG_TYPE, 'span'), String.typed(StringType, 'Some Text'), ]), ]), )
def test_list(): foo_type = Func[[ListType[Union[IntType, StringType]]], IntType] check_expr_type( """ foo [1 2 3] """, Tuple.typed(IntType, [ Symbol.typed(foo_type, 'foo'), List.typed(ListType[Union[IntType, ]], [ Number.typed(IntType, 1), Number.typed(IntType, 2), Number.typed(IntType, 3), ]), ]), {'foo': foo_type}, ) check_expr_type( """ foo [1 2 "3"] """, Tuple.typed(IntType, [ Symbol.typed(foo_type, 'foo'), List.typed(ListType[Union[IntType, StringType]], [ Number.typed(IntType, 1), Number.typed(IntType, 2), String.typed(StringType, '3'), ]), ]), {'foo': foo_type}, ) with py.test.raises(TypeCheckError): check_expr('foo [1 2 "3"]', {'foo': Func[[ListType[IntType]], IntType]})