Fixed all failing tests. Two issues:
1. The regression test failures were both errors in the tests rather than in the code under test; 2. The failure in the 'bulk' test relates to the fact that the new declarative parser cannot cope with trailing whitespace.
This commit is contained in:
parent
ddf967088e
commit
88d707a32e
4 changed files with 18 additions and 16 deletions
|
|
@ -7,18 +7,19 @@
|
|||
(testing "Bulk (file) parsing and compilation"
|
||||
(is (= (count (parse-file (as-file "resources/rules.txt"))) 15)
|
||||
"Should parse all rules and throw no exceptions")
|
||||
(is (empty?
|
||||
(remove #(= % 'fn)
|
||||
(map first
|
||||
(parse-file
|
||||
(is (empty?
|
||||
(remove #(= % ':RULE)
|
||||
(map first
|
||||
(parse-file
|
||||
(as-file "resources/rules.txt")))))
|
||||
"all parsed rules should be lambda sexprs")
|
||||
(is (= (count (compile-file (as-file "resources/rules.txt"))) 15)
|
||||
"Should compile all rules and throw no exceptions")
|
||||
(is (empty?
|
||||
(remove ifn?
|
||||
(map first
|
||||
(compile-file
|
||||
(remove ifn?
|
||||
(map first
|
||||
(compile-file
|
||||
(as-file "resources/rules.txt")))))
|
||||
"all compiled rules should be ifns")
|
||||
))
|
||||
|
||||
|
|
|
|||
|
|
@ -475,12 +475,13 @@
|
|||
|
||||
(deftest regression-tests
|
||||
(testing "Rule in default set which failed on switchover to declarative rules"
|
||||
(let [afn (compile-rule "if state is scrub then 1 chance in 5 state should be forest")
|
||||
(let [afn (compile-rule "if state is scrub then 1 chance in 1 state should be forest")
|
||||
world (transform-world
|
||||
(make-world 3 3)
|
||||
(list (compile-rule "if x is 2 then altitude should be 11")
|
||||
(compile-rule "if x is less than 2 then state should be scrub")))]
|
||||
(is (= (:state (apply afn (list {:x 1 :y 1} world))) :forest)
|
||||
(is (= (:state (apply afn (list (get-cell world 1 1) world))) :forest)
|
||||
"Centre cell is scrub, so rule should fire")
|
||||
(is (= (:state (apply afn (list {:x 2 :y 1} world))) :beach)
|
||||
(is (= (apply afn (list (get-cell world 2 1) world)) nil)
|
||||
"Middle cell of the strip is not scrub, so rule should not fire."))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue