Skip to content

Commit

Permalink
Added tests to epsilon-closure to test functionality with states that…
Browse files Browse the repository at this point in the history
… aren't in sets and also the epsilon closure of a set of states.
  • Loading branch information
davidsantiago committed Mar 16, 2011
1 parent 4a08017 commit 1131f41
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/swangee/nfa_test.clj
Expand Up @@ -15,18 +15,33 @@
:d {nil #{:b :c}}})

(deftest epsilon-closure-test
;; Single states.
(is (= #{:a :b :c}
(epsilon-closure transitions-with-eps
#{:a})))
(epsilon-closure transitions-with-eps :a)))
(is (= #{:b :c}
(epsilon-closure transitions-with-eps
#{:b})))
(epsilon-closure transitions-with-eps :b)))
(is (= #{:c}
(epsilon-closure transitions-with-eps
#{:c})))
(epsilon-closure transitions-with-eps :c)))
(is (= #{:b :c :d}
(epsilon-closure transitions-with-eps
#{:d}))))
(epsilon-closure transitions-with-eps :d)))
;; Single states as sets.
(is (= #{:a :b :c}
(epsilon-closure transitions-with-eps #{:a})))
(is (= #{:b :c}
(epsilon-closure transitions-with-eps #{:b})))
(is (= #{:c}
(epsilon-closure transitions-with-eps #{:c})))
(is (= #{:b :c :d}
(epsilon-closure transitions-with-eps #{:d})))
;; Sets of states
(is (= #{:a :b :c}
(epsilon-closure transitions-with-eps #{:a :b})))
(is (= #{:b :c}
(epsilon-closure transitions-with-eps #{:b :c})))
(is (= #{:b :c :d}
(epsilon-closure transitions-with-eps #{:d})))
(is (= #{:a :b :c :d}
(epsilon-closure transitions-with-eps #{:a :b :c :d}))))

;; For these tests, we use the simple language defined by the
;; regular expression "ab(bb|c)*".
Expand Down

0 comments on commit 1131f41

Please sign in to comment.