Skip to content

gnu-octave/octave-doctest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

fbd9850 · Mar 5, 2024
Feb 25, 2024
Mar 4, 2024
Mar 4, 2024
Mar 2, 2024
Jul 11, 2022
Jan 22, 2019
Nov 14, 2016
Jan 5, 2023
May 10, 2015
Jan 3, 2023
Jul 10, 2015
Jan 5, 2023
Feb 11, 2024
May 12, 2015
Jan 5, 2023
Mar 5, 2024

Repository files navigation

Doctest

The Octave-Forge Doctest package finds specially-formatted blocks of example code within documentation files. It then executes the code and confirms the output is correct. This can be useful as part of a testing framework or simply to ensure that documentation stays up-to-date during software development.

To get started, here is a simple example:

function greet(user)
  % Returns a greeting.
  %
  % >> greet World
  %
  % Hello, World!

  disp(['Hello, ' user '!']);

end

We can test it by invoking doctest greet at the Octave prompt, which will give the following output:

greet .................................................. PASS    1/1

Summary:

   PASS    1/1

1/1 targets passed, 0 without tests.

Doctest also supports Texinfo markup, which is popular in the Octave world, and it provides various toggles and switches for customizing its behavior. The Doctest documentation contains information on all this. Quite appropriately, Doctest can test its own documentation. We also maintain a list of software that is using Doctest.