Code covered by the BSD License  

Highlights from
Doctest - embed testable examples in your function's help comments

Doctest - embed testable examples in your function's help comments

by

 

27 Sep 2010 (Updated )

Put a usage example in the help of your function, then test it to make sure it still works over time

errors.m
% Errors and doctest - demonstrates a current limitation of doctest
%
% This one works fine.
%
% >> not_a_real_function(42)
% ??? Undefined function or method 'not_a_real_function' for input
% arguments of type 'double'.
%
%
% This one breaks.
%
% >> disp('if at first you don''t succeed...'); error('nevermind')
% if at first you don't succeed...
% ??? nevermind

Contact us