[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Moving tests into individual files
From: |
Thomas Weber |
Subject: |
Re: Moving tests into individual files |
Date: |
Tue, 15 Jan 2008 22:02:51 +0100 |
Am Dienstag, den 15.01.2008, 15:48 -0500 schrieb John W. Eaton:
> On 15-Jan-2008, Thomas Weber wrote:
>
> | The patch moves the tests from test_arith.m into the corresponding .m
> | files.
>
> Thanks. I applied this patch and checked it in with the following
> ChangeLog entries. If you move more of these tests, will you please
> include log entries like this with your patches?
Sure.
> | Should the same be done for the built-in and mapping functions?
> | If yes, an example how to do that would be appreciated.
>
> Sure, they go in the src/*.cc files. For an example of doing this for
> most functions, see the tests in src/strfns.cc. For mapper functions,
> you can put them in the src/mappers.cc file, like this:
>
> Index: src/mappers.cc
> ===================================================================
> RCS file: /cvs/octave/src/mappers.cc,v
> retrieving revision 1.97
> diff -u -u -r1.97 mappers.cc
> --- src/mappers.cc 12 Oct 2007 21:27:30 -0000 1.97
> +++ src/mappers.cc 15 Jan 2008 20:47:32 -0000
> @@ -248,6 +248,17 @@
> Compute the inverse sine of each element of @var{x}.\n\
> @end deftypefn");
>
> +/*
> +%!test
> +%! rt2 = sqrt (2);
> +%! rt3 = sqrt (3);
> +%! v = [0, pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6, 0];
> +%! x = [0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0];
> +%! assert(all (abs (asin (x) - v) < sqrt (eps)));
> +%!error asin ();
> +%!error asin (1, 2);
> +*/
> +
> DEFUN_MAPPER (asinh, 0, 0, 0, asinh, 0, asinh, 0.0, 0.0, 0, 0,
> "-*- texinfo -*-\n\
> @deftypefn {Mapping Function} {} asinh (@var{x})\n\
>
>
>
> Currently, the tests are placed below the function definition. I'm
> not sure whether this is the best place. Would we be more likely to
> notice them and remember to add more tests when editing a function if
> they were placed just above the corresponding DEFUN instead of below?
I don't think it makes a difference. Ideally, at least experienced users
would submit bug reports in a test case form. I'll try to make a mental
note about it for future reports.
Thomas