Much better error logging on rule execution.
This commit is contained in:
parent
ac25969f90
commit
85d66208b9
3 changed files with 37 additions and 26 deletions
|
|
@ -11,19 +11,13 @@
|
|||
(cond
|
||||
(= (:state cell) :new)
|
||||
(merge cell {:state :grassland}))))
|
||||
merge {:rule-type :production})
|
||||
pair (list afn "Test source")]
|
||||
merge {:rule-type :production
|
||||
:rule "Test source"})]
|
||||
(is (nil? (apply-rule nil {:state :water} afn))
|
||||
"Rule shouldn't fire when state is wrong")
|
||||
(is (nil? (apply-rule nil {:state :water} pair))
|
||||
"Rule shouldn't fire when state is wrong")
|
||||
(is (= (:state (apply-rule nil {:state :new} afn)) :grassland)
|
||||
"Rule should fire when state is correct")
|
||||
(is (= (:state (apply-rule nil {:state :new} pair)) :grassland)
|
||||
"Rule should fire when state is correct")
|
||||
(is (nil? (:rule (apply-rule nil {:state :new} afn)))
|
||||
"No rule text if not provided")
|
||||
(is (= (:rule (apply-rule nil {:state :new} pair)) "Test source")
|
||||
"Rule should fire when state is correct")
|
||||
(is (= (:rule (apply-rule nil {:state :new} afn)) "Test source")
|
||||
"Rule text cached on cell if provided"))))
|
||||
|
||||
(deftest transform-world-tests
|
||||
|
|
@ -34,10 +28,11 @@
|
|||
(cond
|
||||
(= (:state cell) :new)
|
||||
(merge cell {:state :grassland}))))
|
||||
merge {:rule-type :production})
|
||||
merge {:rule-type :production
|
||||
:rule "Test source"})
|
||||
world (make-world 3 3)
|
||||
expected [[{:y 0, :state :grassland, :x 0, :generation 1} {:y 0, :state :grassland, :x 1, :generation 1} {:y 0, :state :grassland, :x 2, :generation 1}]
|
||||
[{:y 1, :state :grassland, :x 0, :generation 1} {:y 1, :state :grassland, :x 1, :generation 1} {:y 1, :state :grassland, :x 2, :generation 1}]
|
||||
[{:y 2, :state :grassland, :x 0, :generation 1} {:y 2, :state :grassland, :x 1, :generation 1} {:y 2, :state :grassland, :x 2, :generation 1}]]
|
||||
expected [[[{:y 0, :state :grassland, :x 0, :rule-type :production, :rule "Test source", :generation 1} {:y 0, :state :grassland, :x 1, :rule-type :production, :rule "Test source", :generation 1} {:y 0, :state :grassland, :x 2, :rule-type :production, :rule "Test source", :generation 1}]
|
||||
[{:y 1, :state :grassland, :x 0, :rule-type :production, :rule "Test source", :generation 1} {:y 1, :state :grassland, :x 1, :rule-type :production, :rule "Test source", :generation 1} {:y 1, :state :grassland, :x 2, :rule-type :production, :rule "Test source", :generation 1}]
|
||||
[{:y 2, :state :grassland, :x 0, :rule-type :production, :rule "Test source", :generation 1} {:y 2, :state :grassland, :x 1, :rule-type :production, :rule "Test source", :generation 1} {:y 2, :state :grassland, :x 2, :rule-type :production, :rule "Test source", :generation 1}]]]
|
||||
actual (transform-world world (list afn))]
|
||||
(is (= actual expected)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue