Liking cljdoc? Tell your friends :D

testdoc

GitHub Actions for test workflow GitHub Actions for babashka test workflow GitHub Actions for lint workflow Dependencies Status Clojars Project

Yet another doctest implementation in Clojure

Usage

testdoc extends clojure.test/is macro.

REPL style

=> (require '[clojure.test :as t]
=>          'testdoc.core)
nil

=> (defn myplus
=>   "Add a and b
=>
=>   => (myplus 1 2)
=>   3
=>   => (myplus 2
=>   =>         3)
=>   5"
=>   [a b]
=>   (+ a b))
var?

=> (t/deftest myplus-test
=>   (t/is (testdoc #'myplus)))
var?

=> (t/test-var *1)
nil

Code-first style

(defn mymulti
  "Multiply a and b

  (mymulti 1 2)
  ;; => 2
  (mymulti 2
           3)
  ;; => 6"
  [a b]
  (* a b))
;; => var?

(t/deftest mymulti-test
  (t/is (testdoc #'mymulti)))
;; => var?

(t/test-var *1)
;; => nil

Testing external documents

This document is tested by this library, of course!

(require '[clojure.java.io :as io])
;; => nil

(t/deftest external-document-test
  (t/is (testdoc (slurp (io/file "test/resources/README.adoc")))))
;; => var?

(t/test-var *1)
;; => nil

Other works

License

Copyright © 2018-2020 Masashi Iizuka

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Can you improve this documentation? These fine people already did:
liquidz & Masashi Iizuka
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close