Skip to content

Instantly share code, notes, and snippets.

@aaronj1335
Created March 15, 2014 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronj1335/9573879 to your computer and use it in GitHub Desktop.
Save aaronj1335/9573879 to your computer and use it in GitHub Desktop.
re-bind a random number generator for testing
(ns my-lib.core)
(def my-rand rand)
(defn my-fn []
(take 3 (repeatedly my-rand)))
(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