aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/animation-test.scm20
-rw-r--r--tests/entity-test.scm10
2 files changed, 25 insertions, 5 deletions
diff --git a/tests/animation-test.scm b/tests/animation-test.scm
index e12b35b..aaaba41 100644
--- a/tests/animation-test.scm
+++ b/tests/animation-test.scm
@@ -8,9 +8,19 @@
(test-begin "animation")
(test-group "frame->tile-id"
- (test-equal "first frame, frames (0)" 1 (frame->tile-id '(0) 0))
- (test-equal "wraps around" 1 (frame->tile-id '(0 1) 2))
- (test-equal "frame 1 of (27 28)" 29 (frame->tile-id '(27 28) 1)))
+ (test-group "tile IDs only"
+ (test-equal "first frame, frames (0)" 1 (frame->tile-id '(0) 0))
+ (test-equal "wraps around" 1 (frame->tile-id '(0 1) 2))
+ (test-equal "frame 1 of (27 28)" 29 (frame->tile-id '(27 28) 1)))
+ (test-group "tile IDs and durations"
+ (test-equal "first frame, frames (0)" 1 (frame->tile-id '((0 10)) 0))
+ (test-equal "wraps around" 1 (frame->tile-id '((0 10) (1 10)) 2))
+ (test-equal "frame 1 of (27 28)" 29 (frame->tile-id '((27 10) (28 10)) 1))))
+
+(test-group "frame->duration"
+ (test-equal "first frame, frames (0)" 100 (frame->duration '((0 100)) 0))
+ (test-equal "wraps around" 100 (frame->duration '((0 100) (1 200)) 2))
+ (test-equal "frame 1 of (27 28)" 200 (frame->duration '((27 100) (28 200)) 1)))
(test-group "set-animation"
(let ((entity (list #:type 'player #:anim-name 'idle #:anim-frame 5 #:anim-tick 8)))
@@ -21,12 +31,12 @@
(test-equal "resets tick" 0 (entity-ref switched #:anim-tick)))))
(test-group "animate-entity"
- (let* ((anims '((walk . (#:frames (0 1) #:duration 4))))
+ (let* ((anims '((#:name walk #:frames (0 1) #:duration 4)))
(entity (list #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 0))
(stepped (animate-entity entity anims)))
(test-equal "increments tick" 1 (entity-ref stepped #:anim-tick))
(test-equal "sets tile-id on first tick" 1 (entity-ref stepped #:tile-id)))
- (let* ((anims '((walk . (#:frames (0 1) #:duration 2))))
+ (let* ((anims '((#:name walk #:frames (0 1) #:duration 2)))
(entity (list #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 1))
(advanced (animate-entity entity anims)))
(test-equal "advances frame when tick reaches duration" 1 (entity-ref advanced #:anim-frame))
diff --git a/tests/entity-test.scm b/tests/entity-test.scm
index 270555c..9c7607c 100644
--- a/tests/entity-test.scm
+++ b/tests/entity-test.scm
@@ -79,6 +79,16 @@
(test-equal "existing key untouched" 10 (entity-ref e #:x))
(test-equal "list grows by one pair" 4 (length e)))))
+(test-group "entity-set-many"
+ (test-group "Set multiple entities with lists"
+ (let ((e (entity-set-many '(#:x 10 #:y 20) '((#:x 15) (#:y 25)))))
+ (test-equal "value x updated" (entity-ref e #:x) 15)
+ (test-equal "value y updated" (entity-ref e #:y) 25)))
+ (test-group "Set multiple entities with cons"
+ (let ((e (entity-set-many '(#:x 10 #:y 20) (list (cons #:x 15) (cons #:y 25)))))
+ (test-equal "value x updated" (entity-ref e #:x) 15)
+ (test-equal "value y updated" (entity-ref e #:y) 25))))
+
;; Test: entity-update applies transformations
(test-group "entity-update"
(test-group "transform existing value"