Ejemplo 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",
    )
Ejemplo 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",
    )
Ejemplo n.º 3
0
def test_wrong_type_return():
    neg_test(wrong_type_return_py, wrong_type_return_exception)
Ejemplo 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'''
    )
Ejemplo n.º 5
0
def test_power_op():
    neg_test('''a=5**2''', "In line 1: [5] Unsupported binary operator")
Ejemplo 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.",
    )
Ejemplo n.º 7
0
def test_no_exception_else_clause():
    try:
        neg_test("a = 5", "nothing")
    except AssertionError:
        pass
Ejemplo 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.",
    )
Ejemplo n.º 9
0
def test_empty_list():
    neg_test("empty = []", "In line 1: [[]] Empty lists not supported yet")
Ejemplo 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.",
    )
Ejemplo 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.",
    )