Comprehensive and systematic unit testing of all rule language constructs.

This commit is contained in:
Simon Brooke 2014-07-17 09:51:53 +01:00
parent 98f1579869
commit 540e8df404
2 changed files with 340 additions and 43 deletions

View file

@ -109,12 +109,12 @@
([tokens]
(parse-value tokens false)))
(defn- parse-member-condition
(defn parse-member-condition
"Parses a condition of the form '[property] in [value] or [value]...'"
[[property IS IN & rest]]
(if (and (member? IS '("is" "are")) (= IN "in"))
(let [[l remainder] (parse-disjunct-value (cons "in" rest) false)]
[(list 'member? (keyword property) l) remainder])))
[(list 'member? (list (keyword property) 'cell) (list 'quote l)) remainder])))
(defn- parse-less-condition
"Parse '[property] less than [value]'."
@ -218,9 +218,9 @@
(cond (and (= comp1 "equal") (= comp2 "to"))
(gen-neighbours-condition '= quantity property value remainder =)
(and (= comp1 "more") (= comp2 "than"))
(gen-neighbours-condition '> quantity property value remainder >)
(gen-neighbours-condition '= quantity property value remainder >)
(and (= comp1 "less") (= comp2 "than"))
(gen-neighbours-condition '< quantity property value remainder <)
(gen-neighbours-condition '= quantity property value remainder <)
))))))
(defn parse-neighbours-condition