annotate doc/interpreter/testfun.txi @ 19593:446c46af4b42 stable

strip trailing whitespace from most source files * Makefile.am, NEWS, build-aux/common.mk, configure.ac, doc/Makefile.am, doc/doxyhtml/Makefile.am, doc/interpreter/Makefile.am, doc/interpreter/arith.txi, doc/interpreter/audio.txi, doc/interpreter/basics.txi, doc/interpreter/bugs.txi, doc/interpreter/container.txi, doc/interpreter/cp-idx.txi, doc/interpreter/data.txi, doc/interpreter/debug.txi, doc/interpreter/diagperm.txi, doc/interpreter/diffeq.txi, doc/interpreter/doccheck/README, doc/interpreter/doccheck/spellcheck, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/fn-idx.txi, doc/interpreter/func.txi, doc/interpreter/geometry.txi, doc/interpreter/geometryimages.m, doc/interpreter/gpl.txi, doc/interpreter/grammar.txi, doc/interpreter/gui.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/interpimages.m, doc/interpreter/intro.txi, doc/interpreter/io.txi, doc/interpreter/java.txi, doc/interpreter/linalg.txi, doc/interpreter/macros.texi, doc/interpreter/matrix.txi, doc/interpreter/munge-texi.pl, doc/interpreter/nonlin.txi, doc/interpreter/numbers.txi, doc/interpreter/obsolete.txi, doc/interpreter/octave-config.1, doc/interpreter/octave.texi, doc/interpreter/oop.txi, doc/interpreter/op-idx.txi, doc/interpreter/optim.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/poly.txi, doc/interpreter/preface.txi, doc/interpreter/quad.txi, doc/interpreter/set.txi, doc/interpreter/signal.txi, doc/interpreter/sparse.txi, doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m, doc/interpreter/stats.txi, doc/interpreter/stmt.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/testfun.txi, doc/interpreter/tips.txi, doc/interpreter/var.txi, doc/interpreter/vectorize.txi, doc/liboctave/Makefile.am, doc/liboctave/array.texi, doc/liboctave/bugs.texi, doc/liboctave/cp-idx.texi, doc/liboctave/dae.texi, doc/liboctave/diffeq.texi, doc/liboctave/error.texi, doc/liboctave/factor.texi, doc/liboctave/fn-idx.texi, doc/liboctave/gpl.texi, doc/liboctave/install.texi, doc/liboctave/intro.texi, doc/liboctave/liboctave.texi, doc/liboctave/matvec.texi, doc/liboctave/nleqn.texi, doc/liboctave/nlfunc.texi, doc/liboctave/ode.texi, doc/liboctave/optim.texi, doc/liboctave/preface.texi, doc/liboctave/quad.texi, doc/liboctave/range.texi, doc/refcard/Makefile.am, doc/refcard/refcard.tex, etc/HACKING, etc/NEWS.1, etc/NEWS.2, etc/NEWS.3, etc/OLD-ChangeLogs/ChangeLog, etc/OLD-ChangeLogs/doc-ChangeLog, etc/OLD-ChangeLogs/scripts-ChangeLog, etc/OLD-ChangeLogs/src-ChangeLog, etc/OLD-ChangeLogs/test-ChangeLog, etc/PROJECTS, etc/README.Cygwin, etc/README.MacOS, etc/README.MinGW, etc/README.gnuplot, etc/gdbinit, etc/icons/Makefile.am, examples/@polynomial/end.m, examples/@polynomial/subsasgn.m, examples/Makefile.am, examples/standalonebuiltin.cc, libgui/Makefile.am, libgui/qterminal/libqterminal/README, libgui/qterminal/libqterminal/unix/BlockArray.cpp, libgui/qterminal/libqterminal/unix/BlockArray.h, libgui/qterminal/libqterminal/unix/Character.h, libgui/qterminal/libqterminal/unix/CharacterColor.h, libgui/qterminal/libqterminal/unix/Emulation.cpp, libgui/qterminal/libqterminal/unix/Emulation.h, libgui/qterminal/libqterminal/unix/Filter.cpp, libgui/qterminal/libqterminal/unix/Filter.h, libgui/qterminal/libqterminal/unix/History.cpp, libgui/qterminal/libqterminal/unix/History.h, libgui/qterminal/libqterminal/unix/KeyboardTranslator.cpp, libgui/qterminal/libqterminal/unix/KeyboardTranslator.h, libgui/qterminal/libqterminal/unix/LineFont.h, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h, libgui/qterminal/libqterminal/unix/Screen.cpp, libgui/qterminal/libqterminal/unix/Screen.h, libgui/qterminal/libqterminal/unix/ScreenWindow.cpp, libgui/qterminal/libqterminal/unix/ScreenWindow.h, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.h, libgui/qterminal/libqterminal/unix/Vt102Emulation.h, libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp, libgui/qterminal/qterminal/main.cpp, libgui/src/m-editor/file-editor-tab.cc, libgui/src/octave-gui.cc, libgui/src/octave-qt-link.cc, libinterp/corefcn/data.cc, libinterp/corefcn/defun-int.h, libinterp/corefcn/det.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/oct-tex-parser.yy, libinterp/corefcn/oct-tex-symbols.in, libinterp/corefcn/quadcc.cc, libinterp/corefcn/zfstream.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/gendoc.pl, libinterp/genprops.awk, libinterp/mk-errno-list, libinterp/mk-pkg-add, libinterp/mkbuiltins, libinterp/mkdefs, libinterp/mkdocs, libinterp/mkops, libinterp/octave-value/ov-java.cc, libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/octave.gperf, liboctave/Makefile.am, liboctave/array/Array.cc, liboctave/array/module.mk, liboctave/cruft/daspk/datv.f, liboctave/cruft/daspk/dcnst0.f, liboctave/cruft/daspk/dcnstr.f, liboctave/cruft/daspk/ddasic.f, liboctave/cruft/daspk/ddasid.f, liboctave/cruft/daspk/ddasik.f, liboctave/cruft/daspk/ddaspk.f, liboctave/cruft/daspk/ddstp.f, liboctave/cruft/daspk/ddwnrm.f, liboctave/cruft/daspk/dfnrmd.f, liboctave/cruft/daspk/dfnrmk.f, liboctave/cruft/daspk/dhels.f, liboctave/cruft/daspk/dheqr.f, liboctave/cruft/daspk/dinvwt.f, liboctave/cruft/daspk/dlinsd.f, liboctave/cruft/daspk/dlinsk.f, liboctave/cruft/daspk/dmatd.f, liboctave/cruft/daspk/dnedd.f, liboctave/cruft/daspk/dnedk.f, liboctave/cruft/daspk/dnsd.f, liboctave/cruft/daspk/dnsid.f, liboctave/cruft/daspk/dnsik.f, liboctave/cruft/daspk/dnsk.f, liboctave/cruft/daspk/dorth.f, liboctave/cruft/daspk/dslvd.f, liboctave/cruft/daspk/dslvk.f, liboctave/cruft/daspk/dspigm.f, liboctave/cruft/daspk/dyypnw.f, liboctave/cruft/dasrt/ddasrt.f, liboctave/cruft/dasrt/drchek.f, liboctave/cruft/dassl/ddaslv.f, liboctave/cruft/dassl/ddassl.f, liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/module.mk, liboctave/cruft/odepack/cfode.f, liboctave/cruft/odepack/dlsode.f, liboctave/cruft/odepack/ewset.f, liboctave/cruft/odepack/intdy.f, liboctave/cruft/odepack/prepj.f, liboctave/cruft/odepack/sintdy.f, liboctave/cruft/odepack/slsode.f, liboctave/cruft/odepack/solsy.f, liboctave/cruft/odepack/ssolsy.f, liboctave/cruft/odepack/stode.f, liboctave/cruft/odepack/vnorm.f, liboctave/cruft/ranlib/Basegen.doc, liboctave/cruft/ranlib/README, liboctave/cruft/ranlib/genbet.f, liboctave/cruft/ranlib/genexp.f, liboctave/cruft/ranlib/gennch.f, liboctave/cruft/ranlib/gennf.f, liboctave/cruft/ranlib/gennor.f, liboctave/cruft/ranlib/getsd.f, liboctave/cruft/ranlib/initgn.f, liboctave/cruft/ranlib/phrtsd.f, liboctave/cruft/ranlib/randlib.fdoc, liboctave/cruft/ranlib/setsd.f, liboctave/cruft/ranlib/tstgmn.for, liboctave/cruft/ranlib/tstmid.for, liboctave/cruft/slatec-fn/atanh.f, liboctave/cruft/slatec-fn/datanh.f, liboctave/cruft/slatec-fn/xgmainc.f, liboctave/cruft/slatec-fn/xsgmainc.f, liboctave/numeric/module.mk, liboctave/operators/mk-ops.awk, liboctave/operators/mx-ops, liboctave/operators/sparse-mk-ops.awk, liboctave/operators/sparse-mx-ops, liboctave/operators/vx-ops, liboctave/util/module.mk, run-octave.in, scripts/@ftp/ftp.m, scripts/audio/wavread.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_invoke.m, scripts/deprecated/java_new.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/javafields.m, scripts/deprecated/javamethods.m, scripts/deprecated/shell_cmd.m, scripts/general/accumarray.m, scripts/general/display.m, scripts/general/fieldnames.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/isa.m, scripts/general/methods.m, scripts/general/sortrows.m, scripts/geometry/convhull.m, scripts/geometry/delaunay.m, scripts/geometry/delaunay3.m, scripts/geometry/delaunayn.m, scripts/geometry/griddata.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/geometry/voronoin.m, scripts/gui/guihandles.m, scripts/gui/inputdlg.m, scripts/gui/listdlg.m, scripts/gui/msgbox.m, scripts/gui/questdlg.m, scripts/gui/uigetfile.m, scripts/gui/waitbar.m, scripts/gui/warndlg.m, scripts/help/doc.m, scripts/help/help.m, scripts/help/type.m, scripts/image/bone.m, scripts/image/cmpermute.m, scripts/image/cmunique.m, scripts/image/colorcube.m, scripts/image/colormap.m, scripts/image/contrast.m, scripts/image/gray2ind.m, scripts/image/image.m, scripts/image/imshow.m, scripts/image/ind2gray.m, scripts/image/jet.m, scripts/image/rgb2ntsc.m, scripts/image/spinmap.m, scripts/io/importdata.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/java_get.m, scripts/java/java_set.m, scripts/java/javaaddpath.m, scripts/java/javaclasspath.m, scripts/java/javamem.m, scripts/linear-algebra/linsolve.m, scripts/linear-algebra/qzhess.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/desktop.m, scripts/miscellaneous/dir.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/fact.m, scripts/miscellaneous/getappdata.m, scripts/miscellaneous/inputname.m, scripts/miscellaneous/license.m, scripts/miscellaneous/ls_command.m, scripts/miscellaneous/run.m, scripts/miscellaneous/setfield.m, scripts/miscellaneous/unix.m, scripts/miscellaneous/ver.m, scripts/mk-pkg-add, scripts/mkdoc.pl, scripts/optimization/fminsearch.m, scripts/optimization/optimset.m, scripts/optimization/sqp.m, scripts/pkg/pkg.m, scripts/pkg/private/create_pkgadddel.m, scripts/pkg/private/fix_depends.m, scripts/pkg/private/install.m, scripts/plot/appearance/axis.m, scripts/plot/appearance/box.m, scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m, scripts/plot/appearance/datetick.m, scripts/plot/appearance/grid.m, scripts/plot/appearance/legend.m, scripts/plot/appearance/orient.m, scripts/plot/appearance/shading.m, scripts/plot/appearance/text.m, scripts/plot/appearance/title.m, scripts/plot/appearance/xlabel.m, scripts/plot/appearance/ylabel.m, scripts/plot/appearance/zlabel.m, scripts/plot/draw/area.m, scripts/plot/draw/bar.m, scripts/plot/draw/barh.m, scripts/plot/draw/colorbar.m, scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m, scripts/plot/draw/contourf.m, scripts/plot/draw/ellipsoid.m, scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m, scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m, scripts/plot/draw/ezpolar.m, scripts/plot/draw/fill.m, scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m, scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m, scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m, scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m, scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m, scripts/plot/draw/plotyy.m, scripts/plot/draw/private/__bar__.m, scripts/plot/draw/private/__contour__.m, scripts/plot/draw/private/__errplot__.m, scripts/plot/draw/private/__ezplot__.m, scripts/plot/draw/private/__patch__.m, scripts/plot/draw/private/__stem__.m, scripts/plot/draw/rectangle.m, scripts/plot/draw/ribbon.m, scripts/plot/draw/rose.m, scripts/plot/draw/scatter.m, scripts/plot/draw/scatter3.m, scripts/plot/draw/semilogx.m, scripts/plot/draw/shrinkfaces.m, scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m, scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m, scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m, scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m, scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m, scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m, scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m, scripts/plot/util/__gnuplot_drawnow__.m, scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/axes.m, scripts/plot/util/clf.m, scripts/plot/util/copyobj.m, scripts/plot/util/figure.m, scripts/plot/util/gcbo.m, scripts/plot/util/graphics_toolkit.m, scripts/plot/util/hggroup.m, scripts/plot/util/meshgrid.m, scripts/plot/util/newplot.m, scripts/plot/util/print.m, scripts/plot/util/private/__add_default_menu__.m, scripts/plot/util/private/__fltk_print__.m, scripts/plot/util/private/__gnuplot_print__.m, scripts/plot/util/private/__print_parse_opts__.m, scripts/plot/util/refreshdata.m, scripts/plot/util/subplot.m, scripts/polynomial/conv.m, scripts/polynomial/poly.m, scripts/polynomial/polyeig.m, scripts/polynomial/polyfit.m, scripts/polynomial/polyval.m, scripts/polynomial/private/__splinefit__.m, scripts/polynomial/spline.m, scripts/prefs/prefdir.m, scripts/prefs/preferences.m, scripts/prefs/private/prefsfile.m, scripts/prefs/rmpref.m, scripts/signal/freqz.m, scripts/signal/module.mk, scripts/sparse/eigs.m, scripts/sparse/pcg.m, scripts/sparse/private/__sprand_impl__.m, scripts/sparse/sprand.m, scripts/sparse/sprandn.m, scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/specfun/expint.m, scripts/specfun/factor.m, scripts/special-matrix/gallery.m, scripts/special-matrix/hankel.m, scripts/special-matrix/toeplitz.m, scripts/startup/inputrc, scripts/statistics/base/kurtosis.m, scripts/statistics/base/moment.m, scripts/statistics/base/qqplot.m, scripts/statistics/base/var.m, scripts/statistics/distributions/betarnd.m, scripts/statistics/distributions/binoinv.m, scripts/statistics/distributions/binopdf.m, scripts/statistics/distributions/binornd.m, scripts/statistics/distributions/cauchy_rnd.m, scripts/statistics/distributions/chi2rnd.m, scripts/statistics/distributions/discrete_pdf.m, scripts/statistics/distributions/discrete_rnd.m, scripts/statistics/distributions/empirical_rnd.m, scripts/statistics/distributions/exprnd.m, scripts/statistics/distributions/frnd.m, scripts/statistics/distributions/gamrnd.m, scripts/statistics/distributions/geornd.m, scripts/statistics/distributions/hygernd.m, scripts/statistics/distributions/kolmogorov_smirnov_cdf.m, scripts/statistics/distributions/laplace_cdf.m, scripts/statistics/distributions/laplace_pdf.m, scripts/statistics/distributions/logistic_cdf.m, scripts/statistics/distributions/logistic_pdf.m, scripts/statistics/distributions/lognrnd.m, scripts/statistics/distributions/nbincdf.m, scripts/statistics/distributions/nbininv.m, scripts/statistics/distributions/nbinpdf.m, scripts/statistics/distributions/nbinrnd.m, scripts/statistics/distributions/normrnd.m, scripts/statistics/distributions/poissinv.m, scripts/statistics/distributions/poissrnd.m, scripts/statistics/distributions/tinv.m, scripts/statistics/distributions/trnd.m, scripts/statistics/distributions/unidcdf.m, scripts/statistics/distributions/unidpdf.m, scripts/statistics/distributions/unidrnd.m, scripts/statistics/distributions/unifrnd.m, scripts/statistics/distributions/wblrnd.m, scripts/statistics/models/module.mk, scripts/statistics/tests/kruskal_wallis_test.m, scripts/strings/base2dec.m, scripts/strings/deblank.m, scripts/strings/dec2base.m, scripts/strings/dec2bin.m, scripts/strings/dec2hex.m, scripts/strings/mat2str.m, scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjoin.m, scripts/strings/strsplit.m, scripts/strings/strtok.m, scripts/strings/strtrim.m, scripts/strings/strtrunc.m, scripts/strings/substr.m, scripts/testfun/__run_test_suite__.m, scripts/testfun/speed.m, scripts/testfun/test.m, scripts/time/asctime.m, scripts/time/datenum.m, scripts/time/datevec.m, scripts/time/weekday.m, src/Makefile.am, test/Makefile.am, test/build-bc-overload-tests.sh, test/build-sparse-tests.sh, test/jit.tst, test/line-continue.tst: Strip trailing whitespace.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 08:26:57 -0500
parents f51c1498b9f3
children 0e1f5a750d00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 16248
diff changeset
1 @c Copyright (C) 2005-2013 David Bateman
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
2 @c Copyright (C) 2002-2005 Paul Kienzle
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
3 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
4 @c This file is part of Octave.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
5 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
6 @c Octave is free software; you can redistribute it and/or modify it
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
7 @c under the terms of the GNU General Public License as published by the
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
8 @c Free Software Foundation; either version 3 of the License, or (at
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
9 @c your option) any later version.
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
10 @c
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
11 @c Octave is distributed in the hope that it will be useful, but WITHOUT
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
12 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
13 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
14 @c for more details.
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
15 @c
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
16 @c You should have received a copy of the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
17 @c along with Octave; see the file COPYING. If not, see
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
18 @c <http://www.gnu.org/licenses/>.
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
19
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
20 @node Test and Demo Functions
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
21 @appendix Test and Demo Functions
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
22 @cindex test functions
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
23
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
24 Octave includes a number of functions to allow the integration of testing
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
25 and demonstration code in the source code of the functions themselves.
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
26
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
27 @menu
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
28 * Test Functions::
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
29 * Demonstration Functions::
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
30 @end menu
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
31
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
32 @node Test Functions
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
33 @section Test Functions
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
34
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
35 @DOCSTRING(test)
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
36
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
37 @code{test} scans the named script file looking for lines which start
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
38 with the identifier @samp{%!}. The prefix is stripped off and the rest
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
39 of the line is processed through the Octave interpreter. If the code
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
40 generates an error, then the test is said to fail.
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
41
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
42 Since @code{eval()} will stop at the first error it encounters, you must
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
43 divide your tests up into blocks, with anything in a separate
16247
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
44 block evaluated separately. Blocks are introduced by valid keywords like
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
45 @code{test}, @code{function}, or @code{assert} immediately following @samp{%!}.
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
46 A block is defined by indentation as in Python. Lines beginning with
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
47 @samp{%!<whitespace>} are part of the preceeding block.
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
48
16247
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
49 For example:
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
50
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
51 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
52 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
53 %!test error ("this test fails!");
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
54 %!test "test doesn't fail. it doesn't generate an error";
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
55 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
56 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
57
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
58 When a test fails, you will see something like:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
59
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
60 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
61 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
62 ***** test error ("this test fails!")
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
63 !!!!! test failed
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
64 this test fails!
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
65 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
66 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
67
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
68 Generally, to test if something works, you want to assert that it
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
69 produces a correct value. A real test might look something like
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
70
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
71 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
72 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
73 %!test
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
74 %! @var{a} = [1, 2, 3; 4, 5, 6]; B = [1; 2];
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
75 %! expect = [ @var{a} ; 2*@var{a} ];
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
76 %! get = kron (@var{b}, @var{a});
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
77 %! if (any (size (expect) != size (get)))
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
78 %! error ("wrong size: expected %d,%d but got %d,%d",
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
79 %! size (expect), size (get));
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
80 %! elseif (any (any (expect != get)))
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
81 %! error ("didn't get what was expected.");
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
82 %! endif
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
83 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
84 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
85
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
86 To make the process easier, use the @code{assert} function. For example,
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
87 with @code{assert} the previous test is reduced to:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
88
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
89 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
90 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
91 %!test
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
92 %! @var{a} = [1, 2, 3; 4, 5, 6]; @var{b} = [1; 2];
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
93 %! assert (kron (@var{b}, @var{a}), [ @var{a}; 2*@var{a} ]);
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
94 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
95 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
96
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
97 @code{assert} can accept a tolerance so that you can compare results
9080
ec41eabf4499 Cleanup documentation files dynamic.texi, testfun.texi, tips.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
98 absolutely or relatively. For example, the following all succeed:
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
99
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
100 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
101 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
102 %!test assert (1+eps, 1, 2*eps) # absolute error
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
103 %!test assert (100+100*eps, 100, -2*eps) # relative error
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
104 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
105 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
106
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
107 You can also do the comparison yourself, but still have assert
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
108 generate the error:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
109
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
110 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
111 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
112 %!test assert (isempty ([]))
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
113 %!test assert ([1, 2; 3, 4] > 0)
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
114 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
115 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
116
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
117 Because @code{assert} is so frequently used alone in a test block, there
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
118 is a shorthand form:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
119
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
120 @example
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
121 %!assert (@dots{})
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
122 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
123
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10828
diff changeset
124 @noindent
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
125 which is equivalent to:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
126
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
127 @example
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
128 %!test assert (@dots{})
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
129 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
130
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
131 Occasionally a block of tests will depend on having optional
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
132 functionality in Octave. Before testing such blocks the availability of
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
133 the required functionality must be checked. A @code{%!testif HAVE_XXX}
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
134 block will only be run if Octave was compiled with functionality
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
135 @samp{HAVE_XXX}. For example, the sparse single value decomposition,
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
136 @code{svds()}, depends on having the @sc{arpack} library. All of the tests
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
137 for @code{svds} begin with
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
138
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
139 @example
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
140 %!testif HAVE_ARPACK
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
141 @end example
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
142
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
143 @noindent
16248
6601c66280c4 doc: Mention octave_config_info ("features") as new way of looking for HAVE_XXX targets.
Rik <rik@octave.org>
parents: 16247
diff changeset
144 Review @file{config.h} or @code{octave_config_info ("features")} to see some
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
145 of the possible values to check.
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
146
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
147 Sometimes during development there is a test that should work but is
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
148 known to fail. You still want to leave the test in because when the
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
149 final code is ready the test should pass, but you may not be able to
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6731
diff changeset
150 fix it immediately. To avoid unnecessary bug reports for these known
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
151 failures, mark the block with @code{xtest} rather than @code{test}:
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
152
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
153 @example
9080
ec41eabf4499 Cleanup documentation files dynamic.texi, testfun.texi, tips.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
154 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
155 %!xtest assert (1==0)
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
156 %!xtest fail ("success=1", "error")
9080
ec41eabf4499 Cleanup documentation files dynamic.texi, testfun.texi, tips.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
157 @end group
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
158 @end example
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
159
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
160 @noindent
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
161 In this case, the test will run and any failure will be reported.
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
162 However, testing is not aborted and subsequent test blocks will be
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
163 processed normally. Another use of @code{xtest} is for statistical
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
164 tests which should pass most of the time but are known to fail
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
165 occasionally.
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 5582
diff changeset
166
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
167 Each block is evaluated in its own function environment, which means
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
168 that variables defined in one block are not automatically shared
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
169 with other blocks. If you do want to share variables, then you
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
170 must declare them as @code{shared} before you use them. For example, the
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
171 following declares the variable @var{a}, gives it an initial value (default
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
172 is empty), and then uses it in several subsequent tests.
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
173
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
174 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
175 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
176 %!shared @var{a}
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
177 %! @var{a} = [1, 2, 3; 4, 5, 6];
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
178 %!assert (kron ([1; 2], @var{a}), [ @var{a}; 2*@var{a} ]);
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
179 %!assert (kron ([1, 2], @var{a}), [ @var{a}, 2*@var{a} ]);
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
180 %!assert (kron ([1,2; 3,4], @var{a}), [ @var{a},2*@var{a}; 3*@var{a},4*@var{a} ]);
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
181 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
182 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
183
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
184 You can share several variables at the same time:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
185
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
186 @example
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
187 %!shared @var{a}, @var{b}
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
188 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
189
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
190 You can also share test functions:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
191
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
192 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
193 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
194 %!function @var{a} = fn (@var{b})
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
195 %! @var{a} = 2*@var{b};
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
196 %!endfunction
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
197 %!assert (fn(2), 4);
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
198 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
199 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
200
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
201 Note that all previous variables and values are lost when a new
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
202 shared block is declared.
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
203
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
204 Remember that @code{%!function} begins a new block and that
16247
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
205 @code{%!endfunction} ends this block. Be aware that until a new block
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
206 is started, lines starting with @samp{%!<space>} will be discarded as comments.
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
207 The following is nearly identical to the example above, but does nothing.
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
208
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
209 @example
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
210 @group
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
211 %!function @var{a} = fn (@var{b})
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
212 %! @var{a} = 2*@var{b};
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
213 %!endfunction
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
214 %! assert (fn(2), 4);
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
215 @end group
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
216 @end example
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
217
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
218 @noindent
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
219 Because there is a space after @samp{%!} the @code{assert} statement does
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
220 not begin a new block and this line is treated as a comment.
4dc4da5970e5 doc: Clarify how indentation defines %!test blocks.
Rik <rik@octave.org>
parents: 16216
diff changeset
221
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
222 Error and warning blocks are like test blocks, but they only succeed
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
223 if the code generates an error. You can check the text of the error
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
224 is correct using an optional regular expression @code{<pattern>}.
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
225 For example:
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
226
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
227 @example
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
228 %!error <passes!> error ("this test passes!");
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
229 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
230
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10828
diff changeset
231 If the code doesn't generate an error, the test fails. For example:
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
232
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
233 @example
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
234 %!error "this is an error because it succeeds.";
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
235 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
236
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10828
diff changeset
237 @noindent
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
238 produces
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
239
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
240 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
241 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
242 ***** error "this is an error because it succeeds.";
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
243 !!!!! test failed: no error
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
244 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
245 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
246
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
247 It is important to automate the tests as much as possible, however
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
248 some tests require user interaction. These can be isolated into
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
249 demo blocks, which if you are in batch mode, are only run when
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
250 called with @code{demo} or the @code{verbose} option to @code{test}.
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
251 The code is displayed before it is executed. For example,
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
252
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
253 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
254 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
255 %!demo
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
256 %! @var{t} = [0:0.01:2*pi]; @var{x} = sin (@var{t});
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
257 %! plot (@var{t}, @var{x});
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
258 %! # you should now see a sine wave in your figure window
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
259 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
260 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
261
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10828
diff changeset
262 @noindent
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
263 produces
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
264
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
265 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
266 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
267 funcname example 1:
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
268 @var{t} = [0:0.01:2*pi]; @var{x} = sin (@var{t});
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
269 plot (@var{t}, @var{x});
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
270 # you should now see a sine wave in your figure window
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
271
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18534
diff changeset
272 Press <enter> to continue:
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
273 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
274 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
275
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
276 Note that demo blocks cannot use any shared variables. This is so
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
277 that they can be executed by themselves, ignoring all other tests.
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
278
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
279 If you want to temporarily disable a test block, put @code{#} in place
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
280 of the block type. This creates a comment block which is echoed
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
281 in the log file but not executed. For example:
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
282
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
283 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
284 @group
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
285 %!#demo
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
286 %! @var{t} = [0:0.01:2*pi]; @var{x} = sin (@var{t});
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
287 %! plot (@var{t}, @var{x});
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
288 %! # you should now see a sine wave in your figure window
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
289 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
290 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
291
16190
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
292 @noindent
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
293 The following trivial code snippet provides examples for the use of
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
294 fail, assert, error and xtest:
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
295
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
296 @example
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
297 @group
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
298 function output = must_be_zero (@var{input})
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
299 if (@var{input} != 0)
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
300 error ("Non-zero input!")
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
301 endif
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
302 output = input;
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
303 endfunction
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
304
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
305 %!fail ("must_be_zero (1)");
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
306 %!assert (must_be_zero (0), 0);
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
307 %!error <Non-zero> must_be_zero (1);
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
308 %!xtest error ("This code generates an error");
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
309 @end group
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
310 @end example
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
311
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
312 @noindent
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
313 When putting this a file @file{must_be_zero.m}, and running the test, we see
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
314
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
315 @example
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
316 @group
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
317 test must_be_zero verbose
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
318
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
319 @result{}
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
320 >>>>> /path/to/must_be_zero.m
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
321 ***** fail ("must_be_zero (1)");
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
322 ***** assert (must_be_zero (0), 0);
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
323 ***** error <Non-zero> must_be_zero (1);
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
324 ***** xtest error ("This code generates an error");
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
325 !!!!! known failure
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
326 This code generates an error
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
327 PASSES 4 out of 4 tests (1 expected failures)
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
328 @end group
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
329 @end example
7fe4ea72ba4d doc: Update 'test' and "fail" documentation
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
330
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
331 @subsubheading Block type summary:
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
332
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
333 @table @code
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
334 @item %!test
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
335 check that entire block is correct
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10496
diff changeset
336
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
337 @item %!testif HAVE_XXX
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
338 check block only if Octave was compiled with feature HAVE_XXX.
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
339
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
340 @item %!xtest
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
341 check block, report a test failure but do not abort testing.
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
342
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
343 @item %!error
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
344 check for correct error message
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10496
diff changeset
345
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
346 @item %!warning
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
347 check for correct warning message
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10496
diff changeset
348
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
349 @item %!demo
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
350 demo only executes in interactive mode
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10496
diff changeset
351
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
352 @item %!#
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
353 comment: ignore everything within the block
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10496
diff changeset
354
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
355 @item %!shared x,y,z
13920
9cf8bd0e13d2 doc: Document %!endfunction keyword
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
356 declare variables for use in multiple tests
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10496
diff changeset
357
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
358 @item %!function
13920
9cf8bd0e13d2 doc: Document %!endfunction keyword
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
359 define a function for use in multiple tests
9cf8bd0e13d2 doc: Document %!endfunction keyword
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
360
9cf8bd0e13d2 doc: Document %!endfunction keyword
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
361 @item %!endfunction
9cf8bd0e13d2 doc: Document %!endfunction keyword
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
362 close a function definition
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10496
diff changeset
363
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
364 @item %!assert (x, y, tol)
13920
9cf8bd0e13d2 doc: Document %!endfunction keyword
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
365 shorthand for @code{%!test assert (x, y, tol)}
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
366 @end table
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
367
18534
f51c1498b9f3 doc: Replace "builtin" with "built-in" for consistency and correctness.
Rik <rik@octave.org>
parents: 17744
diff changeset
368 You can also create test scripts for built-in functions and your own C++
f51c1498b9f3 doc: Replace "builtin" with "built-in" for consistency and correctness.
Rik <rik@octave.org>
parents: 17744
diff changeset
369 functions. To do so, put a file with the bare function name (no .m
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
370 extension) in a directory in the load path and it will be discovered by
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
371 the @code{test} function. Alternatively, you can embed tests directly in your
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
372 C++ code:
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
373
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
374 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
375 @group
14093
050bc580cb60 doc: Various docstring improvements before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 14051
diff changeset
376 /*
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
377 %!test disp ("this is a test")
14093
050bc580cb60 doc: Various docstring improvements before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 14051
diff changeset
378 */
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
379 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
380 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
381
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10828
diff changeset
382 @noindent
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
383 or
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
384
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
385 @example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
386 @group
14093
050bc580cb60 doc: Various docstring improvements before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 14051
diff changeset
387 #if 0
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
388 %!test disp ("this is a test")
14093
050bc580cb60 doc: Various docstring improvements before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 14051
diff changeset
389 #endif
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
390 @end group
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
391 @end example
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
392
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10828
diff changeset
393 @noindent
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
394 However, in this case the raw source code will need to be on the load
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
395 path and the user will have to remember to type
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
396 @code{test ("funcname.cc")}.
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
397
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
398 @DOCSTRING(assert)
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
399
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
400 @DOCSTRING(fail)
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
401
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
402 @node Demonstration Functions
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
403 @section Demonstration Functions
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
404
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
405 @DOCSTRING(demo)
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
406
14051
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
407 @DOCSTRING(example)
f07f7dd0d4df doc: Update documentation chapter on test functions
Rik <octave@nomad.inbox5.com>
parents: 13920
diff changeset
408
8817
03b7f618ab3d include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
409 @DOCSTRING(rundemos)
03b7f618ab3d include docstrings for new functions in the manual
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
410
10496
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents: 9080
diff changeset
411 @DOCSTRING(runtests)
3b77db443cc0 scripts/testfun/runtests.m: new function
John W. Eaton <jwe@octave.org>
parents: 9080
diff changeset
412
5582
6bf56668b01a [project @ 2005-12-15 01:08:20 by jwe]
jwe
parents:
diff changeset
413 @DOCSTRING(speed)