changeset 16247:4dc4da5970e5

doc: Clarify how indentation defines %!test blocks. * doc/interpreter/testfun.txi: Clarify how indentation defines %!test blocks.
author Rik <rik@octave.org>
date Mon, 11 Mar 2013 11:07:39 -0700
parents 98d8d1f4b7f8
children 6601c66280c4
files doc/interpreter/testfun.txi
diffstat 1 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/testfun.txi	Mon Mar 11 10:49:44 2013 -0700
+++ b/doc/interpreter/testfun.txi	Mon Mar 11 11:07:39 2013 -0700
@@ -41,8 +41,12 @@
 
 Since @code{eval()} will stop at the first error it encounters, you must
 divide your tests up into blocks, with anything in a separate
-block evaluated separately.  Blocks are introduced by the keyword
-@code{test} immediately following @samp{%!}.  For example:
+block evaluated separately.  Blocks are introduced by valid keywords like
+@code{test}, @code{function}, or @code{assert} immediately following @samp{%!}.
+A block is defined by indentation as in Python.  Lines beginning with
+@samp{%!<whitespace>} are part of the preceeding block.
+ 
+For example:
 
 @example
 @group
@@ -197,6 +201,24 @@
 Note that all previous variables and values are lost when a new 
 shared block is declared.
 
+Remember that @code{%!function} begins a new block and that 
+@code{%!endfunction} ends this block.  Be aware that until a new block
+is started, lines starting with @samp{%!<space>} will be discarded as comments.
+The following is nearly identical to the example above, but does nothing.
+
+@example
+@group
+%!function @var{a} = fn (@var{b})
+%!  @var{a} = 2*@var{b};
+%!endfunction
+%! assert (fn(2), 4);
+@end group
+@end example
+
+@noindent
+Because there is a space after @samp{%!} the @code{assert} statement does
+not begin a new block and this line is treated as a comment.
+
 Error and warning blocks are like test blocks, but they only succeed 
 if the code generates an error.  You can check the text of the error
 is correct using an optional regular expression @code{<pattern>}.