Hi, Am 18.11.2008 um 00:13 schrieb Frantisek Sodomka:
B) What about 'throws' macro? Could this become a function returningtrue/false? Then we could stick it inside 'is' or 'all-true'. (I guess itdoesn't matter that much, does it?)
I have a is-like construct, which is build-up slightly different. Instead of checking, what I get, I immediatelly dispatch to a multimethod. (defmacro is [t msg] (is* t msg)) (defmulti is* (fn [t _] (first t))) (defmethod is* :default `(simply-run-t-here ...)) (defmethod is* nil `(always-fail ...)) (defmethod is* '= `(do-test-here ...)) (defmethod is* 'not= `(do-test-here ...)) (defmethod is* 'instance? `(do-test-here ...)) (defmethod is* 'throwing? `(do-test-here ...)) So it is easy to extend is with other tests, while still being able to provide diagnostics in case a test should fail. Furthermore I use a test driver function, which reduces the repition to a minimum. It takes care to run the tests in a try, report the result and provide diagnostics in case of a failure. Then each methods above just has to specify in a callback how the actual test is carried out and what kind diagnostics should be printed. (eg. compare assert-expr for = and instance?. They are very similar.) What do you think about such a structure? Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature