Created
July 27, 2012 14:39
-
-
Save adolfont/3188402 to your computer and use it in GitHub Desktop.
Tests e Classe KE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ke) | |
(defrecord AtomicFormula [name]) | |
;; RUIM | |
(defmethod print-method AtomicFormula [o w] | |
(print-simple | |
(str (:name o)) | |
w | |
) | |
) | |
; aprender a imprimir com método | |
;(defmethod to-string AtomicFormula [o] | |
; (str (:name o)) | |
;) | |
(defrecord UnaryFormula [connective subformula]) | |
(defrecord BinaryFormula [connective left-subformula right-subformula]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ke-tests | |
(:use clojure.test) | |
(:use ke)) | |
; Atomic Formulas | |
(def anAtom (->AtomicFormula "A")) | |
(deftest test-atom-1 | |
(is (= "A" (:name anAtom)))) | |
; Unary Formulas | |
(def aUnaryFormula (->UnaryFormula :not anAtom)) | |
(deftest test-unary-formula-1 | |
(is (= :not (:connective aUnaryFormula)))) | |
(deftest test-unary-formula-2 | |
(is (= anAtom (:subformula aUnaryFormula)))) | |
; Binary Formulas | |
(def aBinaryFormula (->BinaryFormula :and anAtom aUnaryFormula)) | |
(deftest test-binary-formula-1 | |
(is (= :and (:connective aBinaryFormula)))) | |
(deftest test-binary-formula-2 | |
(is (= anAtom (:left-subformula aBinaryFormula)))) | |
(deftest test-binary-formula-3 | |
(is (= aUnaryFormula (:right-subformula aBinaryFormula)))) | |
; Printing tests | |
;(println anAtom) | |
;(println aUnaryFormula) | |
;(println aBinaryFormula) | |
(run-tests) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment