Skip to content

Commit

Permalink
Add missing test files
Browse files Browse the repository at this point in the history
  • Loading branch information
ktilton committed Dec 9, 2005
1 parent e87f77c commit 29c8786
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 0 deletions.
77 changes: 77 additions & 0 deletions test-cycle.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*-
;;;
;;; Copyright (c) 1995,2003 by Kenneth William Tilton.
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining a copy
;;; of this software and associated documentation files (the "Software"), to deal
;;; in the Software without restriction, including without limitation the rights
;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;;; copies of the Software, and to permit persons to whom the Software is furnished
;;; to do so, subject to the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be included in
;;; all copies or substantial portions of the Software.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
;;; IN THE SOFTWARE.

(in-package :cells)



(defmodel m-cyc ()
((m-cyc-a :initform (c-in nil) :initarg :m-cyc-a :accessor m-cyc-a)
(m-cyc-b :initform (c-in nil) :initarg :m-cyc-b :accessor m-cyc-b)))

(def-c-output m-cyc-a ()
(print `(output m-cyc-a ,self ,new-value ,old-value))
(setf (m-cyc-b self) new-value))

(def-c-output m-cyc-b ()
(print `(output m-cyc-b ,self ,new-value ,old-value))
(setf (m-cyc-a self) new-value))

