From 8251c85a4a588504d38a2fad05e4b0fe1cdccb9d Mon Sep 17 00:00:00 2001 From: Gene Pasquet Date: Fri, 17 Apr 2026 16:30:34 +0100 Subject: Convert entities to alists --- tests/scene-loader-test.scm | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'tests/scene-loader-test.scm') 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)) -- cgit v1.2.3