Skip to content

gnu-octave/octave-doctest

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.