Mercurial > hg > octave-lyh
diff scripts/testfun/demo.m @ 15079:dda73cb60ac5
demo.m: Allow functions in demo blocks (bug #33981).
* demo.m: Remove regexp code that checks for embedded functions in
demo blocks and issues an error.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 01 Aug 2012 16:44:16 -0700 |
parents | 5d3a684236b0 |
children | bcace51598ed |
line wrap: on
line diff
--- a/scripts/testfun/demo.m +++ b/scripts/testfun/demo.m @@ -123,19 +123,11 @@ ## Process each demo without failing try block = code(idx(doidx(i)):idx(doidx(i)+1)-1); - ## FIXME: need to check for embedded test functions, which cause - ## segfaults, until issues with subfunctions in functions are resolved. - embed_func = regexp (block, '^\s*function ', 'once', 'lineanchors'); - if (isempty (embed_func)) - ## Use an environment without variables - eval (cstrcat ("function __demo__ ()\n", block, "\nendfunction")); - ## Display the code that will be executed before executing it - printf ("%s example %d:%s\n\n", name, doidx(i), block); - __demo__; - else - error (["Functions embedded in %!demo blocks are not allowed.\n", ... - "Use the %!function/%!endfunction syntax instead to define shared functions for testing.\n"]); - endif + ## Use an environment without variables + eval (cstrcat ("function __demo__ ()\n", block, "\nendfunction")); + ## Display the code that will be executed before executing it + printf ("%s example %d:%s\n\n", name, doidx(i), block); + __demo__; catch ## Let the programmer know which demo failed. printf ("%s example %d: failed\n%s\n", name, doidx(i), lasterr ());