(defun m-cyc () ;;def-cell-test m-cyc
(let ((m (make-be 'm-cyc)))
(print `(start ,(m-cyc-a m)))
(setf (m-cyc-a m) 42)
(assert (= (m-cyc-a m) 42))
(assert (= (m-cyc-b m) 42))))

#+(or)
(m-cyc)

(defmodel m-cyc2 ()
((m-cyc2-a :initform (c-in 0) :initarg :m-cyc2-a :accessor m-cyc2-a)
(m-cyc2-b :initform (c? (1+ (^m-cyc2-a)))
:initarg :m-cyc2-b :accessor m-cyc2-b)))

(def-c-output m-cyc2-a ()
(print `(output m-cyc2-a ,self ,new-value ,old-value))
#+(or) (when (< new-value 45)
(setf (m-cyc2-b self) (1+ new-value))))

(def-c-output m-cyc2-b ()
(print `(output m-cyc2-b ,self ,new-value ,old-value))
(when (< new-value 45)
(setf (m-cyc2-a self) (1+ new-value))))

(def-cell-test m-cyc2
(cell-reset)
(let ((m (make-be 'm-cyc2)))
(print '(start))
(setf (m-cyc2-a m) 42)
(describe m)
(assert (= (m-cyc2-a m) 44))
(assert (= (m-cyc2-b m) 45))
))

#+(or)
(m-cyc2)


57 changes: 57 additions & 0 deletions test-ephemeral.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*-
;;;
;;; Copyright (c) 1995,2003 by Kenneth William Tilton.
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining a copy
;;; of this software and associated documentation files (the "Software"), to deal
;;; in the Software without restriction, including without limitation the rights
;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;;; copies of the Software, and to permit persons to whom the Software is furnished
;;; to do so, subject to the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be included in
;;; all copies or substantial portions of the Software.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
;;; IN THE SOFTWARE.

(in-package :cells)


(defmodel m-ephem ()
((m-ephem-a :cell :ephemeral :initform nil :initarg :m-ephem-a :accessor m-ephem-a)
(m-test-a :cell nil :initform nil :initarg :m-test-a :accessor m-test-a)
(m-ephem-b :cell :ephemeral :initform nil :initarg :m-ephem-b :accessor m-ephem-b)
(m-test-b :cell nil :initform nil :initarg :m-test-b :accessor m-test-b)))

(def-c-output m-ephem-a ()
(setf (m-test-a self) new-value))

(def-c-output m-ephem-b ()
(setf (m-test-b self) new-value))

(def-cell-test m-ephem
(let ((m (make-be 'm-ephem :m-ephem-a (c-in nil) :m-ephem-b (c? (* 2 (or (^m-ephem-a) 0))))))
(ct-assert (null (slot-value m 'm-ephem-a)))
(ct-assert (null (m-ephem-a m)))
(ct-assert (null (m-test-a m)))
(ct-assert (null (slot-value m 'm-ephem-b)))
(ct-assert (null (m-ephem-b m)))
(ct-assert (zerop (m-test-b m)))
(setf (m-ephem-a m) 3)
(ct-assert (null (slot-value m 'm-ephem-a)))
(ct-assert (null (m-ephem-a m)))
(ct-assert (eql 3 (m-test-a m)))
;
(ct-assert (null (slot-value m 'm-ephem-b)))
(ct-assert (null (m-ephem-b m)))
(ct-assert (eql 6 (m-test-b m)))
))



101 changes: 101 additions & 0 deletions test-synapse.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*-
;;;
;;; Copyright (c) 1995,2003 by Kenneth William Tilton.
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining a copy
;;; of this software and associated documentation files (the "Software"), to deal
;;; in the Software without restriction, including without limitation the rights
;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;;; copies of the Software, and to permit persons to whom the Software is furnished
;;; to do so, subject to the following conditions:
;;;
;;; The above copyright notice and this permission notice shall be included in
;;; all copies or substantial portions of the Software.
;;;
;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
;;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
;;; IN THE SOFTWARE.

(in-package :cells)


(defmodel m-syn ()
((m-syn-a :initform nil :initarg :m-syn-a :accessor m-syn-a)
(m-syn-b :initform nil :initarg :m-syn-b :accessor m-syn-b)
(m-syn-factor :initform nil :initarg :m-syn-factor :accessor m-syn-factor)
(m-sens :initform nil :initarg :m-sens :accessor m-sens)
(m-plus :initform nil :initarg :m-plus :accessor m-plus)
))

(def-c-output m-syn-b ()
(print `(output m-syn-b ,self ,new-value ,old-value)))


(def-cell-test m-syn
(progn (cell-reset)
(let* ((delta-ct 0)
(sens-ct 0)
(plus-ct 0)
(m (make-be 'm-syn
:m-syn-a (c-in 0)
:m-syn-b (c? (incf delta-ct)
(trc nil "syn-b rule firing!!!!!!!!!!!!!!" delta-ct)
(eko (nil "syn-b rule returning")
(f-delta :syna-1 (:sensitivity 2)
(^m-syn-a))))
:m-syn-factor (c-in 1)
:m-sens (c? (incf sens-ct)
(trc nil "m-sens rule firing ~d !!!!!!!!!!!!!!" sens-ct)
(* (^m-syn-factor)
(f-sensitivity :sensa (3) (^m-syn-a))))
:m-plus (c? (incf plus-ct)
(trc nil "m-plus rule firing!!!!!!!!!!!!!!" plus-ct)
(f-plusp :syna-2 (- 2 (^m-syn-a)))))))
(ct-assert (= 1 delta-ct))
(ct-assert (= 1 sens-ct))
(ct-assert (= 1 plus-ct))
(ct-assert (= 0 (m-sens m)))
(trc "make-be complete. about to incf m-syn-a")
(incf (m-syn-a m))
(ct-assert (= 1 delta-ct))
(ct-assert (= 1 sens-ct))
(ct-assert (= 1 plus-ct))
(ct-assert (= 0 (m-sens m)))
(trc "about to incf m-syn-a 2")
(incf (m-syn-a m) 2)
(trc nil "syn-b now" (m-syn-b m))
(ct-assert (= 2 delta-ct))
(ct-assert (= 2 sens-ct))
(ct-assert (= 2 plus-ct))

(ct-assert (= 3 (m-sens m)))
(trc "about to incf m-syn-a")
(incf (m-syn-a m))
(ct-assert (= 2 delta-ct))
(ct-assert (= 2 sens-ct))
(trc "about to incf m-syn-factor")
(incf (m-syn-factor m))
(ct-assert (= 3 sens-ct))
(ct-assert (= (m-sens m) (* (m-syn-factor m) (m-syn-a m))))
(trc "about to incf m-syn-a xxx")
(incf (m-syn-a m))
(ct-assert (= 2 delta-ct))
(ct-assert (= 3 sens-ct))
(trc "about to incf m-syn-a yyyy")
(incf (m-syn-a m))
(ct-assert (= 3 delta-ct))
(ct-assert (= 4 sens-ct))
(ct-assert (= 2 plus-ct))
(describe m)
(print '(start)))))

(Def-c-output m-syn-a ()
(trc "!!! M-SYN-A now =" new-value))

#+(or)
(m-syn)

0 comments on commit 29c8786

Please sign in to comment.