def test_meta_remove_slot_shift_map_pointers(): first = PrimitiveStrObject("first") second = PrimitiveStrObject("second") third = PrimitiveStrObject("third") o = Object() assert not o._slot_values o.meta_add_slot("first", first) o.meta_add_slot("second", second) o.meta_add_slot("third", third) assert o.get_slot("first") is first assert o.get_slot("second") is second assert o.get_slot("third") is third o.meta_remove_slot("first") assert len(o._slot_values) == 2 assert len(o.map._slots) == 2 assert o.map._slots["second"] == 0 assert o.map._slots["third"] == 1 assert o.get_slot("first") is None assert o.get_slot("second") == second assert o.get_slot("third") == third
def test_meta_remove_slot(): o = Object() assert not o._slot_values o.meta_add_slot("test", Object()) assert o._slot_values assert "test" in o.map._slots o.meta_remove_slot("test") assert not o._slot_values assert "test" not in o.map._slots
def test_meta_remove_missing_slot(): o = Object() o.meta_add_slot("test", Object()) assert not o.meta_remove_slot("x")