                                   (inc (or (:x component-state) 0))))
                   (assoc component-state :x (inc (or (:x component-state) 0))))
         state (-> {}
-                  (mk-scene :test-scene [test-system])
+                  (mk-scene :test-scene [:test-system])
+                  (mk-system :test-system test-system-fn :testable)
                   (mk-entity :player1 [:testable])
                   (mk-entity :player2 [:testable])
                   (mk-component :testable [test-fn]))]


(println "test iter-fns" (iter-fns {} [#(assoc % :yo :dawg)]))

(defn game-loop
  [state scene-id frame-count]
  (if (< frame-count 10)
    (recur (iter-fns state (-> state :scenes scene-id))
           scene-id
           (inc frame-count))
    state))

(println "test mk-system-fn"
         ((mk-system-fn (fn [s fns ents] s) :b) {:entities {:a [:b]}}))

(defn mk-system
  "Add the system function to the state. Wraps the system function using
   mk-system-fn. Returns an update hashmap."
  [state uid f & [component-id]]
  (let [system-fn (if component-id
                    (mk-system-fn f component-id)
                    (mk-system-fn f))]
    (assoc-in state [:systems uid] system-fn)))

(defn integration-test
  "Test the entire CES implementation with a system that changes component state"
  []
  (let [test-system-fn (fn [state fns entity-ids]
                         (apply deep-merge (for [f fns, e entity-ids]
                                             (f state e))))
        test-fn (fn [component-state entity-id]
                  (println "testing" entity-id
                           component-state "->"
