Created
March 15, 2014 21:03
-
-
Save aaronj1335/9573879 to your computer and use it in GitHub Desktop.
re-bind a random number generator for 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
(ns my-lib.core) | |
(def my-rand rand) | |
(defn my-fn [] | |
(take 3 (repeatedly my-rand))) |
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 my-lib.core-test | |
(:require [clojure.test :refer :all] | |
[my-lib.core as core])) | |
; i'd like to re-bind the my-rand function here to make testing easier, but this doesn't work | |
(def core/my-rand (constantly 1)) | |
(deftest my-fn | |
(is (= (core/my-fn) '(1 1 1)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment