Skip to content

Instantly share code, notes, and snippets.

@MoriTanosuke
Created March 1, 2011 19:51
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 MoriTanosuke/849749 to your computer and use it in GitHub Desktop.
Save MoriTanosuke/849749 to your computer and use it in GitHub Desktop.
Simple functions to have something testable.
(ns clj-testtest.core)
(defn foo
[a b] (str a ":" b))
(defmacro mfoo
[a b] `(str ~a ":" ~b))
(defn gen-foo
[a b c] (defn a [b c] (str b ":" c)))
(ns clj-testtest.test.core
(:use [clj-testtest.core] :reload)
(:use [clojure.test]))
(deftest test-simple
(is (not (= 5 (+ 2 2)))))
(deftest test-foo
(is (= "a:b" (foo 'a 'b))))
(deftest test-foo-numbers
(is (= "5:7" (foo 5 7))))
(deftest test-foo-strings
(is (= "eins:zwei" (foo "eins" "zwei"))))
(deftest test-foo-broken
(is (not (= "eins:zwei" (foo "eins" 7))))
(is (= "eins:7" (foo "eins" 7))))
(deftest test-mfoo
(is (= "a:b" (mfoo 'a 'b))))
(deftest test-genfoo
(is (= (foo 'a 'b) ((gen-foo 'foo 'a 'b) 'a 'b))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment