def test_optimization_multiple_list_comprehensions(): from typing import List from tmppy import Type def f(l0: List[Type]): l1 = [Type.pointer(x) for x in l0] l2 = [Type.const(x) for x in l1] return l2 assert f([Type('int'), Type('float')]) == [Type.const(Type.pointer(Type('int'))), Type.const(Type.pointer(Type('float')))]
def f(t: Type): return match(t)(lambda T: { Type.const(T): T, T: Type('double'), })
def test_const_type_expr_as_match_expr_matched_success(): from tmppy import Type, match def f(t: Type): return match(t)(lambda T: { Type.const(T): T, T: Type('double'), }) assert f(Type.const(Type('int'))) == Type('int')
def f(l0: List[Type]): l1 = [Type.pointer(x) for x in l0] l2 = [Type.const(x) for x in l1] return l2
def test_const_type_literal_success(): from tmppy import Type assert Type.const(Type('int')) == Type.const(Type('int'))
def f(x: bool): return Type.const( 5 ) # error: The argument passed to Type.const\(\) should have type Type, but was: int
def f(x: bool): return Type.const( 'x', 'y') # error: Type.const\(\) takes 1 argument. Got: 2
def f(x: bool): return Type.const( x=1 ) # error: Keyword arguments are not supported in Type.const\(\)