Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

riscy/doctest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

Doctest for Emacs (archive)

This package has a new home: https://github.com/ag91/doctest

Description

These are like a Python “doctest”, but for Emacs Lisp and with an Emacs twist. A doctest is a test written inside a docstring that looks like:

(defun plus (arg1 arg2)
  "Return sum of ARG1 and ARG2.
>> (plus 1 1)
=> 2
>> (plus (plus 5 3) 2)  ; with nesting
=> 10
>> (format \"%s\" (plus 1 2))
=> \"3\""
  (+ arg1 arg2))

There are benefits:

  • It’s a clean way to test elisp code without any heavy dependencies
  • It encourages functions that are pure or at least side-effect-free
  • Your unit tests turn into documentation that your users can read!

Usage

  • Use M-x doctest to run doctests on an entire buffer.
  • Use M-x doctest-here to run the doctest on the current line.
  • Use M-x doctest-defun to run the current defun’s doctests.

Related

  • Python doctest, the original
  • Elixir supports doctests
  • I copied the use of >> and => to mark input and output from Ruby doctest; prefixing output with => is useful because checkdoc complains if lines start with an opening parentheses, which will happen often in elisp code.

About

Doctests for Emacs Lisp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published