def test_dual_annotation_diff_type(): neg_test( """ var : int = 0 var : float = 4.4 """, "In line 3: [var : float = 4.4] Variable var annotated as being of type float but it is already known as being of type int", )
def test_dual_annotation_same_type(): neg_test( """ var : int = 0 var : int = 4 """, "In line 3: [var : int = 4] Variable var is already known in scope", )
def test_wrong_type_return(): neg_test(wrong_type_return_py, wrong_type_return_exception)
def test_ifelse_expr_diff_types(): neg_test( '''b=4 a=5 if b == 4 else "3"''', '''In line 2: [a=5 if b == 4 else "3"] Using if-expressions can only support same types''' )
def test_power_op(): neg_test('''a=5**2''', "In line 1: [5] Unsupported binary operator")
def test_assign_wrong_type(): neg_test( "a = 'foo'\na = 6", expected_message="In line 2: [a = 6] Assignment to a new different type is not supported.", )
def test_no_exception_else_clause(): try: neg_test("a = 5", "nothing") except AssertionError: pass
def test_same_type_on_binop(): neg_test( "val = 3.3 + 5", "In line 1: [3.3 + 5] We do not support different types on binary operators.", )
def test_empty_list(): neg_test("empty = []", "In line 1: [[]] Empty lists not supported yet")
def test_unhomogeneous_tuple(): neg_test( "tup = (2.4, 5)", "In line 1: [(2.4, 5)] Only homogeneous lists and tuples are supported.", )
def test_unhomogeneous_list(): neg_test( "lst = [3, 4.5]", "In line 1: [[3, 4.5]] Only homogeneous lists and tuples are supported.", )