annotate org/test.org @ 218:ac46ee4e574a

edits to vision.org
author Robert McIntyre <rlm@mit.edu>
date Fri, 10 Feb 2012 12:06:41 -0700
parents a1e421d9c485
children 7e7f8d6d9ec5
rev   line source
rlm@66 1 #+title: Test Suite
rlm@58 2 #+author: Robert McIntyre
rlm@58 3 #+email: rlm@mit.edu
rlm@58 4 #+description: Simulating a body (movement, touch, propioception) in jMonkeyEngine3.
rlm@58 5 #+SETUPFILE: ../../aurellem/org/setup.org
rlm@58 6 #+INCLUDE: ../../aurellem/org/level-0.org
rlm@58 7
rlm@66 8 * Tests
rlm@58 9
rlm@66 10 #+name: body-main
rlm@58 11 #+begin_src clojure
rlm@68 12 (ns cortex.test
rlm@69 13 (:use cortex.util)
rlm@69 14 (:use clojure.contrib.def)
rlm@69 15 (:require [cortex.test touch vision body hearing])
rlm@58 16 (:import com.jme3.app.state.AppState
rlm@69 17 com.jme3.system.AppSettings))
rlm@58 18
rlm@58 19 (defn run-world
rlm@70 20 "run the simulation and wait until it closes proprely."
rlm@58 21 [world]
rlm@58 22 (let [lock (promise)]
rlm@58 23 (.enqueue
rlm@58 24 world
rlm@58 25 (partial
rlm@58 26 (fn [world]
rlm@58 27 (.attach
rlm@58 28 (.getStateManager world)
rlm@58 29 (proxy [AppState] []
rlm@58 30 (cleanup [] (deliver lock nil))
rlm@58 31 (initialize [_ _])
rlm@58 32 (isEnabled [] true)
rlm@58 33 (setEnabled [_] )
rlm@58 34 (stateAttached [_])
rlm@58 35 (stateDetached [_])
rlm@58 36 (update [_])
rlm@58 37 (render [_])
rlm@58 38 (isInitialized [] true)
rlm@58 39 (postRender []))))
rlm@58 40 world))
rlm@58 41 (.start world)
rlm@58 42 (deref lock)))
rlm@58 43
rlm@69 44 (defn run-test
rlm@69 45 "print the docstring for the test, then run the simulation which it
rlm@69 46 yields, waiting until it is terminated."
rlm@69 47 [test-fn-var]
rlm@69 48 (println-repl "\n ****************\n")
rlm@69 49 (println-repl (:doc (meta test-fn-var)))
rlm@69 50 (run-world ((deref test-fn-var))))
rlm@69 51
rlm@69 52 (defvar test-suite
rlm@69 53 [#'cortex.test.touch/test-skin
rlm@69 54 #'cortex.test.vision/test-two-eyes
rlm@69 55 #'cortex.test.hearing/test-advanced-hearing
rlm@69 56 #'cortex.test.body/test-proprioception
rlm@69 57 #'cortex.test.body/test-motor-control]
rlm@69 58 "The full test suite for all sensors/effectors.")
rlm@69 59
rlm@71 60 (defn run-suite
rlm@69 61 "Run the entire test-suite."
rlm@69 62 []
rlm@69 63 (dorun (map run-test test-suite)))
rlm@69 64
rlm@58 65 #+end_src
rlm@58 66
rlm@69 67 #+results: body-main
rlm@71 68 : #'cortex.test/run-suite
rlm@69 69
rlm@69 70
rlm@58 71 * COMMENT generate Source.
rlm@68 72 #+begin_src clojure :tangle ../src/cortex/test.clj
rlm@58 73 <<body-main>>
rlm@58 74 #+end_src
rlm@58 75
rlm@58 76