changeset 16216:70c47da7e02b

maint: periodic merge of stable to default
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 07 Mar 2013 13:08:59 -0500
parents 6fe6ac8bbfdb (current diff) ee041a93c755 (diff)
children 1f1e248caeab
files doc/interpreter/io.txi doc/interpreter/testfun.txi scripts/testfun/fail.m
diffstat 3 files changed, 54 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/io.txi	Thu Mar 07 10:02:13 2013 -0800
+++ b/doc/interpreter/io.txi	Thu Mar 07 13:08:59 2013 -0500
@@ -178,10 +178,6 @@
 
 @DOCSTRING(save)
 
-@DOCSTRING(load)
-
-@DOCSTRING(fileread)
-
 There are three functions that modify the behavior of @code{save}.
 
 @DOCSTRING(default_save_options)
@@ -190,6 +186,10 @@
 
 @DOCSTRING(save_header_format_string)
 
+@DOCSTRING(load)
+
+@DOCSTRING(fileread)
+
 @DOCSTRING(native_float_format)
 
 It is possible to write data to a file in a similar way to the
--- a/doc/interpreter/testfun.txi	Thu Mar 07 10:02:13 2013 -0800
+++ b/doc/interpreter/testfun.txi	Thu Mar 07 13:08:59 2013 -0500
@@ -267,6 +267,45 @@
 @end group
 @end example
 
+@noindent
+The following trivial code snippet provides examples for the use of
+fail, assert, error and xtest:
+
+@example
+@group
+function output = must_be_zero (@var{input})
+  if (@var{input} != 0)
+    error ("Non-zero input!")
+  endif
+  output = input;
+endfunction
+
+%!fail ("must_be_zero (1)");
+%!assert (must_be_zero (0), 0);
+%!error <Non-zero> must_be_zero (1);
+%!xtest error ("This code generates an error");
+@end group
+@end example
+
+@noindent
+When putting this a file @file{must_be_zero.m}, and running the test, we see
+
+@example
+@group
+test must_be_zero verbose
+
+@result{}
+>>>>> /path/to/must_be_zero.m
+  ***** fail ("must_be_zero (1)");
+  ***** assert (must_be_zero (0), 0);
+  ***** error <Non-zero> must_be_zero (1);
+  ***** xtest error ("This code generates an error");
+!!!!! known failure
+This code generates an error
+PASSES 4 out of 4 tests (1 expected failures)
+@end group
+@end example
+
 @subsubheading Block type summary:
 
 @table @code
--- a/scripts/testfun/fail.m	Thu Mar 07 10:02:13 2013 -0800
+++ b/scripts/testfun/fail.m	Thu Mar 07 13:08:59 2013 -0500
@@ -29,10 +29,19 @@
 ## is a string and if @var{code} runs successfully, the error produced is:
 ##
 ## @example
-##           expected error but got none
+##           expected error <.> but got none
 ## @end example
 ##
-## If the code fails with a different error, the message produced is:
+##
+## Code must be in the form of a string that may be passed by
+## @code{fail} to the Octave interpreter via the @code{evalin} function,
+## that is, a (quoted) string constant or a string variable.
+##
+## If called with two arguments, the behavior is similar to
+## @code{fail (@var{code})}, except the return value will only be true if
+## code fails with an error message containing pattern (case sensitive).
+## If the code fails with a different error to that given in pattern,
+## the message produced is:
 ##
 ## @example
 ## @group