# HG changeset patch # User Rik # Date 1343864656 25200 # Node ID dda73cb60ac507f7b172a60203f0cdf66748f747 # Parent fe4752f772e29f95737a83a362d73a7efb9e2d3b 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. diff -r fe4752f772e2 -r dda73cb60ac5 scripts/testfun/demo.m --- a/scripts/testfun/demo.m Wed Aug 01 17:00:12 2012 -0500 +++ b/scripts/testfun/demo.m Wed Aug 01 16:44:16 2012 -0700 @@ -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 ());