Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Apr 4, 2023
1 parent 09a0b32 commit 1dd7a6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function test_abstractcomponent_interface(::Type{T}) where {T<:AbstractComponent

@test c[Entity(2)] isa TestCompData

@test entity(c, 1) isa Entity
@test entity(c, 1) isa EntityState{Tuple{T{TestCompData}}}
@test pop!(c, Entity(2)) == TestCompData(1)
@test pop!(c) == EntityState(Entity(1), TestCompData(1))
@test isempty(c)
Expand Down
18 changes: 7 additions & 11 deletions src/entity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ function Entity(m::AbstractLedger, datas...)
return e
end

function entity(c::AbstractComponent, i::Integer)
return Entity(c.indices.packed[i])
end

"""
last_entity(c::AbstractComponent)
Retrieves the last [`Entity`](@ref) in `c`.
"""
last_entity(c::AbstractComponent) = entity(c, length(c))

function Entity(m::AbstractLedger, parent::Entity, datas...)
e = Entity(m)
for d in datas
Expand Down Expand Up @@ -198,3 +187,10 @@ function entity(c::AbstractComponent, i::Integer)
return EntityState(Entity(c.indices.packed[i]), c)
end

"""
last_entity(c::AbstractComponent)
Retrieves the last [`Entity`](@ref) in `c`.
"""
last_entity(c::AbstractComponent) = entity(c, length(c))

0 comments on commit 1dd7a6c

Please sign in to comment.