diff options
| author | Gene Pasquet <dev@etenil.net> | 2026-04-05 23:12:54 +0100 |
|---|---|---|
| committer | Gene Pasquet <dev@etenil.net> | 2026-04-05 23:12:54 +0100 |
| commit | b99ada53b715def5492c7d04c0d327fa7048e5d3 (patch) | |
| tree | 9e94dbc8ff863ef09ef18f4be31fb45e085572a4 /tests/world-test.scm | |
| parent | 027053b11a3a5d861ed2fa2db245388bd95ac246 (diff) | |
Complete implementation
Diffstat (limited to 'tests/world-test.scm')
| -rw-r--r-- | tests/world-test.scm | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/world-test.scm b/tests/world-test.scm index c4fd887..451ab2a 100644 --- a/tests/world-test.scm +++ b/tests/world-test.scm @@ -95,7 +95,7 @@ ;; Test: scene record creation (test-group "scene-structure" - (let ((scene (make-scene entities: '() tilemap: #f))) + (let ((scene (make-scene entities: '() tilemap: #f camera-target: #f))) (test-assert "scene is a record" (scene? scene)) (test-equal "entities list is empty" '() (scene-entities scene)) (test-equal "tilemap is #f" #f (scene-tilemap scene)))) @@ -106,7 +106,8 @@ (enemy '(#:type enemy #:x 200 #:y 200)) (tilemap "mock-tilemap") (scene (make-scene entities: (list player enemy) - tilemap: tilemap))) + tilemap: tilemap + camera-target: #f))) (test-equal "scene has 2 entities" 2 (length (scene-entities scene))) @@ -120,7 +121,7 @@ ;; Test: scene-add-entity adds entity to scene (test-group "scene-add-entity" (let* ((player (make-player-entity 100 100 16 16)) - (scene (make-scene entities: (list player) tilemap: #f)) + (scene (make-scene entities: (list player) tilemap: #f camera-target: #f)) (enemy '(#:type enemy #:x 200 #:y 200))) (test-equal "initial entity count" 1 (length (scene-entities scene))) @@ -137,7 +138,7 @@ (let* ((e1 '(#:type a #:x 1)) (e2 '(#:type b #:x 2)) (e3 '(#:type c #:x 3)) - (scene (make-scene entities: (list e1) tilemap: #f))) + (scene (make-scene entities: (list e1) tilemap: #f camera-target: #f))) (scene-add-entity scene e2) (scene-add-entity scene e3) @@ -150,7 +151,7 @@ (test-group "scene-update-entities" (let* ((e1 '(#:type player #:x 100 #:y 100)) (e2 '(#:type enemy #:x 200 #:y 200)) - (scene (make-scene entities: (list e1 e2) tilemap: #f)) + (scene (make-scene entities: (list e1 e2) tilemap: #f camera-target: #f)) ;; Function that moves all entities right by 10 (move-right (lambda (entity) (let ((x (entity-ref entity #:x)) @@ -174,7 +175,7 @@ (test-group "scene-update-entities-identity" (let* ((e1 '(#:type player #:x 100)) (e2 '(#:type enemy #:x 200)) - (scene (make-scene entities: (list e1 e2) tilemap: #f))) + (scene (make-scene entities: (list e1 e2) tilemap: #f camera-target: #f))) (scene-update-entities scene (lambda (e) e)) @@ -185,7 +186,7 @@ ;; Test: scene mutation (test-group "scene-mutation" - (let* ((scene (make-scene entities: '() tilemap: #f)) + (let* ((scene (make-scene entities: '() tilemap: #f camera-target: #f)) (player (make-player-entity 10 20 16 16))) ;; Add entity @@ -206,7 +207,7 @@ ;; Test: scene-tilemap-set! (test-group "scene-tilemap-mutation" - (let ((scene (make-scene entities: '() tilemap: #f))) + (let ((scene (make-scene entities: '() tilemap: #f camera-target: #f))) (test-equal "tilemap initially #f" #f (scene-tilemap scene)) (scene-tilemap-set! scene "new-tilemap") @@ -228,7 +229,8 @@ (scene (make-scene entities: (list e1 e2) tilemap: test-tilemap camera: (make-camera x: 0 y: 0) - tileset-texture: #f))) + tileset-texture: #f + camera-target: #f))) (scene-filter-entities scene (lambda (e) (eq? (entity-ref e #:type #f) 'player))) (test-equal "keeps matching entities" 1 (length (scene-entities scene))) @@ -252,7 +254,7 @@ (let* ((p (list #:type 'player #:x 0 #:y 0 #:width 16 #:height 16 #:tags '(player))) (e (list #:type 'enemy #:x 0 #:y 0 #:width 16 #:height 16 #:tags '(enemy npc))) (s (make-scene entities: (list p e) tilemap: #f - camera: (make-camera x: 0 y: 0) tileset-texture: #f))) + camera: (make-camera x: 0 y: 0) tileset-texture: #f camera-target: #f))) (test-equal "finds entity with matching tag" p (scene-find-tagged s 'player)) (test-equal "finds enemy by 'enemy tag" e (scene-find-tagged s 'enemy)) (test-equal "finds entity with second tag in list" e (scene-find-tagged s 'npc)) @@ -263,7 +265,7 @@ (p2 (list #:type 'ally #:x 0 #:y 0 #:width 16 #:height 16 #:tags '(ally friendly))) (e (list #:type 'enemy #:x 0 #:y 0 #:width 16 #:height 16 #:tags '(enemy))) (s (make-scene entities: (list p1 p2 e) tilemap: #f - camera: (make-camera x: 0 y: 0) tileset-texture: #f))) + camera: (make-camera x: 0 y: 0) tileset-texture: #f camera-target: #f))) (test-equal "returns all friendly entities" 2 (length (scene-find-all-tagged s 'friendly))) (test-equal "returns empty list when none match" '() (scene-find-all-tagged s 'boss)))) |
