annotate org/test.org @ 334:c264ebf683b4

cleanup.
author Robert McIntyre <rlm@mit.edu>
date Fri, 20 Jul 2012 11:22:21 -0500
parents 5c398b65d01b
children 4c37d39a3cf6
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@321 14 (:require [cortex.test
rlm@321 15 body
rlm@321 16 vision
rlm@321 17 hearing
rlm@321 18 touch
rlm@321 19 proprioception
rlm@321 20 movement
rlm@321 21
rlm@321 22 ])
rlm@58 23 (:import com.jme3.app.state.AppState
rlm@321 24 com.jme3.system.AppSettings)
rlm@321 25 (:import (com.jme3.math Triangle Vector3f Vector2f Ray Matrix4f)))
rlm@58 26
rlm@58 27 (defn run-world
rlm@306 28 "run the simulation and wait until it closes properly."
rlm@58 29 [world]
rlm@58 30 (let [lock (promise)]
rlm@58 31 (.enqueue
rlm@58 32 world
rlm@58 33 (partial
rlm@58 34 (fn [world]
rlm@58 35 (.attach
rlm@58 36 (.getStateManager world)
rlm@58 37 (proxy [AppState] []
rlm@58 38 (cleanup [] (deliver lock nil))
rlm@58 39 (initialize [_ _])
rlm@58 40 (isEnabled [] true)
rlm@58 41 (setEnabled [_] )
rlm@58 42 (stateAttached [_])
rlm@58 43 (stateDetached [_])
rlm@58 44 (update [_])
rlm@58 45 (render [_])
rlm@58 46 (isInitialized [] true)
rlm@58 47 (postRender []))))
rlm@58 48 world))
rlm@58 49 (.start world)
rlm@58 50 (deref lock)))
rlm@58 51
rlm@69 52 (defn run-test
rlm@69 53 "print the docstring for the test, then run the simulation which it
rlm@69 54 yields, waiting until it is terminated."
rlm@69 55 [test-fn-var]
rlm@321 56 (println-repl (:doc (meta test-fn-var)))
rlm@69 57 (println-repl "\n ****************\n")
rlm@69 58 (run-world ((deref test-fn-var))))
rlm@69 59
rlm@317 60 (def test-suite
rlm@317 61 "The full test suite for all sensors/effectors."
rlm@321 62 [#'cortex.test.body/test-worm
rlm@69 63
rlm@321 64 #'cortex.test.vision/test-pipeline
rlm@321 65 #'cortex.test.vision/test-worm-vision
rlm@321 66
rlm@321 67 #'cortex.test.hearing/test-java-hearing
rlm@321 68 #'cortex.test.hearing/test-worm-hearing
rlm@321 69
rlm@321 70 #'cortex.test.touch/test-basic-touch
rlm@321 71 #'cortex.test.touch/test-worm-touch
rlm@321 72
rlm@321 73 #'cortex.test.proprioception/test-proprioception
rlm@321 74
rlm@321 75 #'cortex.test.movement/test-worm-movement
rlm@321 76 ])
rlm@321 77
rlm@321 78
rlm@321 79
rlm@71 80 (defn run-suite
rlm@69 81 "Run the entire test-suite."
rlm@69 82 []
rlm@323 83 (load-bullet)
rlm@321 84 (println-repl "\n ****************\n")
rlm@323 85 (dorun (map run-test test-suite))
rlm@323 86 (println "all tests complete."))
rlm@323 87
rlm@69 88
rlm@58 89 #+end_src
rlm@58 90
rlm@69 91 #+results: body-main
rlm@71 92 : #'cortex.test/run-suite
rlm@69 93
rlm@69 94
rlm@58 95 * COMMENT generate Source.
rlm@68 96 #+begin_src clojure :tangle ../src/cortex/test.clj
rlm@58 97 <<body-main>>
rlm@58 98 #+end_src
rlm@58 99
rlm@58 100