aboutsummaryrefslogtreecommitdiff
path: root/tests/renderer-test.scm
diff options
context:
space:
mode:
authorGene Pasquet <dev@etenil.net>2026-04-17 16:52:41 +0100
committerGene Pasquet <dev@etenil.net>2026-04-17 16:52:41 +0100
commita02b892e2ad1e1605ff942c63afdd618daa48be4 (patch)
tree7ccd9278a0cdc7fd2f156b0b4710f6ac00acab27 /tests/renderer-test.scm
parent8251c85a4a588504d38a2fad05e4b0fe1cdccb9d (diff)
Migrate tests to the test egg
Diffstat (limited to 'tests/renderer-test.scm')
-rw-r--r--tests/renderer-test.scm43
1 files changed, 22 insertions, 21 deletions
diff --git a/tests/renderer-test.scm b/tests/renderer-test.scm
index 9f6ce55..702a712 100644
--- a/tests/renderer-test.scm
+++ b/tests/renderer-test.scm
@@ -5,7 +5,7 @@
(only srfi-1 fold iota for-each)
srfi-69
defstruct
- srfi-64)
+ test)
;; Mock tilemap module
(module downstroke-tilemap *
@@ -60,42 +60,42 @@
(test-group "entity-screen-coords"
(let* ((cam (make-camera x: 10 y: 20))
(e (entity #:x 50 #:y 80 #:width 16 #:height 16)))
- (test-equal "subtracts camera offset from x"
+ (test "subtracts camera offset from x"
40
(car (entity-screen-coords e cam)))
- (test-equal "subtracts camera offset from y"
+ (test "subtracts camera offset from y"
60
(cadr (entity-screen-coords e cam)))
- (test-equal "preserves width"
+ (test "preserves width"
16
(caddr (entity-screen-coords e cam)))
- (test-equal "preserves height"
+ (test "preserves height"
16
(cadddr (entity-screen-coords e cam))))
(let* ((cam (make-camera x: 0 y: 0))
(e (entity #:x 100.7 #:y 200.3 #:width 16 #:height 16)))
- (test-equal "floors fractional x"
+ (test "floors fractional x"
100
(car (entity-screen-coords e cam)))
- (test-equal "floors fractional y"
+ (test "floors fractional y"
200
(cadr (entity-screen-coords e cam))))
(let* ((cam (make-camera x: 0 y: 0))
(e (entity #:x 0 #:y 0 #:width 32 #:height 32)))
- (test-equal "zero camera, zero position"
+ (test "zero camera, zero position"
'(0 0 32 32)
(entity-screen-coords e cam))))
(test-group "entity-flip"
- (test-equal "facing 1: no flip"
+ (test "facing 1: no flip"
'()
(entity-flip (entity #:facing 1)))
- (test-equal "facing -1: horizontal flip"
+ (test "facing -1: horizontal flip"
'(horizontal)
(entity-flip (entity #:facing -1)))
- (test-equal "no facing key: defaults to no flip"
+ (test "no facing key: defaults to no flip"
'()
(entity-flip (entity #:x 0))))
@@ -135,23 +135,23 @@
(test-group "make-sprite-font*"
(let ((font (make-sprite-font* tile-size: 8 spacing: 1
ranges: (list (list #\A #\C 100)))))
- (test-equal "A maps to 100"
+ (test "A maps to 100"
100
(sprite-font-char->tile-id font #\A))
- (test-equal "B maps to 101"
+ (test "B maps to 101"
101
(sprite-font-char->tile-id font #\B))
- (test-equal "C maps to 102"
+ (test "C maps to 102"
102
(sprite-font-char->tile-id font #\C))))
(test-group "sprite-font-char->tile-id"
(let ((font (make-sprite-font* tile-size: 8 spacing: 1
ranges: (list (list #\A #\Z 100)))))
- (test-equal "returns #f for unmapped char"
+ (test "returns #f for unmapped char"
#f
(sprite-font-char->tile-id font #\1))
- (test-equal "auto-upcase: lowercase a maps to uppercase"
+ (test "auto-upcase: lowercase a maps to uppercase"
100
(sprite-font-char->tile-id font #\a))))
@@ -170,16 +170,16 @@
(test-group "sprite-text-width"
(let ((font (make-sprite-font* tile-size: 8 spacing: 1
ranges: (list (list #\A #\Z 100)))))
- (test-equal "empty string width is 0"
+ (test "empty string width is 0"
0
(sprite-text-width font ""))
- (test-equal "single char width is tile-size"
+ (test "single char width is tile-size"
8
(sprite-text-width font "A"))
- (test-equal "two chars: 2*tile-size + 1*spacing"
+ (test "two chars: 2*tile-size + 1*spacing"
17
(sprite-text-width font "AB"))
- (test-equal "three chars: 3*tile-size + 2*spacing"
+ (test "three chars: 3*tile-size + 2*spacing"
26
(sprite-text-width font "ABC"))))
@@ -303,7 +303,7 @@
(test-assert "render-scene! works with plist entities"
(begin (render-scene! #f scene-ok) #t))
(test-error "render-scene! errors when entity list contains a vector"
- #t (render-scene! #f scene-bad))
+ (render-scene! #f scene-bad))
(test-assert "extracting entity from cell vector fixes the issue"
(let ((scene-fixed (make-scene entities: (list (vector-ref cell 0))
tilemap: tilemap camera: cam
@@ -311,3 +311,4 @@
(begin (render-scene! #f scene-fixed) #t)))))
(test-end "renderer")
+(test-exit)