Mercurial > hg > octave-nkf
changeset 12505:6a1fe83fe129
Allow command forms of example and demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sat, 26 Feb 2011 18:15:48 -0500 |
parents | d1758f03a2ec |
children | 0dda50ae4997 20cb178716ee |
files | scripts/ChangeLog scripts/testfun/demo.m scripts/testfun/example.m |
diffstat | 3 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -61,6 +61,11 @@ * special-matrix/pascal.m: Fix incorrect statement in documentation for pascal.m. Bug #32523. +2011-02-26 Andy Buckle <andybuckle@gmail.com> + + * testfun/demo.m, testfun/example.m: Allow command forms of example + and demo. + 2011-02-26 Robert T. Short <octave@phaselockedsystems.com> * polynomial/polyval.m: Compute offset/normalization only when needed.
--- a/scripts/testfun/demo.m +++ b/scripts/testfun/demo.m @@ -17,7 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} demo ('@var{name}', @var{n}) +## @deftypefn {Command} {} demo @var{name} @var{n} +## @deftypefnx {Function File} {} demo ('@var{name}', @var{n}) ## ## Runs any examples associated with the function '@var{name}'. ## Examples are stored in the script file, or in a file with the same @@ -87,7 +88,9 @@ if (nargin < 2) n = 0; - endif + elseif (strcmp ("char", class (n))) + n = str2double (n); + endif [code, idx] = test (name, "grabdemo"); if (length (idx) == 0)
--- a/scripts/testfun/example.m +++ b/scripts/testfun/example.m @@ -17,7 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} example ('@var{name}', @var{n}) +## @deftypefn {Command} {} example @var{name} @var{n} +## @deftypefnx {Function File} {} example ('@var{name}', @var{n}) ## @deftypefnx {Function File} {[@var{x}, @var{idx}] =} example ('@var{name}', @var{n}) ## ## Display the code for example @var{n} associated with the function @@ -37,9 +38,12 @@ if (nargin < 1 || nargin > 2) print_usage (); endif + if (nargin < 2) n = 0; - endif + elseif (strcmp ("char", class (n))) + n = str2double (n); + endif [code, idx] = test (name, "grabdemo"); if (nargout > 0)