view org/test.org @ 449:09b7c8dd4365

first chapter done, half of last chapter done.
author Robert McIntyre <rlm@mit.edu>
date Wed, 26 Mar 2014 02:42:01 -0400
parents 4c37d39a3cf6
children
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
21 integration])
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
77 #'cortex.test.integration/test-integration
78 ])
82 (defn run-suite
83 "Run the entire test-suite."
84 []
85 (load-bullet)
86 (println-repl "\n ****************\n")
87 (dorun (map run-test test-suite))
88 (println "all tests complete."))
91 #+end_src
93 #+results: body-main
94 : #'cortex.test/run-suite
97 * COMMENT generate Source.
98 #+begin_src clojure :tangle ../src/cortex/test.clj
99 <<body-main>>
100 #+end_src