comparison org/test.org @ 69:39e4e1542e4a

updated test-suite
author Robert McIntyre <rlm@mit.edu>
date Fri, 09 Dec 2011 23:11:28 -0600
parents 6cd5a034d855
children 0235c32152af
comparison
equal deleted inserted replaced
68:6cd5a034d855 69:39e4e1542e4a
8 * Tests 8 * Tests
9 9
10 #+name: body-main 10 #+name: body-main
11 #+begin_src clojure 11 #+begin_src clojure
12 (ns cortex.test 12 (ns cortex.test
13 (:require [cortex.test touch vision]) 13 (:use cortex.util)
14 (:use clojure.contrib.def)
15 (:require [cortex.test touch vision body hearing])
14 (:import com.jme3.app.state.AppState 16 (:import com.jme3.app.state.AppState
15 com.jme3.system.AppSettings)) 17 com.jme3.system.AppSettings))
16 18
17 (defn run-world 19 (defn run-world
18 "run the simulation and wait until it closes proprely" 20 "run the simulation and wait until it closes proprely"
19 [world] 21 [world]
20 (let [lock (promise)] 22 (let [lock (promise)]
37 (postRender [])))) 39 (postRender []))))
38 world)) 40 world))
39 (.start world) 41 (.start world)
40 (deref lock))) 42 (deref lock)))
41 43
42 (defn test-all [] 44 (defn run-test
43 (println 45 "print the docstring for the test, then run the simulation which it
44 "***************\n" 46 yields, waiting until it is terminated."
45 "Testing touch:\n" 47 [test-fn-var]
46 "you should see a ball which responds to the table\n" 48 (println-repl "\n ****************\n")
47 "and whatever balls hit it.\n") 49 (println-repl (:doc (meta test-fn-var)))
48 (run-world (test.touch/test-skin)) 50 (run-world ((deref test-fn-var))))
49 (println 51
50 "***************\n" 52 (defvar test-suite
51 "Testing vision:\n" 53 [#'cortex.test.touch/test-skin
52 "You should see a rotating cube, and two windows,\n" 54 #'cortex.test.vision/test-two-eyes
53 "each displaying a different view of the cube.\n") 55 #'cortex.test.hearing/test-advanced-hearing
54 (run-world (test.vision/test-two-eyes)) 56 #'cortex.test.body/test-proprioception
55 (println 57 #'cortex.test.body/test-motor-control]
56 "***************\n" 58 "The full test suite for all sensors/effectors.")
57 "Testing hearing:\n" 59
58 "You should see a blue sphere flying around several\n" 60 (defn run-test-suite
59 "cubes. As the sphere approaches each cube, it turns\n" 61 "Run the entire test-suite."
60 "green.\n") 62 []
61 (run-world 63 (dorun (map run-test test-suite)))
62 (doto (com.aurellem.capture.examples.Advanced.) 64
63 (.setSettings
64 (doto (AppSettings. true)
65 (.setAudioRenderer "Send")))
66 (.setShowSettings false)
67 (.setPauseOnLostFocus false))))
68 #+end_src 65 #+end_src
66
67 #+results: body-main
68 : #'cortex.test/run-test-suite
69
69 70
70 * COMMENT generate Source. 71 * COMMENT generate Source.
71 #+begin_src clojure :tangle ../src/cortex/test.clj 72 #+begin_src clojure :tangle ../src/cortex/test.clj
72 <<body-main>> 73 <<body-main>>
73 #+end_src 74 #+end_src