Created
June 21, 2012 07:23
-
-
Save martintrojer/2964379 to your computer and use it in GitHub Desktop.
Generative Testing
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
;; example from ScalaCheck | |
(ns string-tests | |
(:use clojure.test.generative)) | |
(defspec startsWith | |
(partial map identity) | |
[^string a ^string b] | |
(assert (.startsWith (str a b) a))) | |
(defspec concatenate | |
(partial map identity) | |
[^string a ^string b] | |
(let [s (str a b)] | |
(assert (>= (.length s) (.length a))) | |
(assert (>= (.length s) (.length b))))) | |
(defspec substring | |
(partial map identity) | |
[^string a ^string b ^string c] | |
(let [s (str a b c) | |
al (.length a) | |
bl (.length b)] | |
(assert (= b (.substring s al (+ al bl)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment