Add more tests
This commit is contained in:
parent
09fd451b73
commit
f72e0e1ff5
2 changed files with 51 additions and 1 deletions
|
|
@ -227,7 +227,7 @@
|
|||
(sort-systems))
|
||||
|
||||
;; System creation/removal interface
|
||||
(export add-system remove-system)
|
||||
(export add-system remove-system clear-systems)
|
||||
|
||||
;; Add a system to the state processing and return its name
|
||||
(define (add-system system)
|
||||
|
|
@ -273,6 +273,8 @@
|
|||
(hash-table-set! event-buses name (make-hash-table))
|
||||
name)))
|
||||
|
||||
(register-event-bus 'input)
|
||||
|
||||
;; Remove an event bus
|
||||
(define (remove-event-bus name)
|
||||
(assert (symbol? name))
|
||||
|
|
|
|||
|
|
@ -34,4 +34,52 @@
|
|||
(remove-entity 'ball)
|
||||
(resolve-queues)
|
||||
(check (hash-table-size world) => 0) ;; Entity is properly removed
|
||||
|
||||
;; System addition and state modification
|
||||
(check (length systems) => 0) ;; Systems list starts empty
|
||||
|
||||
(define sys-1 (make-system 'foo '3d 0 '() void))
|
||||
(define sys-2 (make-system 'bar '2d 1 '() void))
|
||||
(add-system sys-1)
|
||||
(check (length systems) => 0) ;; Systems list is not immediately updated
|
||||
|
||||
(resolve-queues)
|
||||
(check (length systems) => 1) ;; Systems list updates
|
||||
|
||||
(add-system sys-2)
|
||||
(resolve-queues)
|
||||
(check (length systems) => 2) ;; Systems list updates
|
||||
(check (system-name (car systems)) => 'foo) ;; Foo is sorted before bar
|
||||
|
||||
(set-system-priority! sys-1 2)
|
||||
(resolve-queues)
|
||||
(check (system-name (car systems)) => 'bar) ;; Bar is sorted earlier after a priority change
|
||||
|
||||
(remove-system 'foo)
|
||||
(check (length systems) => 2) ;; Systems list does not automatically update
|
||||
|
||||
(resolve-queues)
|
||||
(check (length systems) => 1) ;; Systems list updates after resolution
|
||||
|
||||
(clear-systems)
|
||||
(resolve-queues)
|
||||
(check (length systems) => 0) ;; Systems list clears
|
||||
|
||||
;; Event bus creation and events
|
||||
(check (hash-table-size event-buses) => 1) ;; Input bus already exists
|
||||
|
||||
(remove-event-bus 'input)
|
||||
(check (hash-table-size event-buses) => 0) ;; Input bus is removed
|
||||
|
||||
(register-event-bus 'foo)
|
||||
(check (hash-table-size event-buses) => 1) ;; Event bus registered
|
||||
|
||||
(push-event 'foo 'bar (make-point 1 1))
|
||||
(check (hash-table-size (fetch-event-bus 'foo)) => 1) ;; Event is created
|
||||
|
||||
(check (point-x (peek-event 'foo 'bar)) => 1) ;; Event is peaked
|
||||
(check (hash-table-size (fetch-event-bus 'foo)) => 1) ;; Event still exists
|
||||
|
||||
(check (point-x (pop-event 'foo 'bar)) => 1) ;; Event is popped
|
||||
(check (hash-table-size (fetch-event-bus 'foo)) => 0) ;; Event is removed exists
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue