changeset 69:39e4e1542e4a

updated test-suite
author Robert McIntyre <rlm@mit.edu>
date Fri, 09 Dec 2011 23:11:28 -0600
parents 6cd5a034d855
children 0235c32152af
files org/body.org org/eyes.org org/skin.org org/test.org
diffstat 4 files changed, 49 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/body.org	Fri Dec 09 21:33:05 2011 -0600
     1.2 +++ b/org/body.org	Fri Dec 09 23:11:28 2011 -0600
     1.3 @@ -131,9 +131,9 @@
     1.4  
     1.5  * Examples
     1.6  
     1.7 -#+srcname: test-body
     1.8 +#+name: test-body
     1.9  #+begin_src clojure
    1.10 -(ns test.body
    1.11 +(ns cortex.test.body
    1.12    (:use (cortex world util body))
    1.13    (:import
    1.14     com.jme3.math.Vector3f
    1.15 @@ -200,7 +200,8 @@
    1.16       Vector3f/ZERO]))
    1.17  
    1.18  (defn test-motor-control
    1.19 -  "You should see a multi-segmented worm-like object fall onto the
    1.20 +  "Testing motor-control:
    1.21 +   You should see a multi-segmented worm-like object fall onto the
    1.22     table and begin writhing and moving."
    1.23    []
    1.24    (let [worm (eve-worm)
    1.25 @@ -227,7 +228,8 @@
    1.26                 (worm-pattern @time)))))))
    1.27  
    1.28  (defn test-proprioception
    1.29 -  "You should see two foating bars, and a printout of pitch, yaw, and
    1.30 +  "Testing proprioception:
    1.31 +   You should see two foating bars, and a printout of pitch, yaw, and
    1.32     roll. Pressing key-r/key-t should move the blue bar up and down and
    1.33     change only the value of pitch. key-f/key-g moves it side to side
    1.34     and changes yaw. key-v/key-b will spin the blue segment clockwise
    1.35 @@ -269,9 +271,7 @@
    1.36         (set-gravity world (Vector3f. 0 0 0))
    1.37         (.setMoveSpeed (.getFlyByCamera world) 50)
    1.38         (.setRotationSpeed (.getFlyByCamera world) 50)
    1.39 -       (light-up-everything world)
    1.40 -       (.setTimer world (NanoTimer.))
    1.41 -       )
    1.42 +       (light-up-everything world))
    1.43       (fn [_ _]
    1.44         (if @move-up?
    1.45           (.applyTorque control
    1.46 @@ -300,7 +300,6 @@
    1.47  
    1.48         (if (= 0 (rem (swap! time inc) 2000))
    1.49           (do
    1.50 -           
    1.51             (apply
    1.52              (comp
    1.53               println-repl
    1.54 @@ -752,7 +751,7 @@
    1.55  <<motor-control>>
    1.56  #+end_src
    1.57  
    1.58 -#+begin_src clojure :tangle ../src/test/body.clj
    1.59 +#+begin_src clojure :tangle ../src/cortex/test/body.clj
    1.60  <<test-body>>
    1.61  #+end_src  
    1.62  
     2.1 --- a/org/eyes.org	Fri Dec 09 21:33:05 2011 -0600
     2.2 +++ b/org/eyes.org	Fri Dec 09 23:11:28 2011 -0600
     2.3 @@ -126,9 +126,13 @@
     2.4        (.repaint panel))))
     2.5  
     2.6  (defn test-two-eyes
     2.7 -  "Tests the vision system by creating two views of the same rotating
     2.8 -  object from different angles and displaying both of those views in
     2.9 -  JFrames."  
    2.10 +  "Testing vision:
    2.11 +   Tests the vision system by creating two views of the same rotating
    2.12 +   object from different angles and displaying both of those views in
    2.13 +   JFrames.
    2.14 +
    2.15 +   You should see a rotating cube, and two windows,
    2.16 +   each displaying a different view of the cube."
    2.17    []
    2.18    (let [candy
    2.19          (box 1 1 1 :physical? false :color ColorRGBA/Blue)]
     3.1 --- a/org/skin.org	Fri Dec 09 21:33:05 2011 -0600
     3.2 +++ b/org/skin.org	Fri Dec 09 23:11:28 2011 -0600
     3.3 @@ -228,7 +228,11 @@
     3.4          (.setBlendMode RenderState$BlendMode/Alpha))
     3.5      (.setQueueBucket RenderQueue$Bucket/Transparent)))
     3.6  
     3.7 -(defn test-skin []
     3.8 +(defn test-skin 
     3.9 +  "Testing touch:
    3.10 +   you should see a ball which responds to the table
    3.11 +   and whatever balls hit it."
    3.12 +  []
    3.13    (let [b
    3.14          ;;(transparent-box)
    3.15          (transparent-sphere)
     4.1 --- a/org/test.org	Fri Dec 09 21:33:05 2011 -0600
     4.2 +++ b/org/test.org	Fri Dec 09 23:11:28 2011 -0600
     4.3 @@ -10,9 +10,11 @@
     4.4  #+name: body-main
     4.5  #+begin_src clojure 
     4.6  (ns cortex.test
     4.7 -  (:require [cortex.test touch vision])
     4.8 +  (:use cortex.util)
     4.9 +  (:use clojure.contrib.def)
    4.10 +  (:require [cortex.test touch vision body hearing])
    4.11    (:import com.jme3.app.state.AppState
    4.12 -           com.jme3.system.AppSettings))
    4.13 +	   com.jme3.system.AppSettings))
    4.14  
    4.15  (defn run-world
    4.16    "run the simulation and wait until it closes proprely"
    4.17 @@ -39,34 +41,33 @@
    4.18      (.start world)
    4.19      (deref lock)))
    4.20  
    4.21 -(defn test-all []
    4.22 -  (println
    4.23 -   "***************\n"
    4.24 -   "Testing touch:\n"
    4.25 -   "you should see a ball which responds to the table\n"
    4.26 -   "and whatever balls hit it.\n")
    4.27 -  (run-world (test.touch/test-skin))
    4.28 -  (println
    4.29 -   "***************\n"
    4.30 -   "Testing vision:\n"
    4.31 -   "You should see a rotating cube, and two windows,\n"
    4.32 -   "each displaying a different view of the cube.\n")
    4.33 -  (run-world (test.vision/test-two-eyes))
    4.34 -  (println
    4.35 -   "***************\n"
    4.36 -   "Testing hearing:\n"
    4.37 -   "You should see a blue sphere flying around several\n"
    4.38 -   "cubes.  As the sphere approaches each cube, it turns\n"
    4.39 -   "green.\n")
    4.40 -  (run-world
    4.41 -   (doto (com.aurellem.capture.examples.Advanced.)
    4.42 -     (.setSettings
    4.43 -      (doto (AppSettings. true)
    4.44 -        (.setAudioRenderer "Send")))
    4.45 -     (.setShowSettings false)
    4.46 -     (.setPauseOnLostFocus false))))
    4.47 +(defn run-test
    4.48 +  "print the docstring for the test, then run the simulation which it
    4.49 +  yields, waiting until it is terminated."
    4.50 +  [test-fn-var]
    4.51 +  (println-repl "\n ****************\n")
    4.52 +  (println-repl (:doc (meta test-fn-var)))
    4.53 +  (run-world ((deref test-fn-var))))
    4.54 +
    4.55 +(defvar test-suite
    4.56 +  [#'cortex.test.touch/test-skin
    4.57 +   #'cortex.test.vision/test-two-eyes
    4.58 +   #'cortex.test.hearing/test-advanced-hearing
    4.59 +   #'cortex.test.body/test-proprioception
    4.60 +   #'cortex.test.body/test-motor-control]
    4.61 +  "The full test suite for all sensors/effectors.")
    4.62 +
    4.63 +(defn run-test-suite
    4.64 +  "Run the entire test-suite."
    4.65 +  []
    4.66 +  (dorun (map run-test test-suite)))
    4.67 +
    4.68  #+end_src
    4.69  
    4.70 +#+results: body-main
    4.71 +: #'cortex.test/run-test-suite
    4.72 +
    4.73 +
    4.74  * COMMENT generate Source.
    4.75  #+begin_src clojure :tangle ../src/cortex/test.clj
    4.76  <<body-main>>