Exemplo n.º 1
0
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",
    )
Exemplo n.º 2
0
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",
    )
Exemplo n.º 3
0
def test_wrong_type_return():
    neg_test(wrong_type_return_py, wrong_type_return_exception)
Exemplo n.º 4
0
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'''
    )
Exemplo n.º 5
0
def test_power_op():
    neg_test('''a=5**2''', "In line 1: [5] Unsupported binary operator")
Exemplo n.º 6
0
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.",
    )
Exemplo n.º 7
0
def test_no_exception_else_clause():
    try:
        neg_test("a = 5", "nothing")
    except AssertionError:
        pass
Exemplo n.º 8
0
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.",
    )
Exemplo n.º 9
0
def test_empty_list():
    neg_test("empty = []", "In line 1: [[]] Empty lists not supported yet")
Exemplo n.º 10
0
def test_unhomogeneous_tuple():
    neg_test(
        "tup = (2.4, 5)",
        "In line 1: [(2.4, 5)] Only homogeneous lists and tuples are supported.",
    )
Exemplo n.º 11
0
def test_unhomogeneous_list():
    neg_test(
        "lst = [3, 4.5]",
        "In line 1: [[3, 4.5]] Only homogeneous lists and tuples are supported.",
    )