Some work on flow, mainly code tidy-up
This commit is contained in:
parent
ca3861b505
commit
fb39f1ee9c
36 changed files with 5191 additions and 3995 deletions
30
test/mw_parser/utils_test.clj
Normal file
30
test/mw_parser/utils_test.clj
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
(ns mw-parser.utils-test
|
||||
(:require [clojure.test :refer [deftest is testing]]
|
||||
[mw-parser.utils :refer [assert-type rule? search-tree
|
||||
suitable-fragment? TODO]]))
|
||||
|
||||
(deftest fragment-tests
|
||||
(testing "Functions finding and identifying rule fragments"
|
||||
(let [rule '(:RULE
|
||||
(:IF "if")
|
||||
(:PROPERTY-CONDITION
|
||||
(:SYMBOL "state")
|
||||
(:QUALIFIER (:EQUIVALENCE (:IS "is")))
|
||||
(:SYMBOL "forest"))
|
||||
(:ACTIONS
|
||||
(:SIMPLE-ACTION
|
||||
(:SYMBOL "state")
|
||||
(:BECOMES "should be")
|
||||
(:SYMBOL "climax"))))
|
||||
not-rule [:FROBOZ :foo :bar :ban]]
|
||||
(is (rule? rule))
|
||||
(is (not (rule? not-rule)))
|
||||
(is (= nil (assert-type rule :RULE)))
|
||||
(is (thrown-with-msg?
|
||||
Exception #"Expected a :RULE fragment" (assert-type not-rule :RULE)))
|
||||
(is (= '(:EQUIVALENCE (:IS "is")) (search-tree rule :EQUIVALENCE)))
|
||||
(is (= nil (search-tree rule :EQUIVOCATION)))
|
||||
(is (suitable-fragment? '(:EQUIVALENCE (:IS "is")) :EQUIVALENCE))
|
||||
(is (not (suitable-fragment? :EQUIVALENCE :EQUIVALENCE)))
|
||||
(is (not (suitable-fragment? '(:EQUIVALENCE (:IS "is")) :QUALIFIER)))
|
||||
(is (= (TODO "Froboz") "Froboz")))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue