Interesting! Unit tests show the bug is not in merge-rules, as thought,
but in add-rule.
This commit is contained in:
parent
68fafdab99
commit
aad3cd6b58
|
@ -23,7 +23,6 @@
|
|||
rules: a rule tree (i.e. a recursively nested map token => rule-tree);
|
||||
path: a flat sequence of tokens."
|
||||
[rules path]
|
||||
(prn "Rule: " path)
|
||||
(cond
|
||||
;; if we have no more path, we're done.
|
||||
(empty? path) nil
|
||||
|
|
39
test/milkwood_clj/analyse_test.clj
Normal file
39
test/milkwood_clj/analyse_test.clj
Normal file
|
@ -0,0 +1,39 @@
|
|||
(ns milkwood-clj.analyse-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[milkwood-clj.analyse :refer :all]))
|
||||
|
||||
(deftest flat-rule-test
|
||||
(testing "Create a rule set with a single rule"
|
||||
(is (= (add-rule nil '("a" "b" "c" "d")) '{"a" {"b" {"c" {"d" nil}}}}))))
|
||||
|
||||
(deftest two-distinct-rule-test
|
||||
(testing "Create a set of two rules with no common tokens"
|
||||
(is
|
||||
(=
|
||||
(add-rule (add-rule nil '("a" "b" "c" "d")) '("a" "b" "e" "f"))
|
||||
'{"a" {"b" {"c" {"d" nil} "e" {"f" nil}}}}))))
|
||||
|
||||
(deftest two-fork-rule-test
|
||||
(testing "Create a set of two rules with common initial tokens"
|
||||
(is
|
||||
(=
|
||||
(add-rule (add-rule nil '("a" "b" "c" "d")) '("p" "q" "r" "s"))
|
||||
'{"a" {"b" {"c" {"d" nil}}} "p" {"q" {"r" {"s" nil}}}}))))
|
||||
|
||||
(deftest merge-two-rules
|
||||
(testing "Merge two rule trees each comprising a single rule, with no tokens common between trees"
|
||||
(is
|
||||
(=
|
||||
(merge-rules
|
||||
(add-rule nil '("a" "b" "c" "d"))
|
||||
(add-rule nil '("p" "q" "r" "s")))
|
||||
'{"a" {"b" {"c" {"d" nil}}} "p" {"q" {"r" {"s" nil}}}}))))
|
||||
|
||||
(deftest merge-fork-rules
|
||||
(testing "Merge two rule tees each comprising a single rule, with common initial tokens"
|
||||
(is
|
||||
(=
|
||||
(merge-rules
|
||||
(add-rule nil '("a" "b" "c" "d"))
|
||||
(add-rule nil '("a" "b" "e" "f")))
|
||||
'{"a" {"b" {"c" {"d" nil} "e" {"f" nil}}}}))))
|
7
test/milkwood_clj/core_test.clj
Normal file
7
test/milkwood_clj/core_test.clj
Normal file
|
@ -0,0 +1,7 @@
|
|||
(ns milkwood-clj.core-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[milkwood-clj.core :refer :all]))
|
||||
|
||||
(deftest a-test
|
||||
(testing "Nothing worth testing in core, yet."
|
||||
(is (= 1 1))))
|
Loading…
Reference in a new issue