Created
January 22, 2010 22:47
-
-
Save tjennings/284250 to your computer and use it in GitHub Desktop.
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 probe) | |
(use 'clojure.contrib.seq-utils) | |
(defmacro property | |
([doc] | |
`(println "Pending - " ~doc)) | |
([doc test] | |
`(if ~test | |
(println "passed! " '~test) | |
(println "failed! " '~test))) | |
([doc data test] | |
`(let [x 10] | |
(if ~test | |
(println "passed! " '~test) | |
(println "failed! " '~test))))) | |
(defn run-tests [raw-arglists assertion original-expression] | |
(cons original-expression | |
(map (fn [raw-arglist] | |
(let [arglist (if (sequential? raw-arglist) raw-arglist [raw-arglist])] | |
(if (apply assertion arglist) | |
[true arglist] | |
[false arglist]) | |
)) | |
raw-arglists)) | |
) | |
(defmacro for-all [generator bindings expr] | |
`(run-tests | |
(~generator) (fn [~@bindings] ~expr) '~expr) | |
) | |
(defn context [doc & rest] | |
(cons doc rest)) | |
(defn my-pretty-print [stuff prefix] | |
(if (string? (first stuff)) | |
(do (println (first stuff) (my-pretty-print (rest stuff) (str " " prefix)))) | |
(map (fn [for-all-result] (println prefix for-all-result)) stuff)) | |
) | |
(defn testing [& rest] | |
(println (pretty-print rest)) | |
(my-pretty-print rest "") | |
"That's all, folks") | |
(def ansi-red "\033[31m") | |
(def ansi-green "\033[32m") | |
(def ansi-brown "\033[33m") | |
(def ansi-default "\033[0m") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment