# Path: roglick/engine/ecs/base.py
# class Entity(object):
#     """An Entity is really little more than a lookup key for Components"""
#     __slots__ = ("_eid",)
# 
#     def __init__(self, eid):
#         self._eid = eid
# 
#     def __repr__(self):
#         return "{name}({eid})".format(
#                 name=type(self).__name__,
#                 eid=self._eid)
# 
#     def __hash__(self):
#         return self._eid
# 
#     def __eq__(self, rhs):
#         return hash(self) == hash(rhs)


from roglick.engine.ecs import Entity

    # Different objects...
    assert id(e1) != id(e2)
    # ...but same Entity
    assert e1 == e2

def test_entity_unequality():
    e1 = Entity(1)
    e2 = Entity(2)

    # Different objects...
    assert id(e1) != id(e2)
    # ...and different Entities
    assert e1 != e2

def test_entity_dict_index():
    """Test that our Entity object can be used for dict keys

    By default, user-created objects are hashed based on id, meaning that no
    two different objects will ever reference the same data if used as dict
    keys. Therefore, if we can correctly store and retrieve data using
    different objects but which are logically the same, then we know that our
    overridden __hash__ method is working correctly and properly enabled dict
    access.
    """
    data = {}
    for x in range(10):
        data[Entity(x)] = x

    for x in range(10):

# Path: roglick/engine/ecs/base.py
# class Entity(object):
#     """An Entity is really little more than a lookup key for Components"""
#     __slots__ = ("_eid",)
# 
#     def __init__(self, eid):
#         self._eid = eid
# 
#     def __repr__(self):
#         return "{name}({eid})".format(
#                 name=type(self).__name__,
#                 eid=self._eid)
# 
#     def __hash__(self):
#         return self._eid
# 
#     def __eq__(self, rhs):
#         return hash(self) == hash(rhs)


# Path: test/engine/ecs/test_entity.py
from roglick.engine.ecs import Entity


    # Different objects...
    assert id(e1) != id(e2)
    # ...but same Entity
    assert e1 == e2

def test_entity_unequality():
    e1 = Entity(1)
    e2 = Entity(2)

    # Different objects...
    assert id(e1) != id(e2)
    # ...and different Entities
    assert e1 != e2

def test_entity_dict_index():
    """Test that our Entity object can be used for dict keys

    By default, user-created objects are hashed based on id, meaning that no
    two different objects will ever reference the same data if used as dict
    keys. Therefore, if we can correctly store and retrieve data using
    different objects but which are logically the same, then we know that our
    overridden __hash__ method is working correctly and properly enabled dict
    access.
    """
    data = {}
    for x in range(10):
        data[Entity(x)] = x

    for x in range(10):

        assert data[Entity(x)] == x