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)
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"]]
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"]]
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)
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)
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)
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]
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]
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]