octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Moving tests into individual files


From: John W. Eaton
Subject: Moving tests into individual files
Date: Tue, 15 Jan 2008 15:48:53 -0500

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?

test/ChangeLog:

2008-01-15  Thomas Weber  <address@hidden>

        * test_arith.m: Move tests to source files.

scripts/ChangeLog:

2008-01-15  Thomas Weber  <address@hidden>

        * elfun/acot.m, elfun/acoth.m, elfun/acsc.m, elfun/acsch.m,
        elfun/asec.m, elfun/asech.m, elfun/cot.m, elfun/coth.m,
        elfun/csc.m,elfun/csch.m, elfun/lcm.m, elfun/sec.m, elfun/sech.m,
        general/rem.m, miscellaneous/bincoeff.m, miscellaneous/xor.m,
        specfun/beta.m, specfun/log2.m, specfun/pow2.m:
        Move tests here from test/test_arith.m.

| 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?

Thanks,

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]