annotate org/test.org @ 319:b84701e4f6ae

corrected typo
author Robert McIntyre <rlm@mit.edu>
date Thu, 01 Mar 2012 05:56:52 -0700
parents bb3f8a4af87f
children 702b5c78c2de
rev   line source
rlm@66 1 #+title: Test Suite
rlm@58 2 #+author: Robert McIntyre
rlm@58 3 #+email: rlm@mit.edu
rlm@306 4 #+description: Simulating a body (movement, touch, proprioception) 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 (:require [cortex.test touch vision body hearing])
rlm@58 15 (:import com.jme3.app.state.AppState
rlm@69 16 com.jme3.system.AppSettings))
rlm@58 17
rlm@58 18 (defn run-world
rlm@306 19 "run the simulation and wait until it closes properly."
rlm@58 20 [world]
rlm@58 21 (let [lock (promise)]
rlm@58 22 (.enqueue
rlm@58 23 world
rlm@58 24 (partial
rlm@58 25 (fn [world]
rlm@58 26 (.attach
rlm@58 27 (.getStateManager world)
rlm@58 28 (proxy [AppState] []
rlm@58 29 (cleanup [] (deliver lock nil))
rlm@58 30 (initialize [_ _])
rlm@58 31 (isEnabled [] true)
rlm@58 32 (setEnabled [_] )
rlm@58 33 (stateAttached [_])
rlm@58 34 (stateDetached [_])
rlm@58 35 (update [_])
rlm@58 36 (render [_])
rlm@58 37 (isInitialized [] true)
rlm@58 38 (postRender []))))
rlm@58 39 world))
rlm@58 40 (.start world)
rlm@58 41 (deref lock)))
rlm@58 42
rlm@69 43 (defn run-test
rlm@69 44 "print the docstring for the test, then run the simulation which it
rlm@69 45 yields, waiting until it is terminated."
rlm@69 46 [test-fn-var]
rlm@69 47 (println-repl "\n ****************\n")
rlm@69 48 (println-repl (:doc (meta test-fn-var)))
rlm@69 49 (run-world ((deref test-fn-var))))
rlm@69 50
rlm@317 51 (def test-suite
rlm@317 52 "The full test suite for all sensors/effectors."
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@317 57 #'cortex.test.body/test-motor-control])
rlm@69 58
rlm@71 59 (defn run-suite
rlm@69 60 "Run the entire test-suite."
rlm@69 61 []
rlm@69 62 (dorun (map run-test test-suite)))
rlm@69 63
rlm@58 64 #+end_src
rlm@58 65
rlm@69 66 #+results: body-main
rlm@71 67 : #'cortex.test/run-suite
rlm@69 68
rlm@69 69
rlm@58 70 * COMMENT generate Source.
rlm@68 71 #+begin_src clojure :tangle ../src/cortex/test.clj
rlm@58 72 <<body-main>>
rlm@58 73 #+end_src
rlm@58 74
rlm@58 75