annotate scripts/testfun/test.m @ 19627: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 d63878346099
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: 17336
diff changeset
1 ## Copyright (C) 2005-2013 Paul Kienzle
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
2 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
3 ## This file is part of Octave.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
4 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
6 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
8 ## your option) any later version.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
9 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
13 ## General Public License for more details.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
14 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
18
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
11412
a8a9f062d0ef test.m: Use 'Command' for deftype in docstring.
Rik <octave@nomad.inbox5.com>
parents: 11032
diff changeset
20 ## @deftypefn {Command} {} test @var{name}
a8a9f062d0ef test.m: Use 'Command' for deftype in docstring.
Rik <octave@nomad.inbox5.com>
parents: 11032
diff changeset
21 ## @deftypefnx {Command} {} test @var{name} quiet|normal|verbose
14359
7277fe922e99 doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
22 ## @deftypefnx {Function File} {} test ("@var{name}", "quiet|normal|verbose", @var{fid})
7277fe922e99 doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
23 ## @deftypefnx {Function File} {} test ([], "explain", @var{fid})
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
24 ## @deftypefnx {Function File} {@var{success} =} test (@dots{})
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
25 ## @deftypefnx {Function File} {[@var{n}, @var{max}] =} test (@dots{})
14359
7277fe922e99 doc: Use Octave preference for double quote in docstrings in scripts/
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
26 ## @deftypefnx {Function File} {[@var{code}, @var{idx}] =} test ("@var{name}", "grabdemo")
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
27 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
28 ## Perform tests from the first file in the loadpath matching @var{name}.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
29 ## @code{test} can be called as a command or as a function. Called with
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
30 ## a single argument @var{name}, the tests are run interactively and stop
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
31 ## after the first error is encountered.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
32 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
33 ## With a second argument the tests which are performed and the amount of
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
34 ## output is selected.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
35 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
36 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
37 ## @item @qcode{"quiet"}
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
38 ## Don't report all the tests as they happen, just the errors.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
39 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
40 ## @item @qcode{"normal"}
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
41 ## Report all tests as they happen, but don't do tests which require
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
42 ## user interaction.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
43 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
44 ## @item @qcode{"verbose"}
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
45 ## Do tests which require user interaction.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
46 ## @end table
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
47 ##
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
48 ## The argument @var{fid} can be used to allow batch processing. Errors
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
49 ## can be written to the already open file defined by @var{fid}, and
8481
00df69d7e698 [docs] capitalize Octave consistently
Brian Gough <bjg@gnu.org>
parents: 8422
diff changeset
50 ## hopefully when Octave crashes this file will tell you what was happening
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
51 ## when it did. You can use @code{stdout} if you want to see the results as
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
52 ## they happen. You can also give a file name rather than an @var{fid}, in
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
53 ## which case the contents of the file will be replaced with the log from
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
54 ## the current test.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
55 ##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
56 ## Called with a single output argument @var{success}, @code{test} returns
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
57 ## true if all of the tests were successful. Called with two output arguments
7001
8b0cfeb06365 [project @ 2007-10-10 18:02:59 by jwe]
jwe
parents: 6730
diff changeset
58 ## @var{n} and @var{max}, the number of successful tests and the total number
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
59 ## of tests in the file @var{name} are returned.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
60 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
61 ## If the second argument is the string @qcode{"grabdemo"}, the contents of
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
62 ## the demo blocks are extracted but not executed. Code for all code blocks
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
63 ## is concatenated and returned as @var{code} with @var{idx} being a vector
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
64 ## of positions of the ends of the demo blocks.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
65 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
66 ## If the second argument is @qcode{"explain"}, then @var{name} is ignored
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
67 ## and an explanation of the line markers used is written to the file
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17245
diff changeset
68 ## @var{fid}.
11412
a8a9f062d0ef test.m: Use 'Command' for deftype in docstring.
Rik <octave@nomad.inbox5.com>
parents: 11032
diff changeset
69 ## @seealso{assert, fail, error, demo, example}
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
70 ## @end deftypefn
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
71
8202
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7940
diff changeset
72 ## FIXME: * Consider using keyword fail rather then error? This allows us
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7940
diff changeset
73 ## to make a functional form of error blocks, which means we
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7940
diff changeset
74 ## can include them in test sections which means that we can use
cf59d542f33e replace all TODOs and XXXs with FIXMEs
Jaroslav Hajek <highegg@gmail.com>
parents: 7940
diff changeset
75 ## octave flow control for both kinds of tests.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
76
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
77 function [__ret1, __ret2, __ret3, __ret4] = test (__name, __flag, __fid)
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
78 ## Information from test will be introduced by "key".
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
79 persistent __signal_fail = "!!!!! ";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
80 persistent __signal_empty = "????? ";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
81 persistent __signal_block = " ***** ";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
82 persistent __signal_file = ">>>>> ";
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
83 persistent __signal_skip = "----- ";
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
84
6730
230f9c49857e [project @ 2007-06-15 04:22:13 by jwe]
jwe
parents: 6728
diff changeset
85 __xfail = 0;
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
86 __xskip = 0;
6730
230f9c49857e [project @ 2007-06-15 04:22:13 by jwe]
jwe
parents: 6728
diff changeset
87
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
88 if (nargin < 2 || isempty (__flag))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
89 __flag = "quiet";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
90 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
91 if (nargin < 3)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
92 __fid = [];
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
93 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
94 if (nargin < 1 || nargin > 3
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
95 || (! ischar (__name) && ! isempty (__name)) || ! ischar (__flag))
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 6024
diff changeset
96 print_usage ();
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
97 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
98 if (isempty (__name) && (nargin != 3 || ! strcmp (__flag, "explain")))
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 6024
diff changeset
99 print_usage ();
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
100 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
101 __batch = (! isempty (__fid));
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
102
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
103 ## Decide if error messages should be collected.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
104 __close_fid = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
105 if (__batch)
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
106 if (ischar (__fid))
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
107 __fid = fopen (__fid, "wt");
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
108 if (__fid < 0)
10635
d1978e7364ad Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents: 10615
diff changeset
109 error ("test: could not open log file");
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
110 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
111 __close_fid = 1;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
112 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
113 fprintf (__fid, "%sprocessing %s\n", __signal_file, __name);
5908
9c134531c2c4 [project @ 2006-07-27 17:14:24 by jwe]
jwe
parents: 5803
diff changeset
114 fflush (__fid);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
115 else
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
116 __fid = stdout;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
117 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
118
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
119 if (strcmp (__flag, "normal"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
120 __grabdemo = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
121 __rundemo = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
122 __verbose = __batch;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
123 elseif (strcmp (__flag, "quiet"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
124 __grabdemo = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
125 __rundemo = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
126 __verbose = 0;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
127 elseif (strcmp (__flag, "verbose"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
128 __grabdemo = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
129 __rundemo = 1;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
130 __verbose = 1;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
131 elseif (strcmp (__flag, "grabdemo"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
132 __grabdemo = 1;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
133 __rundemo = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
134 __verbose = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
135 __demo_code = "";
12643
55430618bd5f Properly warn when demo or example called on a function without demos
Rik <octave@nomad.inbox5.com>
parents: 12447
diff changeset
136 __demo_idx = [];
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
137 elseif (strcmp (__flag, "explain"))
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
138 fprintf (__fid, "# %s new test file\n", __signal_file);
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
139 fprintf (__fid, "# %s no tests in file\n", __signal_empty);
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
140 fprintf (__fid, "# %s test had an unexpected result\n", __signal_fail);
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
141 fprintf (__fid, "# %s code for the test\n", __signal_block);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
142 fprintf (__fid, "# Search for the unexpected results in the file\n");
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
143 fprintf (__fid, "# then page back to find the file name which caused it.\n");
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
144 fprintf (__fid, "# The result may be an unexpected failure (in which\n");
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
145 fprintf (__fid, "# case an error will be reported) or an unexpected\n");
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
146 fprintf (__fid, "# success (in which case no error will be reported).\n");
5908
9c134531c2c4 [project @ 2006-07-27 17:14:24 by jwe]
jwe
parents: 5803
diff changeset
147 fflush (__fid);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
148 if (__close_fid)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
149 fclose (__fid);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
150 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
151 return;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
152 else
10635
d1978e7364ad Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents: 10615
diff changeset
153 error ("test: unknown flag '%s'", __flag);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
154 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
155
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
156 ## Locate the file to test.
6249
c507206c45bc [project @ 2007-01-22 20:00:06 by jwe]
jwe
parents: 6046
diff changeset
157 __file = file_in_loadpath (__name, "all");
c507206c45bc [project @ 2007-01-22 20:00:06 by jwe]
jwe
parents: 6046
diff changeset
158 if (isempty (__file))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16992
diff changeset
159 __file = file_in_loadpath ([__name ".m"], "all");
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
160 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
161 if (isempty (__file))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16992
diff changeset
162 __file = file_in_loadpath ([__name ".cc"], "all");
6249
c507206c45bc [project @ 2007-01-22 20:00:06 by jwe]
jwe
parents: 6046
diff changeset
163 endif
c507206c45bc [project @ 2007-01-22 20:00:06 by jwe]
jwe
parents: 6046
diff changeset
164 if (iscell (__file))
6365
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6249
diff changeset
165 ## If repeats, return first in path.
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6249
diff changeset
166 if (isempty (__file))
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6249
diff changeset
167 __file = "";
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6249
diff changeset
168 else
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6249
diff changeset
169 __file = __file{1};
ccdb8ffbb994 [project @ 2007-02-27 19:43:35 by jwe]
jwe
parents: 6249
diff changeset
170 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
171 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
172 if (isempty (__file))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
173 if (__grabdemo)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
174 __ret1 = "";
15520
bcace51598ed Improve demo() to warn when an input function does not exist.
Rik <rik@octave.org>
parents: 15006
diff changeset
175 __ret2 = -1;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
176 else
15762
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
177 ftype = exist (__name);
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
178 if (ftype == 3)
12447
890e89c3dfeb More explicit error message when source with tests for dynamically linked functions not found (#30341)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
179 fprintf (__fid, "%s%s source code with tests for dynamically linked function not found\n", __signal_empty, __name);
15762
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
180 elseif (ftype == 5)
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
181 fprintf (__fid, "%s%s is a built-in function\n", __signal_empty, __name);
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
182 elseif (any (strcmp (__operators__ (), __name)))
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
183 fprintf (__fid, "%s%s is an operator\n", __signal_empty, __name);
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
184 elseif (any (strcmp (__keywords__ (), __name)))
a5475ba0d199 test.m: Better error reporting for arguments that can't be tested (bug #37592)
Mike Miller <mtmiller@ieee.org>
parents: 15520
diff changeset
185 fprintf (__fid, "%s%s is a keyword\n", __signal_empty, __name);
12447
890e89c3dfeb More explicit error message when source with tests for dynamically linked functions not found (#30341)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
186 else
890e89c3dfeb More explicit error message when source with tests for dynamically linked functions not found (#30341)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
187 fprintf (__fid, "%s%s does not exist in path\n", __signal_empty, __name);
890e89c3dfeb More explicit error message when source with tests for dynamically linked functions not found (#30341)
David Bateman <dbateman@free.fr>
parents: 11587
diff changeset
188 endif
5908
9c134531c2c4 [project @ 2006-07-27 17:14:24 by jwe]
jwe
parents: 5803
diff changeset
189 fflush (__fid);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
190 if (nargout > 0)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
191 __ret1 = __ret2 = 0;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
192 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
193 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
194 if (__close_fid)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
195 fclose (__fid);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
196 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
197 return;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
198 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
199
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
200 ## Grab the test code from the file.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
201 __body = __extract_test_code (__file);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
202
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
203 if (isempty (__body))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
204 if (__grabdemo)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
205 __ret1 = "";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
206 __ret2 = [];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
207 else
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
208 fprintf (__fid, "%s%s has no tests available\n", __signal_empty, __file);
5908
9c134531c2c4 [project @ 2006-07-27 17:14:24 by jwe]
jwe
parents: 5803
diff changeset
209 fflush (__fid);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
210 if (nargout > 0)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
211 __ret1 = __ret2 = 0;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
212 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
213 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
214 if (__close_fid)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
215 fclose (__fid);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
216 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
217 return;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
218 else
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
219 ## Add a dummy comment block to the end for ease of indexing.
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
220 if (__body (length (__body)) == "\n")
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
221 __body = sprintf ("\n%s#", __body);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
222 else
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
223 __body = sprintf ("\n%s\n#", __body);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
224 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
225 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
226
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
227 ## Chop it up into blocks for evaluation.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
228 __lineidx = find (__body == "\n");
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
229 __blockidx = __lineidx(find (! isspace (__body(__lineidx+1))))+1;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
230
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
231 ## Ready to start tests ... if in batch mode, tell us what is happening.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
232 if (__verbose)
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16992
diff changeset
233 disp ([__signal_file, __file]);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
234 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
235
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
236 ## Assume all tests will pass.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
237 __all_success = 1;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
238
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
239 ## Process each block separately, initially with no shared variables.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
240 __tests = __successes = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
241 __shared = " ";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
242 __shared_r = " ";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
243 __clear = "";
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
244 for __i = 1:length (__blockidx)-1
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
245
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
246 ## Extract the block.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
247 __block = __body(__blockidx(__i):__blockidx(__i+1)-2);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
248
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
249 ## Let the user/logfile know what is happening.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
250 if (__verbose)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
251 fprintf (__fid, "%s%s\n", __signal_block, __block);
5908
9c134531c2c4 [project @ 2006-07-27 17:14:24 by jwe]
jwe
parents: 5803
diff changeset
252 fflush (__fid);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
253 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
254
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
255 ## Split __block into __type and __code.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
256 __idx = find (! isletter (__block));
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
257 if (isempty (__idx))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
258 __type = __block;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
259 __code = "";
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
260 else
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
261 __type = __block(1:__idx(1)-1);
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
262 __code = __block(__idx(1):length (__block));
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
263 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
264
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
265 ## Assume the block will succeed.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
266 __success = 1;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
267 __msg = [];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
268
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
269 ### DEMO
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
270
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
271 ## If in __grabdemo mode, then don't process any other block type.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
272 ## So that the other block types don't have to worry about
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
273 ## this __grabdemo mode, the demo block processor grabs all block
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
274 ## types and skips those which aren't demo blocks.
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
275
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
276 __isdemo = strcmp (__type, "demo");
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
277 if (__grabdemo || __isdemo)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
278 __istest = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
279
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
280 if (__grabdemo && __isdemo)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
281 if (isempty (__demo_code))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
282 __demo_code = __code;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
283 __demo_idx = [1, length(__demo_code)+1];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
284 else
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16992
diff changeset
285 __demo_code = [__demo_code, __code];
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
286 __demo_idx = [__demo_idx, length(__demo_code)+1];
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
287 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
288
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
289 elseif (__rundemo && __isdemo)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
290 try
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
291 ## process the code in an environment without variables
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14359
diff changeset
292 eval (sprintf ("function __test__ ()\n%s\nendfunction", __code));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
293 __test__;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
294 input ("Press <enter> to continue: ", "s");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
295 catch
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
296 __success = 0;
12687
6d4c18565de1 Deprecate error_text(), __error_text__()
Rik <octave@nomad.inbox5.com>
parents: 12643
diff changeset
297 __msg = sprintf ("%sdemo failed\n%s", __signal_fail, lasterr ());
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
298 end_try_catch
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
299 clear __test__;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
300
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
301 endif
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
302 ## Code already processed.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
303 __code = "";
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
304
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
305 ### SHARED
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
306
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
307 elseif (strcmp (__type, "shared"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
308 __istest = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
309
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
310 ## Separate initialization code from variables.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
311 __idx = find (__code == "\n");
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
312 if (isempty (__idx))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
313 __vars = __code;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
314 __code = "";
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
315 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
316 __vars = __code (1:__idx(1)-1);
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
317 __code = __code (__idx(1):length (__code));
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
318 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
319
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
320 ## Strip comments off the variables.
6730
230f9c49857e [project @ 2007-06-15 04:22:13 by jwe]
jwe
parents: 6728
diff changeset
321 __idx = find (__vars == "%" | __vars == "#");
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
322 if (! isempty (__idx))
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
323 __vars = __vars(1:__idx(1)-1);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
324 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
325
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
326 ## Assign default values to variables.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
327 try
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
328 __vars = deblank (__vars);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
329 if (! isempty (__vars))
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16992
diff changeset
330 eval ([strrep(__vars, ",", "=[];"), "=[];"]);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
331 __shared = __vars;
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16992
diff changeset
332 __shared_r = ["[ ", __vars, "] = "];
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
333 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
334 __shared = " ";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
335 __shared_r = " ";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
336 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
337 catch
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
338 ## Couldn't declare, so don't initialize.
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
339 __code = "";
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
340 __success = 0;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
341 __msg = sprintf ("%sshared variable initialization failed\n",
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
342 __signal_fail);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
343 end_try_catch
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
344
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
345 ## Initialization code will be evaluated below.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
346
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
347 ### FUNCTION
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
348
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
349 elseif (strcmp (__type, "function"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
350 __istest = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
351 persistent __fn = 0;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
352 __name_position = function_name (__block);
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
353 if (isempty (__name_position))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
354 __success = 0;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
355 __msg = sprintf ("%stest failed: missing function name\n",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
356 __signal_fail);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
357 else
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
358 __name = __block(__name_position(1):__name_position(2));
10130
0c3609dd34cf oct-parse.yy (eval_string): save and set reading_{script,fcn,classdef}_file vars
John W. Eaton <jwe@octave.org>
parents: 10128
diff changeset
359 __code = __block;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
360 try
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
361 eval (__code); # Define the function
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
362 __clear = sprintf ("%sclear %s;\n", __clear, __name);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
363 catch
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
364 __success = 0;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
365 __msg = sprintf ("%stest failed: syntax error\n%s",
12687
6d4c18565de1 Deprecate error_text(), __error_text__()
Rik <octave@nomad.inbox5.com>
parents: 12643
diff changeset
366 __signal_fail, lasterr ());
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
367 end_try_catch
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
368 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
369 __code = "";
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
370
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
371 ### ENDFUNCTION
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
372
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
373 elseif (strcmp (__type, "endfunction"))
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
374 ## endfunction simply declares the end of a previous function block.
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
375 ## There is no processing to be done here, just skip to next block.
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
376 __istest = 0;
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
377 __code = "";
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
378
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
379 ### ASSERT/FAIL
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
380
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
381 elseif (strcmp (__type, "assert") || strcmp (__type, "fail"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
382 __istest = 1;
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
383 ## Put the keyword back on the code.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
384 __code = __block;
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
385 ## The code will be evaluated below as a test block.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
386
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
387 ### ERROR/WARNING
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
388
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
389 elseif (strcmp (__type, "error") || strcmp (__type, "warning"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
390 __istest = 1;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
391 __warning = strcmp (__type, "warning");
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
392 [__pattern, __id, __code] = getpattern (__code);
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
393 if (__id)
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
394 __patstr = ["id=",__id];
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
395 else
16976
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
396 if (! strcmp (__pattern, '.'))
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
397 __patstr = ["<",__pattern,">"];
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
398 else
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
399 __patstr = ifelse (__warning, "a warning", "an error");
16976
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
400 endif
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
401 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
402 try
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
403 eval (sprintf ("function __test__(%s)\n%s\nendfunction",
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
404 __shared, __code));
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
405 catch
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
406 __success = 0;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
407 __msg = sprintf ("%stest failed: syntax error\n%s",
12687
6d4c18565de1 Deprecate error_text(), __error_text__()
Rik <octave@nomad.inbox5.com>
parents: 12643
diff changeset
408 __signal_fail, lasterr ());
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
409 end_try_catch
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
410
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
411 if (__success)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
412 __success = 0;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
413 __warnstate = warning ("query", "quiet");
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
414 warning ("on", "quiet");
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
415 ## Clear error and warning strings before starting
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
416 lasterr ("");
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
417 lastwarn ("");
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
418 try
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
419 ## FIXME: lastwarn () must be called once from *WITHIN* the try block
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
420 ## or subsequent warning/lastwarn statements may fail.
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
421 ## Likely this is something to do with the specialness of
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
422 ## the try block which is disabling normal errors.
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
423 lastwarn ();
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
424 eval (sprintf ("__test__(%s);", __shared));
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
425 if (! __warning)
16976
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
426 __msg = sprintf ("%serror failed.\nExpected %s but got no error\n",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
427 __signal_fail, __patstr);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
428 else
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
429 if (! isempty (__id))
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
430 [~, __err] = lastwarn ();
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
431 __mismatch = ! strcmp (__err, __id);
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
432 else
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
433 __err = trimerr (lastwarn (), "warning");
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
434 __mismatch = isempty (regexp (__err, __pattern, "once"));
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
435 endif
7028
ecd6347f7d1c [project @ 2007-10-15 09:00:02 by dbateman]
dbateman
parents: 7017
diff changeset
436 warning (__warnstate.state, "quiet");
ecd6347f7d1c [project @ 2007-10-15 09:00:02 by dbateman]
dbateman
parents: 7017
diff changeset
437 if (isempty (__err))
17245
7babcdb9bc13 Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
438 __msg = sprintf (["%swarning failed.\n" ...
16976
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
439 "Expected %s but got no warning\n"],
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
440 __signal_fail, __patstr);
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
441 elseif (__mismatch)
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
442 __msg = sprintf ("%swarning failed.\nExpected %s but got <%s>\n",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
443 __signal_fail, __patstr, __err);
7028
ecd6347f7d1c [project @ 2007-10-15 09:00:02 by dbateman]
dbateman
parents: 7017
diff changeset
444 else
ecd6347f7d1c [project @ 2007-10-15 09:00:02 by dbateman]
dbateman
parents: 7017
diff changeset
445 __success = 1;
ecd6347f7d1c [project @ 2007-10-15 09:00:02 by dbateman]
dbateman
parents: 7017
diff changeset
446 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
447 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
448
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
449 catch
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
450 if (! isempty (__id))
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
451 [~, __err] = lasterr ();
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
452 __mismatch = ! strcmp (__err, __id);
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
453 else
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
454 __err = trimerr (lasterr (), "error");
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
455 __mismatch = isempty (regexp (__err, __pattern, "once"));
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
456 endif
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
457 warning (__warnstate.state, "quiet");
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
458 if (__warning)
17245
7babcdb9bc13 Use ... instead of \ for line continuation marker.
Stefan Mahr <dac922@gmx.de>
parents: 16994
diff changeset
459 __msg = sprintf (["%swarning failed.\n" ...
16976
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
460 "Expected warning %s but got error <%s>\n"],
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
461 __signal_fail, __patstr, __err);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
462 elseif (__mismatch)
16976
13affad7347c test.m: Use the syntax "BLOCK_NAME failed" for error/warnings blocks.
Rik <rik@octave.org>
parents: 16170
diff changeset
463 __msg = sprintf ("%serror failed.\nExpected %s but got <%s>\n",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
464 __signal_fail, __patstr, __err);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
465 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
466 __success = 1;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
467 endif
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
468 end_try_catch
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
469 clear __test__;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
470 endif
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
471 ## Code already processed.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
472 __code = "";
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
473
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
474 ### TESTIF
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
475
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
476 elseif (strcmp (__type, "testif"))
14182
f8d99761244c test: Expand %!testif functionality to multiple conditions
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
477 __e = regexp (__code, '.$', 'lineanchors', 'once');
14190
68fd9f95e1f9 Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
478 ## Strip comment any comment from testif line before looking for features
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
479 __feat_line = strtok (__code(1:__e), '#%');
14190
68fd9f95e1f9 Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents: 14182
diff changeset
480 __feat = regexp (__feat_line, '\w+', 'match');
16170
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16019
diff changeset
481 __feat = strrep (__feat, "HAVE_", "");
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16019
diff changeset
482 __have_feat = __have_feature__ (__feat);
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16019
diff changeset
483 if (__have_feat)
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16019
diff changeset
484 __istest = 1;
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16019
diff changeset
485 __code = __code(__e + 1 : end);
2a4f83826024 new way to test for features in Octave scripts
John W. Eaton <jwe@octave.org>
parents: 16019
diff changeset
486 else
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
487 __xskip++;
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
488 __istest = 0;
10615
08050f37ba49 Don't abort testing when merely skipping a testif block.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
489 __code = ""; # Skip the code.
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
490 __msg = sprintf ("%sskipped test\n", __signal_skip);
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
491 endif
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
492
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
493 ### TEST
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
494
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 6494
diff changeset
495 elseif (strcmp (__type, "test") || strcmp (__type, "xtest"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
496 __istest = 1;
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
497 ## Code will be evaluated below.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
498
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
499 ### Comment block.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
500
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
501 elseif (strcmp (__block(1:1), "#"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
502 __istest = 0;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
503 __code = ""; # skip the code
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
504
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
505 ### Unknown block.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
506
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
507 else
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
508 __istest = 1;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
509 __success = 0;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
510 __msg = sprintf ("%sunknown test type!\n", __signal_fail);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
511 __code = ""; # skip the code
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
512 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
513
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
514 ## evaluate code for test, shared, and assert.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
515 if (! isempty(__code))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
516 try
14066
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
517 ## FIXME: need to check for embedded test functions, which cause
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
518 ## segfaults, until issues with subfunctions in functions are resolved.
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
519 embed_func = regexp (__code, '^\s*function ', 'once', 'lineanchors');
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
520 if (isempty (embed_func))
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
521 eval (sprintf ("function %s__test__(%s)\n%s\nendfunction",
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
522 __shared_r,__shared, __code));
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
523 eval (sprintf ("%s__test__(%s);", __shared_r, __shared));
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
524 else
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
525 error (["Functions embedded in %!test blocks are not allowed.\n", ...
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
526 "Use the %!function/%!endfunction syntax instead to define shared functions for testing.\n"]);
80bda7c4f012 Avoid segfault in test() and demo() blocks with embedded functions (Bugs #35068, #32843, #33981)
Rik <octave@nomad.inbox5.com>
parents: 13914
diff changeset
527 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
528 catch
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 6494
diff changeset
529 if (strcmp (__type, "xtest"))
12687
6d4c18565de1 Deprecate error_text(), __error_text__()
Rik <octave@nomad.inbox5.com>
parents: 12643
diff changeset
530 __msg = sprintf ("%sknown failure\n%s", __signal_fail, lasterr ());
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
531 __xfail++;
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 6494
diff changeset
532 else
12687
6d4c18565de1 Deprecate error_text(), __error_text__()
Rik <octave@nomad.inbox5.com>
parents: 12643
diff changeset
533 __msg = sprintf ("%stest failed\n%s", __signal_fail, lasterr ());
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
534 __success = 0;
6728
a25173d58101 [project @ 2007-06-14 21:10:48 by jwe]
jwe
parents: 6494
diff changeset
535 endif
12687
6d4c18565de1 Deprecate error_text(), __error_text__()
Rik <octave@nomad.inbox5.com>
parents: 12643
diff changeset
536 if (isempty (lasterr ()))
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
537 error ("empty error text, probably Ctrl-C --- aborting");
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
538 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
539 end_try_catch
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
540 clear __test__;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
541 endif
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
542
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
543 ## All done. Remember if we were successful and print any messages.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
544 if (! isempty (__msg))
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
545 ## Make sure the user knows what caused the error.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
546 if (! __verbose)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
547 fprintf (__fid, "%s%s\n", __signal_block, __block);
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
548 fflush (__fid);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
549 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
550 fputs (__fid, __msg);
9996
929e53107f09 Add newline to message output of test.m
Rik <rdrider0-list@yahoo.com>
parents: 9051
diff changeset
551 fputs (__fid, "\n");
5908
9c134531c2c4 [project @ 2006-07-27 17:14:24 by jwe]
jwe
parents: 5803
diff changeset
552 fflush (__fid);
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
553 ## Show the variable context.
7244
5a9561046b89 [project @ 2007-12-04 02:27:27 by jwe]
jwe
parents: 7243
diff changeset
554 if (! strcmp (__type, "error") && ! strcmp (__type, "testif")
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
555 && ! all (__shared == " "))
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
556 fputs (__fid, "shared variables ");
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
557 eval (sprintf ("fdisp(__fid,bundle(%s));", __shared));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
558 fflush (__fid);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
559 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
560 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
561 if (__success == 0)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
562 __all_success = 0;
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
563 ## Stop after one error if not in batch mode.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
564 if (! __batch)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
565 if (nargout > 0)
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
566 __ret1 = __ret2 = 0;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
567 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
568 if (__close_fid)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
569 fclose (__fid);
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
570 endif
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
571 return;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
572 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
573 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
574 __tests += __istest;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
575 __successes += __success * __istest;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
576 endfor
15006
d8acad691f26 Clear %!functions at the end of testing, not for each shared block.
Rik <rik@octave.org>
parents: 14868
diff changeset
577 ## Clear any test functions created
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
578 eval (__clear, "");
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
579
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
580 if (nargout == 0)
8422
20cbb0fdab48 test.m: print "has no tests" message if there are demos but no tests
John W. Eaton <jwe@octave.org>
parents: 8202
diff changeset
581 if (__tests || __xfail || __xskip)
20cbb0fdab48 test.m: print "has no tests" message if there are demos but no tests
John W. Eaton <jwe@octave.org>
parents: 8202
diff changeset
582 if (__xfail)
16992
4e8f49304059 test.m: Use correct English singular/plural in reporting messages (bug #39164).
Rafael Laboissiere <rafael@laboissiere.net>
parents: 16977
diff changeset
583 printf ("PASSES %d out of %d test%s (%d expected failure%s)\n",
4e8f49304059 test.m: Use correct English singular/plural in reporting messages (bug #39164).
Rafael Laboissiere <rafael@laboissiere.net>
parents: 16977
diff changeset
584 __successes, __tests, ifelse (__tests > 1, "s", ""),
4e8f49304059 test.m: Use correct English singular/plural in reporting messages (bug #39164).
Rafael Laboissiere <rafael@laboissiere.net>
parents: 16977
diff changeset
585 __xfail, ifelse (__xfail > 1, "s", ""));
8422
20cbb0fdab48 test.m: print "has no tests" message if there are demos but no tests
John W. Eaton <jwe@octave.org>
parents: 8202
diff changeset
586 else
16992
4e8f49304059 test.m: Use correct English singular/plural in reporting messages (bug #39164).
Rafael Laboissiere <rafael@laboissiere.net>
parents: 16977
diff changeset
587 printf ("PASSES %d out of %d test%s\n", __successes, __tests,
4e8f49304059 test.m: Use correct English singular/plural in reporting messages (bug #39164).
Rafael Laboissiere <rafael@laboissiere.net>
parents: 16977
diff changeset
588 ifelse (__tests > 1, "s", ""));
8422
20cbb0fdab48 test.m: print "has no tests" message if there are demos but no tests
John W. Eaton <jwe@octave.org>
parents: 8202
diff changeset
589 endif
20cbb0fdab48 test.m: print "has no tests" message if there are demos but no tests
John W. Eaton <jwe@octave.org>
parents: 8202
diff changeset
590 if (__xskip)
16992
4e8f49304059 test.m: Use correct English singular/plural in reporting messages (bug #39164).
Rafael Laboissiere <rafael@laboissiere.net>
parents: 16977
diff changeset
591 printf ("Skipped %d test%s due to missing features\n", __xskip,
4e8f49304059 test.m: Use correct English singular/plural in reporting messages (bug #39164).
Rafael Laboissiere <rafael@laboissiere.net>
parents: 16977
diff changeset
592 ifelse (__xskip > 1, "s", ""));
8422
20cbb0fdab48 test.m: print "has no tests" message if there are demos but no tests
John W. Eaton <jwe@octave.org>
parents: 8202
diff changeset
593 endif
6730
230f9c49857e [project @ 2007-06-15 04:22:13 by jwe]
jwe
parents: 6728
diff changeset
594 else
8422
20cbb0fdab48 test.m: print "has no tests" message if there are demos but no tests
John W. Eaton <jwe@octave.org>
parents: 8202
diff changeset
595 printf ("%s%s has no tests available\n", __signal_empty, __file);
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
596 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
597 elseif (__grabdemo)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
598 __ret1 = __demo_code;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
599 __ret2 = __demo_idx;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
600 elseif (nargout == 1)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
601 __ret1 = __all_success;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
602 else
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
603 __ret1 = __successes;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
604 __ret2 = __tests;
6730
230f9c49857e [project @ 2007-06-15 04:22:13 by jwe]
jwe
parents: 6728
diff changeset
605 __ret3 = __xfail;
7242
e4398e3903be [project @ 2007-12-03 23:52:07 by dbateman]
dbateman
parents: 7151
diff changeset
606 __ret4 = __xskip;
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
607 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
608 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
609
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
610 ## Create structure with fieldnames the name of the input variables.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
611 function s = varstruct (varargin)
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
612 for i = 1:nargin
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
613 s.(deblank (argn(i,:))) = varargin{i};
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
614 endfor
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
615 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
616
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
617 ## Find [start,end] of fn in 'function [a,b] = fn'.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
618 function pos = function_name (def)
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
619 pos = [];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
620
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
621 ## Find the end of the name.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
622 right = find (def == "(", 1);
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
623 if (isempty (right))
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
624 return;
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
625 endif
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
626 right = find (def(1:right-1) != " ", 1, "last");
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
627
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
628 ## Find the beginning of the name.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
629 left = max ([find(def(1:right)==" ", 1, "last"), ...
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10398
diff changeset
630 find(def(1:right)=="=", 1, "last")]);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
631 if (isempty (left))
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
632 return;
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
633 endif
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
634 left++;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
635
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
636 ## Return the end points of the name.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
637 pos = [left, right];
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
638 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
639
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
640 ## Strip <pattern> from '<pattern> code'.
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
641 ## Also handles 'id=ID code'
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
642 function [pattern, id, rest] = getpattern (str)
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
643 pattern = ".";
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
644 id = [];
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
645 rest = str;
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
646 str = trimleft (str);
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
647 if (! isempty (str) && str(1) == "<")
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
648 close = index (str, ">");
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
649 if (close)
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
650 pattern = str(2:close-1);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
651 rest = str(close+1:end);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
652 endif
10398
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
653 elseif (strncmp (str, "id=", 3))
f7cf1a53e1c5 support ID test for errors and warningsin test suites
Jaroslav Hajek <highegg@gmail.com>
parents: 10130
diff changeset
654 [id, rest] = strtok (str(4:end));
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
655 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
656 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
657
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
658 ## Strip '.*prefix:' from '.*prefix: msg\n' and strip trailing blanks.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
659 function msg = trimerr (msg, prefix)
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
660 idx = index (msg, [prefix ":"]);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
661 if (idx > 0)
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
662 msg(1:idx+length(prefix)) = [];
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
663 endif
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
664 msg = strtrim (msg);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
665 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
666
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
667 ## Strip leading blanks from string.
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
668 function str = trimleft (str)
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
669 idx = find (! isspace (str), 1);
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
670 str = str(idx:end);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
671 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
672
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
673 ## Make a structure out of the named variables
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8481
diff changeset
674 ## (based on Etienne Grossmann's tar function).
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
675 function s = bundle (varargin)
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
676 for i = 1:nargin
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
677 s.(deblank (argn(i,:))) = varargin{i};
7151
aeeb646f6538 [project @ 2007-11-09 19:34:17 by jwe]
jwe
parents: 7028
diff changeset
678 endfor
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
679 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
680
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
681 function body = __extract_test_code (nm)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
682 fid = fopen (nm, "rt");
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
683 body = [];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
684 if (fid >= 0)
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
685 while (! feof (fid))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
686 ln = fgetl (fid);
6494
76a1a953533d [project @ 2007-04-05 16:09:03 by jwe]
jwe
parents: 6365
diff changeset
687 if (length (ln) >= 2 && strcmp (ln(1:2), "%!"))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
688 body = [body, "\n"];
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
689 if (length (ln) > 2)
16994
333243133364 Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents: 16992
diff changeset
690 body = [body, ln(3:end)];
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
691 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
692 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
693 endwhile
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
694 fclose (fid);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
695 endif
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
696 endfunction
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
697
16977
0d5d3e53255f test.m: Fix randomly failing %!warning test blocks (bug #35850, bug #38679).
Rik <rik@octave.org>
parents: 16976
diff changeset
698
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
699 ### example from toeplitz
13914
4b1ce071f504 test.m: Update tests which depend on error messages changed in toeplitz.m
Rik <octave@nomad.inbox5.com>
parents: 13305
diff changeset
700 %!shared msg1,msg2
4b1ce071f504 test.m: Update tests which depend on error messages changed in toeplitz.m
Rik <octave@nomad.inbox5.com>
parents: 13305
diff changeset
701 %! msg1="C must be a vector";
4b1ce071f504 test.m: Update tests which depend on error messages changed in toeplitz.m
Rik <octave@nomad.inbox5.com>
parents: 13305
diff changeset
702 %! msg2="C and R must be vectors";
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
703 %!fail ('toeplitz ([])', msg1);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
704 %!fail ('toeplitz ([1,2;3,4])', msg1);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
705 %!fail ('toeplitz ([1,2],[])', msg2);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
706 %!fail ('toeplitz ([1,2],[1,2;3,4])', msg2);
13914
4b1ce071f504 test.m: Update tests which depend on error messages changed in toeplitz.m
Rik <octave@nomad.inbox5.com>
parents: 13305
diff changeset
707 %!fail ('toeplitz ([1,2;3,4],[1,2])', msg2);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
708 % !fail ('toeplitz','usage: toeplitz'); # usage doesn't generate an error
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
709 % !fail ('toeplitz (1, 2, 3)', 'usage: toeplitz');
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
710 %!test assert (toeplitz ([1,2,3], [1,4]), [1,4; 2,1; 3,2]);
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
711 %!demo toeplitz ([1,2,3,4],[1,5,6])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
712
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
713 ### example from kron
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5681
diff changeset
714 %!#error kron # FIXME suppress these until we can handle output
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
715 %!#error kron(1,2,3)
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
716 %!test assert (isempty (kron ([], rand (3, 4))))
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
717 %!test assert (isempty (kron (rand (3, 4), [])))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
718 %!test assert (isempty (kron ([], [])))
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
719 %!shared A, B
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
720 %!test
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
721 %! A = [1, 2, 3; 4, 5, 6];
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
722 %! B = [1, -1; 2, -2];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
723 %!assert (size (kron (zeros (3, 0), A)), [ 3*rows(A), 0 ])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
724 %!assert (size (kron (zeros (0, 3), A)), [ 0, 3*columns(A) ])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
725 %!assert (size (kron (A, zeros (3, 0))), [ 3*rows(A), 0 ])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
726 %!assert (size (kron (A, zeros (0, 3))), [ 0, 3*columns(A) ])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
727 %!assert (kron (pi, e), pi*e)
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
728 %!assert (kron (pi, A), pi*A)
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
729 %!assert (kron (A, e), e*A)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
730 %!assert (kron ([1, 2, 3], A), [ A, 2*A, 3*A ])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
731 %!assert (kron ([1; 2; 3], A), [ A; 2*A; 3*A ])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
732 %!assert (kron ([1, 2; 3, 4], A), [ A, 2*A; 3*A, 4*A ])
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
733 %!test
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
734 %! res = [1,-1,2,-2,3,-3; 2,-2,4,-4,6,-6; 4,-4,5,-5,6,-6; 8,-8,10,-10,12,-12];
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
735 %! assert (kron (A, B), res)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
736
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
737 ### an extended demo from specgram
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
738 %!#demo
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
739 %! ## Speech spectrogram
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
740 %! [x, Fs] = auload (file_in_loadpath ("sample.wav")); # audio file
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
741 %! step = fix (5*Fs/1000); # one spectral slice every 5 ms
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
742 %! window = fix (40*Fs/1000); # 40 ms data window
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
743 %! fftn = 2^nextpow2 (window); # next highest power of 2
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
744 %! [S, f, t] = specgram (x, fftn, Fs, window, window-step);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
745 %! S = abs (S (2:fftn*4000/Fs,:)); # magnitude in range 0<f<=4000 Hz.
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
746 %! S = S/max(max(S)); # normalize magnitude so that max is 0 dB.
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
747 %! S = max (S, 10^(-40/10)); # clip below -40 dB.
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
748 %! S = min (S, 10^(-3/10)); # clip above -3 dB.
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
749 %! imagesc (flipud (20*log10 (S)), 1);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
750 %! % you should now see a spectrogram in the image window
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
751
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
752
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
753 ## now test 'test' itself
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
754
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
755 ## usage and error testing
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
756 % !fail ('test','usage.*test') # no args, generates usage()
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
757 % !fail ('test (1,2,3,4)','usage.*test') # too many args, generates usage()
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
758 %!fail ('test ("test", "bogus")','unknown flag') # incorrect args
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
759 %!fail ('garbage','garbage.*undefined') # usage on nonexistent function should be
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
760
7940
1bfb88e78027 fix tests
John W. Eaton <jwe@octave.org>
parents: 7540
diff changeset
761 %!error test # no args, generates usage()
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
762 %!error test (1,2,3,4) # too many args, generates usage()
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
763 %!error <unknown flag> test ("test", 'bogus'); # incorrect args, generates error()
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
764 %!error <garbage' undefined> garbage # usage on nonexistent function should be
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
765
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
766 %!error test ("test", 'bogus'); # test without pattern
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
767
5681
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5642
diff changeset
768 %!test
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5642
diff changeset
769 %! lastwarn(); # clear last warning just in case
233d98d95659 [project @ 2006-03-16 17:48:55 by dbateman]
dbateman
parents: 5642
diff changeset
770
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
771 %!warning <warning message> warning ('warning message');
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
772
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
773 ## test of shared variables
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
774 %!shared a # create a shared variable
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
775 %!test a=3; # assign to a shared variable
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
776 %!test assert (a,3) # variable should equal 3
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
777 %!shared b,c # replace shared variables
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 15762
diff changeset
778 %!test assert (!exist ("a", "var")); # a no longer exists
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
779 %!test assert (isempty (b)); # variables start off empty
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
780 %!shared a,b,c # recreate a shared variable
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
781 %!test assert (isempty (a)); # value is empty even if it had a previous value
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
782 %!test a=1; b=2; c=3; # give values to all variables
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
783 %!test assert ([a,b,c],[1,2,3]); # test all of them together
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
784 %!test c=6; # update a value
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
785 %!test assert ([a, b, c],[1, 2, 6]); # show that the update sticks
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
786 %!shared # clear all shared variables
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 15762
diff changeset
787 %!test assert (!exist ("a", "var")) # show that they are cleared
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
788 %!shared a,b,c # support for initializer shorthand
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
789 %! a=1; b=2; c=4;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
790
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
791 %!function x = __test_a (y)
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
792 %! x = 2*y;
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
793 %!endfunction
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
794 %!assert (__test_a (2),4); # Test a test function
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
795
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
796 %!function __test_a (y)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
797 %! x = 2*y;
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
798 %!endfunction
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
799 %!test
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
800 %! __test_a (2); # Test a test function with no return value
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
801
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
802 %!function [x,z] = __test_a (y)
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
803 %! x = 2*y;
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
804 %! z = 3*y;
13305
63463570d9fe Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents: 12687
diff changeset
805 %!endfunction
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
806 %!test # Test a test function with multiple returns
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
807 %! [x,z] = __test_a (3);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
808 %! assert (x,6);
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
809 %! assert (z,9);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
810
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
811 ## test of assert block
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
812 %!assert (isempty ([])) # support for test assert shorthand
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
813
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
814 ## demo blocks
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
815 %!demo # multiline demo block
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14190
diff changeset
816 %! t = [0:0.01:2*pi]; x = sin (t);
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14190
diff changeset
817 %! plot (t,x);
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
818 %! % you should now see a sine wave in your figure window
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
819 %!demo a=3 # single line demo blocks work too
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
820
17336
b81b9d079515 Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents: 17281
diff changeset
821 ## this is a comment block. it can contain anything.
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
822 %!##
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
823 %! it is the "#" as the block type that makes it a comment
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14190
diff changeset
824 %! and it stays as a comment even through continuation lines
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
825 %! which means that it works well with commenting out whole tests
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
826
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
827 % !# failure tests. All the following should fail. These tests should
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
828 % !# be disabled unless you are developing test() since users don't
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
829 % !# like to be presented with expected failures. I use % ! to disable.
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
830 % !test error("---------Failure tests. Use test('test','verbose',1)");
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
831 % !test assert([a,b,c],[1,3,6]); # variables have wrong values
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
832 % !bogus # unknown block type
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
833 % !error toeplitz([1,2,3]); # correct usage
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
834 % !test syntax errors) # syntax errors fail properly
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
835 % !shared garbage in # variables must be comma separated
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
836 % !error syntax++error # error test fails on syntax errors
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
837 % !error "succeeds."; # error test fails if code succeeds
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
838 % !error <wrong pattern> error("message") # error pattern must match
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
839 % !demo with syntax error # syntax errors in demo fail properly
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
840 % !shared a,b,c
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
841 % !demo # shared variables not available in demo
16019
5b2126a8c84f install tests and functions to run them
John W. Eaton <jwe@octave.org>
parents: 15762
diff changeset
842 % ! assert(exist("a", "var"))
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
843 % !error
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
844 % ! test('/etc/passwd');
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
845 % ! test("nonexistent file");
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
846 % ! ## These don't signal an error, so the test for an error fails. Note
5589
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
847 % ! ## that the call doesn't reference the current fid (it is unavailable),
f812a0680d05 [project @ 2006-01-06 00:14:42 by jwe]
jwe
parents:
diff changeset
848 % ! ## so of course the informational message is not printed in the log.
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14190
diff changeset
849