37 lines
1.3 KiB
Scheme
37 lines
1.3 KiB
Scheme
(module (test engine) ()
|
|
(import scheme
|
|
(chicken base)
|
|
(engine core)
|
|
(srfi 69)
|
|
(srfi 78)
|
|
(srfi 99))
|
|
|
|
(define-record-type <point> (make-point x y) point? (x point-x) (y point-y))
|
|
|
|
;; Entity addition and world state modification
|
|
(check (hash-table-size world) => 0) ;; World state starts empty
|
|
(check (hash-table-size component-sets) => 0)
|
|
|
|
(create-named-entity 'ball (make-point 1 1))
|
|
(check (hash-table-size world) => 0) ;; World state empty before next frame
|
|
(check (hash-table-size component-sets) => 0)
|
|
|
|
(resolve-queues) ;; TODO: swap this for (next-frame) and remove (resolve-queues) once we have a full game loop setup
|
|
(check (hash-table-size world) => 1) ;; World state updates after next frame
|
|
(check (hash-table-size component-sets) => 1)
|
|
(check (hash-table-exists? world 'ball) => #t)
|
|
(check (hash-table-exists? component-sets '<point>) => #t)
|
|
|
|
(clear-world)
|
|
(check (hash-table-size world) => 1) ;; World state does not immediately clear
|
|
|
|
(resolve-queues)
|
|
(check (hash-table-size world) => 0) ;; World state is empty after clear
|
|
(check (hash-table-size component-sets) => 1) ;; Component-sets doesn't clear
|
|
|
|
(create-named-entity 'ball (make-point 1 1))
|
|
(resolve-queues)
|
|
(remove-entity 'ball)
|
|
(resolve-queues)
|
|
(check (hash-table-size world) => 0) ;; Entity is properly removed
|
|
)
|