view org/test.org @ 304:2dfebf71053c

Merged Winston cover letter
author Dylan Holmes <ocsenave@gmail.com>
date Sat, 18 Feb 2012 02:07:40 -0600
parents a1e421d9c485
children 7e7f8d6d9ec5
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, propioception) 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 (:use clojure.contrib.def)
15 (:require [cortex.test touch vision body hearing])
16 (:import com.jme3.app.state.AppState
17 com.jme3.system.AppSettings))
19 (defn run-world
20 "run the simulation and wait until it closes proprely."
21 [world]
22 (let [lock (promise)]
23 (.enqueue
24 world
25 (partial
26 (fn [world]
27 (.attach
28 (.getStateManager world)
29 (proxy [AppState] []
30 (cleanup [] (deliver lock nil))
31 (initialize [_ _])
32 (isEnabled [] true)
33 (setEnabled [_] )
34 (stateAttached [_])
35 (stateDetached [_])
36 (update [_])
37 (render [_])
38 (isInitialized [] true)
39 (postRender []))))
40 world))
41 (.start world)
42 (deref lock)))
44 (defn run-test
45 "print the docstring for the test, then run the simulation which it
46 yields, waiting until it is terminated."
47 [test-fn-var]
48 (println-repl "\n ****************\n")
49 (println-repl (:doc (meta test-fn-var)))
50 (run-world ((deref test-fn-var))))
52 (defvar test-suite
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]
58 "The full test suite for all sensors/effectors.")
60 (defn run-suite
61 "Run the entire test-suite."
62 []
63 (dorun (map run-test test-suite)))
65 #+end_src
67 #+results: body-main
68 : #'cortex.test/run-suite
71 * COMMENT generate Source.
72 #+begin_src clojure :tangle ../src/cortex/test.clj
73 <<body-main>>
74 #+end_src