# Path: pycket/impersonators/hidden_classes/base.py
# class W_ImpPropertyDescriptor(values.W_Object):
#     errorname = "chaperone-property"
#     _immutable_fields_ = ["name"]
#     def __init__(self, name):
#         if we_are_translated():
#             assert name is not None
#         self.name = name
#     def tostring(self):
#         return "#<chaperone-property>"


import pytest
    import gc
    import gc
    import gc
    import gc
from pycket.hidden_classes                    import make_map_type, make_caching_map_type
from pycket.impersonators.hidden_classes.base import W_ImpPropertyDescriptor
def test_caching_map():
    empty = make_caching_map_type("__getitem__", int).EMPTY
    map = empty
    for i in range(1, 4):
        gc.collect()
        map = map.add_dynamic_attribute(i)
    assert map.get_dynamic_index(1) == 0
    assert map.get_dynamic_index(2) == 1
    assert map.get_dynamic_index(3) == 2
    assert map.get_dynamic_index(4) == -1
    assert map.storage_size() == 3

    map2 = empty
    for i in range(1, 4):
        gc.collect()
        map2 = map2.add_dynamic_attribute(i)
    assert map is map2

    assert empty.dynamic_submaps.get(1) is not None
    assert empty.dynamic_submaps.get(1).dynamic_submaps.get(2) is not None
    assert empty.dynamic_submaps.get(1).dynamic_submaps.get(2).dynamic_submaps.get(3) is not None

    map_ = empty.add_dynamic_attribute(2).add_dynamic_attribute(1).add_dynamic_attribute(3)
    assert map_ is not map
    assert map_.get_dynamic_index(2) == 0
    assert map_.get_dynamic_index(1) == 1
    assert map_.get_dynamic_index(3) == 2

def test_caching_map_descriptors():
    empty = make_caching_map_type("__getitem__", W_ImpPropertyDescriptor).EMPTY

# Path: pycket/impersonators/hidden_classes/base.py
# class W_ImpPropertyDescriptor(values.W_Object):
#     errorname = "chaperone-property"
#     _immutable_fields_ = ["name"]
#     def __init__(self, name):
#         if we_are_translated():
#             assert name is not None
#         self.name = name
#     def tostring(self):
#         return "#<chaperone-property>"


# Path: pycket/test/test_hidden_classes.py
import pytest
    import gc
    import gc
    import gc
    import gc
from pycket.hidden_classes                    import make_map_type, make_caching_map_type
from pycket.impersonators.hidden_classes.base import W_ImpPropertyDescriptor

def test_caching_map():
    empty = make_caching_map_type("__getitem__", int).EMPTY
    map = empty
    for i in range(1, 4):
        gc.collect()
        map = map.add_dynamic_attribute(i)
    assert map.get_dynamic_index(1) == 0
    assert map.get_dynamic_index(2) == 1
    assert map.get_dynamic_index(3) == 2
    assert map.get_dynamic_index(4) == -1
    assert map.storage_size() == 3

    map2 = empty
    for i in range(1, 4):
        gc.collect()
        map2 = map2.add_dynamic_attribute(i)
    assert map is map2

    assert empty.dynamic_submaps.get(1) is not None
    assert empty.dynamic_submaps.get(1).dynamic_submaps.get(2) is not None
    assert empty.dynamic_submaps.get(1).dynamic_submaps.get(2).dynamic_submaps.get(3) is not None

    map_ = empty.add_dynamic_attribute(2).add_dynamic_attribute(1).add_dynamic_attribute(3)
    assert map_ is not map
    assert map_.get_dynamic_index(2) == 0
    assert map_.get_dynamic_index(1) == 1
    assert map_.get_dynamic_index(3) == 2

def test_caching_map_descriptors():
    empty = make_caching_map_type("__getitem__", W_ImpPropertyDescriptor).EMPTY

    a = W_ImpPropertyDescriptor("a")