decons/test-asys.lisp

33 lines
973 B
Common Lisp

;;;; decons/test-asys - tests for the asys (asynchronous actor systems) package
(in-package :decons/test-decons)
(defun probe (msg state syns env)
(let ((t:*test-suite* env))
(== (actor:content msg) (pop state))
(lambda (msg) (probe msg state syns env))
))
(defun test-asys ()
(async:init)
(test-neuron-basics)
(async:finish))
(deftest test-neuron-basics ()
(let* ((prb (asys:neuron #'probe :env t:*test-suite* :state '(43 44 9 13)))
;(syn (asys:synapse prb (asys:set-content #'1+)))
(syn1 (asys:synapse prb #'1+))
;(syn (asys:synapse prb (asys:inhibit)))
(fw (asys:neuron #'asys:forward :syns (list syn1)))
(syn2 (asys:synapse fw #'1+))
(cum (asys:neuron #'asys:cumulate :state 0 :syns (list syn2))))
(actor:send fw 42)
(actor:send fw 43)
(actor:send cum 7)
(actor:send cum 4)
(sleep 0.1)
(actor:stop prb)
(actor:stop fw)
(actor:stop cum)
(sleep 0.1)
))