This file contains hidden or 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
;; original | |
(deftest put-get-json-default | |
(let [obj {:value [1 "2" '(3)]} | |
put-ret (client/put c "test-bucket" "test-key" obj) | |
get-ret (client/get c "test-bucket" "test-key")] | |
(is (= (:value obj) | |
(:value (first get-ret)))))) | |
;; my Midje version |
This file contains hidden or 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
;; TESTS | |
;; Destructuring arguments | |
(def actual-plus-one-equals-4 (chatty-checker [actual] (= (inc actual) 4))) | |
(def vec-structured-checker | |
(chatty-checker [ [a b & c]] | |
(and (= a 1) | |
(= b 2) |
This file contains hidden or 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
;; This first swipe at generative-style testing in Midje was super easy: | |
;; first a use of it | |
(defn make-string [] | |
(rand-nth ["a" "b" "c" "d" "e" "f" "g" "i"])) | |
(formula [a (make-string) b (make-string)] | |
(str a b) => #(.startsWith % a)) |
This file contains hidden or 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
(defmacro def+keep-meta [name a-var] | |
`(alter-meta! (def ~name ~a-var) merge (meta ~a-var))) |
This file contains hidden or 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
(defn make-foo [n] | |
(let [foo (atom n)] | |
{:update (fn [n] (reset! foo n)) | |
:inc (fn [] (swap! foo inc)) | |
:status (fn [] (print @foo))} )) | |
(defmacro defobject | |
"doesn't work yet" | |
[name field-vec & methods] | |
(let [methods (partition 3 methods) |
This file contains hidden or 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
;; Example of midje formula | |
(defn make-string | |
"A generator for 'random' string values - could use the ones from test.generative" | |
[] | |
(rand-nth ["a" "b" "c" "d" "e" "f" "g" "i"])) | |
(formula | |
"can now use simple generative-style formulas" | |
[a (make-string) b (make-string)] |
This file contains hidden or 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 leiningen.midje | |
(:refer-clojure :exclude [test]) | |
(:use [bultitude.core :only [namespaces-in-dir namespaces-on-classpath]] ;; changed | |
[leiningen.test :only [*exit-after-tests*]] | |
[leiningen.compile :only [eval-in-project]] | |
[clojure.set :only [difference]])) | |
;; ... | |
This file contains hidden or 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 ^{:doc "Midje's special blend of generative-style testing."} | |
midje.ideas.formulas | |
(:use [midje.util.form-utils :only [pop-docstring]] | |
[midje.error-handling.validation-errors :only [simple-report-validation-error validate when-valid]] | |
[midje.ideas.arrows :only [leaves-contain-arrow?]])) | |
(def ^{:doc "The number of facts generated per formula." | |
:dynamic true} | |
*num-generations-per-formula* 100) |
This file contains hidden or 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
(def g | |
[[:a1 :rdf/type :sdx/FederationService] | |
[:a1 :sdx/exposesServices :a2] | |
[:a2 :rdf/type :sdx/ServiceCollection] | |
[:a2 :sdx/service :b1] | |
[:a2 :sdx/service :c1] | |
[:a2 :sdx/service :d1] | |
[:b1 :rdf/type :sdx/FederatedService] | |
[:b1 :sdx/exposesServices :b2] |
This file contains hidden or 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
(defmacro defworld [name bindings & body] | |
`(defn ~name ~bindings | |
(fn [~'world] | |
(println ~'world) | |
~@body))) | |
(defmacro with-world [& body] | |
`(domonad state-m | |
~@body)) |