예제 #1
0
def test_subscript_negative(build_node, namespace):
    node = build_node("foo[-1]")
    type_def = Int128Definition()

    namespace["foo"] = ArrayDefinition(type_def, 3)
    with pytest.raises(ArrayIndexException):
        get_possible_types_from_node(node)
예제 #2
0
def test_tuple_subscript(build_node, namespace):
    node = build_node("(foo, bar)[1]")

    namespace["foo"] = Int128Definition()
    namespace["bar"] = AddressDefinition()
    types_list = get_possible_types_from_node(node)

    assert types_list == [namespace["bar"]]
예제 #3
0
def test_tuple(build_node, namespace):
    node = build_node("(foo, bar)")

    namespace["foo"] = Int128Definition()
    namespace["bar"] = AddressDefinition()
    types_list = get_possible_types_from_node(node)

    assert types_list[0].value_type == [namespace["foo"], namespace["bar"]]
예제 #4
0
def test_attribute_not_member_type(build_node, namespace):
    node = build_node("foo.bar")
    with namespace.enter_scope():
        namespace["foo"] = Int128Definition()
        with pytest.raises(StructureException):
            get_possible_types_from_node(node)
예제 #5
0
def test_attribute_not_in_self(build_node, namespace):
    node = build_node("self.foo")
    with namespace.enter_scope():
        namespace["foo"] = Int128Definition()
        with pytest.raises(InvalidReference):
            get_possible_types_from_node(node)
예제 #6
0
def test_attribute_missing_self(build_node, namespace):
    node = build_node("foo")
    with namespace.enter_scope():
        namespace["self"].add_member("foo", Int128Definition())
        with pytest.raises(InvalidReference):
            get_possible_types_from_node(node)
예제 #7
0
def test_attribute(build_node, namespace):
    node = build_node("self.foo")
    type_def = Int128Definition()
    with namespace.enter_scope():
        namespace["self"].add_member("foo", type_def)
        assert get_possible_types_from_node(node) == [type_def]
예제 #8
0
def test_subscript(build_node, namespace):
    node = build_node("foo[1]")
    type_def = Int128Definition()

    namespace["foo"] = ArrayDefinition(type_def, 3)
    assert get_possible_types_from_node(node) == [type_def]
예제 #9
0
def test_name(build_node, namespace):
    node = build_node("foo")
    type_def = Int128Definition()
    namespace["foo"] = type_def

    assert get_possible_types_from_node(node) == [type_def]