view org/test.org @ 317:bb3f8a4af87f

removed references to defvar from clojure.contrib.def since the def from 1.4 now allows for docstrings
author Robert McIntyre <rlm@mit.edu>
date Tue, 28 Feb 2012 14:04:21 -0600
parents 7e7f8d6d9ec5
children 702b5c78c2de
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 touch vision body hearing])
15 (:import com.jme3.app.state.AppState
16 com.jme3.system.AppSettings))
18 (defn run-world
19 "run the simulation and wait until it closes properly."
20 [world]
21 (let [lock (promise)]
22 (.enqueue
23 world
24 (partial
25 (fn [world]
26 (.attach
27 (.getStateManager world)
28 (proxy [AppState] []
29 (cleanup [] (deliver lock nil))
30 (initialize [_ _])
31 (isEnabled [] true)
32 (setEnabled [_] )
33 (stateAttached [_])
34 (stateDetached [_])
35 (update [_])
36 (render [_])
37 (isInitialized [] true)
38 (postRender []))))
39 world))
40 (.start world)
41 (deref lock)))
43 (defn run-test
44 "print the docstring for the test, then run the simulation which it
45 yields, waiting until it is terminated."
46 [test-fn-var]
47 (println-repl "\n ****************\n")
48 (println-repl (:doc (meta test-fn-var)))
49 (run-world ((deref test-fn-var))))
51 (def test-suite
52 "The full test suite for all sensors/effectors."
53 [#'cortex.test.touch/test-skin
54 #'cortex.test.vision/test-two-eyes
55 #'cortex.test.hearing/test-advanced-hearing
56 #'cortex.test.body/test-proprioception
57 #'cortex.test.body/test-motor-control])
59 (defn run-suite
60 "Run the entire test-suite."
61 []
62 (dorun (map run-test test-suite)))
64 #+end_src
66 #+results: body-main
67 : #'cortex.test/run-suite
70 * COMMENT generate Source.
71 #+begin_src clojure :tangle ../src/cortex/test.clj
72 <<body-main>>
73 #+end_src