Created
December 15, 2015 14:57
-
-
Save rcanepa/d0d91d08634b02c84b79 to your computer and use it in GitHub Desktop.
Improve feedback from Clojure function pre/post conditions.
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 string-to-string [s1] | |
{:pre [(or (string? s1) | |
(throw (Exception. (format "Pre-condition failed; %s is not a string." s1))))] | |
:post [(or (string? %) | |
(throw (Exception. (format "Post-condition failed; %s is not a string." %))))]} | |
s1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment