From f3491a5aa359141aa0e25e076b0b015169e9faab Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 28 Feb 2026 11:55:59 +0100 Subject: [PATCH] testing: + in-seq test, use in csys probe --- csys/csys.lisp | 3 ++- scopes-csys.asd | 2 +- test/test-csys.lisp | 6 +++--- testing.lisp | 10 ++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/csys/csys.lisp b/csys/csys.lisp index 150d07e..a1dddc4 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -46,7 +46,8 @@ (defun find-create-sensors (msg) (let* ((key (cddr (shape:head msg))) (sns (gethash key *sensors*))) - (format t "~&~a ~a" key sns) + ;(format t "~&~a ~a" key sns) + (util:lgi key sns) (or sns (let* ((mx (message:create (list :csys :sensor (shape:head-value msg :class)))) diff --git a/scopes-csys.asd b/scopes-csys.asd index 9805f3d..b9978f4 100644 --- a/scopes-csys.asd +++ b/scopes-csys.asd @@ -10,7 +10,7 @@ :description "Concurrent cybernetic communications systems." :depends-on (:scopes-core) :components ((:file "csys/csys")) - :long-description "scopes/csys: Concurrent cybernetic communications systems." + :long-description "scopes/csys: Concurrent cybernetic communication systems." :in-order-to ((test-op (test-op "scopes-csys/test")))) (defsystem :scopes-csys/test diff --git a/test/test-csys.lisp b/test/test-csys.lisp index 5cd2da3..c43906b 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -14,7 +14,7 @@ (:util :scopes/util) (:t :scopes/testing)) (:export #:run) - (:import-from :scopes/testing #:deftest #:== #:!=)) + (:import-from :scopes/testing #:deftest #:== #:!= #:in-seq)) (in-package :scopes/test-csys) @@ -25,8 +25,8 @@ (defun probe (msg state syns env) (let ((t:*test-suite* (test-suite env))) - (== (shape:data msg) (pop state)) - (actor:become (csys:neuron #'probe state syns env)))) + (let ((state (in-seq (shape:data msg) state :remove t))) + (actor:become (csys:neuron #'probe state syns env))))) (defvar *probe* nil) diff --git a/testing.lisp b/testing.lisp index 2c92d49..261c181 100644 --- a/testing.lisp +++ b/testing.lisp @@ -6,7 +6,7 @@ (:use :common-lisp) (:export #:*test-suite* #:test-suite #:deftest #:show-result - #:failure #:check #:test #:== #:has-prefix + #:failure #:check #:test #:== #:has-prefix #:in-seq #:test-path #:*current-system*)) (in-package :scopes/testing) @@ -39,7 +39,8 @@ (let ((is-ok (funcall fn have wanted))) (push is-ok (car (result *test-suite*))) (unless is-ok - (failure fmt have wanted)))) + (failure fmt have wanted)) + is-ok)) (defun == (have wanted) (check #'equalp "~s!=~s" have wanted)) @@ -51,6 +52,11 @@ (check #'(lambda (h w) (string= (str:prefix (list h w)) w)) "~s has not prefix ~s" have wanted)) +(defun in-seq (have seq &key remove) + (if (and (check #'position "~s is not in ~s" have seq) remove) + (remove-if (lambda (x) (eql x have)) seq :count 1) + seq)) + (defmacro deftest (name args &body body) `(defun ,name ,args (push '(,name) (result *test-suite*))