Skip to content

Instantly share code, notes, and snippets.

@ecmendenhall
Created October 21, 2013 20:45
Show Gist options
  • Save ecmendenhall/7090683 to your computer and use it in GitHub Desktop.
Save ecmendenhall/7090683 to your computer and use it in GitHub Desktop.
A macro for Speclj-style simple-check assertions.
(ns my-great-project.core-spec
(:require [speclj.core :refer :all]
[simple-check.core :as sc]
[simple-check.generators :as gen]
[simple-check.properties :as prop]
[my-great-project.core :refer :all]))
(defmacro check-that [desc n property]
`(it ~desc
(let [check# (sc/quick-check ~n ~property)
passed# (:result check#)]
(when-not passed# (println check#))
(should passed#))))
(describe "Addition"
(check-that "addition is commutative" 100
(prop/for-all [a gen/int
b gen/int]
(= (+ a b) (+ b a)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment