aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/animation-test.scm30
1 files changed, 20 insertions, 10 deletions
diff --git a/tests/animation-test.scm b/tests/animation-test.scm
index 00dd217..7ee634c 100644
--- a/tests/animation-test.scm
+++ b/tests/animation-test.scm
@@ -22,13 +22,22 @@
(test "wraps around" 0 (frame->tile-id '((0 10) (1 10)) 2))
(test "frame 1 of (27 28)" 28 (frame->tile-id '((27 10) (28 10)) 1))))
-(test-group "frame->duration"
- (test "first frame, frames (0)" 100 (frame->duration '((#:frames . ((0 100))))
+(test-group "animation-frame-duration"
+ (test "first frame, frames (0)" 100 (animation-frame-duration '((#:frames . ((0 100))))
0))
- (test "wraps around" 100 (frame->duration '((#:frames . ((0 100) (1 200))))
+ (test "wraps around" 100 (animation-frame-duration '((#:frames . ((0 100) (1 200))))
0))
- (test "frame 1 of (27 28)" 200 (frame->duration '((#:frames . ((27 100) (28 200))))
+ (test "frame 1 of (27 28)" 200 (animation-frame-duration '((#:frames . ((27 100) (28 200))))
1))
+ (test "bare frame uses animation #:duration"
+ 4
+ (animation-frame-duration (anim #:name 'x #:frames '(0 1) #:duration 4) 0))
+ (test "bare frame falls back to global default without animation #:duration"
+ 100
+ (animation-frame-duration (anim #:name 'x #:frames '(0 1)) 0))
+ (test "timed frame ignores animation #:duration"
+ 10
+ (animation-frame-duration (anim #:name 'x #:frames '((0 10) (1 20)) #:duration 4) 0))
)
(test-group "set-animation"
@@ -57,7 +66,7 @@
(stepped (animate-entity e anims 200)))
(test "ticks resets on frame switch" 0 (entity-ref stepped #:anim-tick))
(test "sets tile-id on 10th tick" 1 (entity-ref stepped #:tile-id))
- (test "sets duration to frame duration" 20 (entity-ref stepped #:duration))))
+ (test "sets anim-duration to frame duration" 20 (entity-ref stepped #:anim-duration))))
(test-group "Empty"
(let* ((e (entity #:type 'player)))
(test "unchanged entity without anim-name" e (animate-entity e '() 1)))))
@@ -66,11 +75,12 @@
(test-group "animated entity"
(let* ((anims (list (anim #:name 'walk #:frames '(2 3) #:duration 4)))
(e (entity #:type 'player #:anim-name 'walk #:anim-frame 0 #:anim-tick 0 #:animations anims))
- (stepped-entity (apply-animation #f e 10)))
- (test "Updated animated entity" 10 (entity-ref stepped-entity #:anim-tick)))
- (let* ((e (entity #:type 'static))
- (stepped-entity (apply-animation #f e 10)))
- (test "unchanged static entity" #f (entity-ref stepped-entity #:anim-tick)))))
+ (stepped-entity (apply-animation #f e 3)))
+ (test "accumulates anim-tick against frame duration" 3 (entity-ref stepped-entity #:anim-tick))
+ (test "mirrors current frame duration on entity" 4 (entity-ref stepped-entity #:anim-duration))))
+ (let* ((e (entity #:type 'static))
+ (stepped-entity (apply-animation #f e 10)))
+ (test "unchanged static entity" #f (entity-ref stepped-entity #:anim-tick))))
(test-end "animation")
(test-exit)