Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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