diff options
| author | Gene Pasquet <dev@etenil.net> | 2026-04-17 16:30:34 +0100 |
|---|---|---|
| committer | Gene Pasquet <dev@etenil.net> | 2026-04-17 16:30:34 +0100 |
| commit | 8251c85a4a588504d38a2fad05e4b0fe1cdccb9d (patch) | |
| tree | c3fcedb7331caf798f2355c7549b35aa3aaf6ac8 /tests/scene-loader-test.scm | |
| parent | 5de3b9cf122542f2a0c1c906c8ce8add20e5c8c6 (diff) | |
Convert entities to alists
Diffstat (limited to 'tests/scene-loader-test.scm')
| -rw-r--r-- | tests/scene-loader-test.scm | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/tests/scene-loader-test.scm b/tests/scene-loader-test.scm index 5c85ede..88fb544 100644 --- a/tests/scene-loader-test.scm +++ b/tests/scene-loader-test.scm @@ -20,25 +20,15 @@ (define (load-tileset filename) (make-tileset tilewidth: 16 tileheight: 16 spacing: 0 tilecount: 256 columns: 16 image-source: "" image: #f))) (import downstroke-tilemap) -;; Mock entity module (minimal) -(module downstroke-entity * - (import scheme (chicken base)) - (define (entity-ref entity key #!optional (default #f)) - (let loop ((plist entity)) - (cond - ((null? plist) (if (procedure? default) (default) default)) - ((eq? (car plist) key) (cadr plist)) - (else (loop (cddr plist)))))) - (define (entity-set entity key val) - (let loop ((plist entity) (acc '())) - (cond - ((null? plist) (reverse (cons val (cons key acc)))) - ((eq? (car plist) key) (append (reverse acc) (cons key (cons val (cddr plist))))) - (else (loop (cddr plist) (cons (cadr plist) (cons (car plist) acc))))))) - (define (entity-type entity) - (entity-ref entity #:type #f))) +;; Load the real entity module (alist-based) +(include "entity.scm") (import downstroke-entity) +(import (only (list-utils alist) plist->alist)) + +;; Test helper: build an alist entity from plist-style keyword args. +(define (entity . kws) (plist->alist kws)) + ;; Mock world module (module downstroke-world * (import scheme (chicken base) defstruct) @@ -100,8 +90,8 @@ objects: (list obj1 obj2 obj3))) ;; mock registry: alist of (type . constructor) (registry - (list (cons 'player (lambda (x y w h) (list #:type 'player #:x x #:y y #:width w #:height h))) - (cons 'enemy (lambda (x y w h) (list #:type 'enemy #:x x #:y y #:width w #:height h))))) + (list (cons 'player (lambda (x y w h) (entity #:type 'player #:x x #:y y #:width w #:height h))) + (cons 'enemy (lambda (x y w h) (entity #:type 'enemy #:x x #:y y #:width w #:height h))))) (result (tilemap-objects->entities tm registry))) (test-equal "filters #f results: 2 entities from 3 objects" 2 (length result)) |
