view org/test.org @ 346:83afb1fcc999

add touch sensors and mass.
author Robert McIntyre <rlm@mit.edu>
date Sun, 22 Jul 2012 11:18:47 -0500
parents 5c398b65d01b
children 4c37d39a3cf6
line wrap: on
line source
1 #+title: Test Suite
2 #+author: Robert McIntyre
3 #+email: rlm@mit.edu
4 #+description: Simulating a body (movement, touch, proprioception) in jMonkeyEngine3.
5 #+SETUPFILE: ../../aurellem/org/setup.org
6 #+INCLUDE: ../../aurellem/org/level-0.org
8 * Tests
10 #+name: body-main
11 #+begin_src clojure
12 (ns cortex.test
13 (:use cortex.util)
14 (:require [cortex.test
15 body
16 vision
17 hearing
18 touch
19 proprioception
20 movement
22 ])
23 (:import com.jme3.app.state.AppState
24 com.jme3.system.AppSettings)
25 (:import (com.jme3.math Triangle Vector3f Vector2f Ray Matrix4f)))
27 (defn run-world
28 "run the simulation and wait until it closes properly."
29 [world]
30 (let [lock (promise)]
31 (.enqueue
32 world
33 (partial
34 (fn [world]
35 (.attach
36 (.getStateManager world)
37 (proxy [AppState] []
38 (cleanup [] (deliver lock nil))
39 (initialize [_ _])
40 (isEnabled [] true)
41 (setEnabled [_] )
42 (stateAttached [_])
43 (stateDetached [_])
44 (update [_])
45 (render [_])
46 (isInitialized [] true)
47 (postRender []))))
48 world))
49 (.start world)
50 (deref lock)))
52 (defn run-test
53 "print the docstring for the test, then run the simulation which it
54 yields, waiting until it is terminated."
55 [test-fn-var]
56 (println-repl (:doc (meta test-fn-var)))
57 (println-repl "\n ****************\n")
58 (run-world ((deref test-fn-var))))
60 (def test-suite
61 "The full test suite for all sensors/effectors."
62 [#'cortex.test.body/test-worm
64 #'cortex.test.vision/test-pipeline
65 #'cortex.test.vision/test-worm-vision
67 #'cortex.test.hearing/test-java-hearing
68 #'cortex.test.hearing/test-worm-hearing
70 #'cortex.test.touch/test-basic-touch
71 #'cortex.test.touch/test-worm-touch
73 #'cortex.test.proprioception/test-proprioception
75 #'cortex.test.movement/test-worm-movement
76 ])
80 (defn run-suite
81 "Run the entire test-suite."
82 []
83 (load-bullet)
84 (println-repl "\n ****************\n")
85 (dorun (map run-test test-suite))
86 (println "all tests complete."))
89 #+end_src
91 #+results: body-main
92 : #'cortex.test/run-suite
95 * COMMENT generate Source.
96 #+begin_src clojure :tangle ../src/cortex/test.clj
97 <<body-main>>
98 #+end_src