Fix entity unit tests
This commit is contained in:
parent
e0b55cd11c
commit
580bcd9799
3 changed files with 50 additions and 44 deletions
2
stoe.asd
2
stoe.asd
|
|
@ -57,7 +57,7 @@
|
|||
:in-order-to ((test-op (load-op stoe/test))))
|
||||
|
||||
(defsystem stoe/test
|
||||
:depends-on ("prove" "stoe/test/all"))
|
||||
:depends-on ("prove" "stoe" "stoe/test/all"))
|
||||
|
||||
(register-system-packages "stoe/maths/all" '(:maths))
|
||||
(register-system-packages "stoe/core/all" '(:core))
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
(uiop:define-package :stoe/test/all
|
||||
(:nicknames :test)
|
||||
(:use-reexport
|
||||
:stoe/test/job-utils
|
||||
:stoe/test/jobs
|
||||
:stoe/test/resources
|
||||
;; :stoe/test/job-utils
|
||||
;; :stoe/test/jobs
|
||||
;; :stoe/test/resources
|
||||
:stoe/test/entity))
|
||||
|
|
|
|||
|
|
@ -9,65 +9,71 @@
|
|||
:stoe/core/entity))
|
||||
(in-package :stoe/test/entity)
|
||||
|
||||
(clrhash stoe/core/entity::*component-subclasses*)
|
||||
(clrhash stoe/core/entity::*component-dependencies*)
|
||||
(eval-when (:compile-toplevel)
|
||||
(defparameter old-component-subclasses stoe/core/entity::*component-subclasses*)
|
||||
(defparameter old-component-dependencies stoe/core/entity::*component-dependencies*)
|
||||
(clrhash stoe/core/entity::*component-subclasses*)
|
||||
(stoe/core/entity::register-component-subclasses 'component nil)
|
||||
(clrhash stoe/core/entity::*component-dependencies*))
|
||||
|
||||
(plan 18)
|
||||
(eval-when (:compile-toplevel)
|
||||
(plan 18)
|
||||
(diag "Define components"))
|
||||
|
||||
(diag "Define a base component.")
|
||||
(defcomponent comp-base1 ()
|
||||
())
|
||||
|
||||
(is (stoe/core/entity::component-subclasses 'component) '(comp-base1)
|
||||
"1 component subclass defined.")
|
||||
(eval-when (:compile-toplevel)
|
||||
(is (stoe/core/entity::component-subclasses 'component) '(comp-base1)
|
||||
"component subclass defined."))
|
||||
|
||||
(diag "Define another base component.")
|
||||
(defcomponent comp-base2 (component)
|
||||
())
|
||||
|
||||
(is (stoe/core/entity::component-subclasses 'component) '(comp-base2 comp-base1)
|
||||
"2 component subclasses defined.")
|
||||
(eval-when (:compile-toplevel)
|
||||
(is (stoe/core/entity::component-subclasses 'component) '(comp-base2 comp-base1)
|
||||
"component subclasses defined."))
|
||||
|
||||
(diag "Define a derived component.")
|
||||
(defcomponent comp-derived1 (comp-base1)
|
||||
())
|
||||
|
||||
(is (stoe/core/entity::component-subclasses 'component)
|
||||
'(comp-derived1 comp-base2 comp-base1)
|
||||
"3 component subclasses defined.")
|
||||
(eval-when (:compile-toplevel)
|
||||
(is (stoe/core/entity::component-subclasses 'component)
|
||||
'(comp-derived1 comp-base2 comp-base1)
|
||||
"component subclasses defined.")
|
||||
|
||||
(is (stoe/core/entity::component-subclasses 'comp-base1) '(comp-derived1)
|
||||
"1 comp-base1 subclass defined.")
|
||||
(is (stoe/core/entity::component-subclasses 'comp-base1) '(comp-derived1)
|
||||
"comp-base1 subclass defined."))
|
||||
|
||||
(diag "Define another derived component with dependency.")
|
||||
(defcomponent comp-derived2 (comp-base2)
|
||||
()
|
||||
(:needs comp-derived1))
|
||||
|
||||
(is (stoe/core/entity::component-subclasses 'component)
|
||||
'(comp-derived2 comp-derived1 comp-base2 comp-base1)
|
||||
"4 component subclasses defined.")
|
||||
(eval-when (:compile-toplevel)
|
||||
(is (stoe/core/entity::component-subclasses 'component)
|
||||
'(comp-derived2 comp-derived1 comp-base2 comp-base1)
|
||||
"component subclasses defined.")
|
||||
|
||||
(is (stoe/core/entity::component-dependencies 'comp-derived2)
|
||||
'(comp-derived1)
|
||||
"1 comp-derived2 dependency.")
|
||||
(is (stoe/core/entity::component-dependencies 'comp-derived2)
|
||||
'(comp-derived1)
|
||||
"comp-derived2 dependency."))
|
||||
|
||||
(diag "Redefine a component")
|
||||
(defcomponent comp-derived1 ()
|
||||
()
|
||||
(:needs comp-derived2))
|
||||
|
||||
(is (stoe/core/entity::component-subclasses 'component)
|
||||
'(comp-derived2 comp-derived1 comp-base2 comp-base1)
|
||||
"4 component subclasses defined.")
|
||||
(eval-when (:compile-toplevel)
|
||||
(is (stoe/core/entity::component-subclasses 'component)
|
||||
'(comp-derived2 comp-derived1 comp-base2 comp-base1)
|
||||
"component subclasses defined.")
|
||||
|
||||
(is (stoe/core/entity::component-dependencies 'comp-derived2)
|
||||
'(comp-derived1)
|
||||
"1 comp-derived2 dependency.")
|
||||
(is (stoe/core/entity::component-dependencies 'comp-derived2)
|
||||
'(comp-derived1)
|
||||
"comp-derived2 dependency.")
|
||||
|
||||
(is (stoe/core/entity::component-dependencies 'comp-derived1)
|
||||
'(comp-derived2)
|
||||
"1 comp-derived1 dependency.")
|
||||
(is (stoe/core/entity::component-dependencies 'comp-derived1)
|
||||
'(comp-derived2)
|
||||
"comp-derived1 dependency."))
|
||||
|
||||
(defcomponent comp1 ()
|
||||
())
|
||||
|
|
@ -85,14 +91,14 @@
|
|||
comp-base1))
|
||||
|
||||
(is (object-id ent2) 1 "Object ID 1")
|
||||
(is (length (all-components ent2)) 1 "all-components 1")
|
||||
(is (length (all-components ent2)) 1 "all-components 2")
|
||||
(is (length (components ent2 'comp-base1)) 1 "get-component comp-base1")
|
||||
|
||||
(defparameter ent3 (create-entity "ent3"
|
||||
comp-derived2))
|
||||
|
||||
(is (object-id ent3) 2 "Object ID 2")
|
||||
(is (length (all-components ent3)) 2 "all-components 2")
|
||||
(is (length (all-components ent3)) 2 "all-components 3")
|
||||
(is (length (components ent3 'comp-derived1)) 1 "get-component comp-derived1")
|
||||
(is (length (components ent3 'comp-derived2)) 1 "get-component comp-derived2")
|
||||
|
||||
|
|
@ -101,14 +107,14 @@
|
|||
comp2
|
||||
comp3))
|
||||
|
||||
(is (length (all-components ent4)) 3 "all-components 3")
|
||||
(is (length (all-components ent4)) 3 "all-components 4")
|
||||
|
||||
(defesystem render-mesh (mesh-component)
|
||||
()
|
||||
(:update (component)))
|
||||
;; (defesystem render-mesh (mesh-component)
|
||||
;; ()
|
||||
;; ())
|
||||
|
||||
(defmethod esystem-update ((system render-mesh) &key component)
|
||||
(render component))
|
||||
;; (defmethod esystem-update ((system render-mesh) &key component)
|
||||
;; (render component))
|
||||
|
||||
(destroy-entity ent1)
|
||||
(destroy-entity ent2)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue