octave-maintainers
[Top][All Lists]
Advanced

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

Re: function definitions in tests


From: David Grundberg
Subject: Re: function definitions in tests
Date: Mon, 18 Jan 2010 13:56:03 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090812)

Thorsten Meyer wrote:
Hi,

the tests for for example fsolve.m contain function definitions like this:
%!function retval = f (p)
%!  x = p(1);
%!  y = p(2);
%!  z = p(3);
%!  retval = zeros (3, 1);
%!  retval(1) = sin(x) + y**2 + log(z) - 7;
%!  retval(2) = 3*x + 2**y -z**3 + 1;
%!  retval(3) = x + y + z - 5;
%!test
%! x_opt = [ 0.599054;
%! 2.395931;
%! 2.005014 ];
%! tol = 1.0e-5;
%! [x, fval, info] = fsolve (@f, [ 0.5; 2.0; 2.5 ]);
%! assert (info > 0);
%! assert (norm (x - x_opt, Inf) < tol);
%! assert (norm (fval) < tol);

And these tests are passed nicely when running "make check".

However, when I try to test fsolve from an interactive octave session I get:
octave:1> test fsolve
  ***** function retval = f (p)
  x = p(1);
  y = p(2);
  z = p(3);
  retval = zeros (3, 1);
  retval(1) = sin(x) + y**2 + log(z) - 7;
  retval(2) = 3*x + 2**y -z**3 + 1;
  retval(3) = x + y + z - 5;
!!!!! test failed: syntax error
parse error:

  function body open at end of input


Probably, I am missing something obvious. How can I run tests with function
definitions interactively?

Thorsten

This might have to do with changes I did to the interpreter (after 3.2). I know I changed eval_string() to require function definitions to have endfunctions. I think this is a good thing when calling eval.m. But with tests, the block is defined by the indention and that should suffice. I'm pushing a changeset to fix this.

http://hg.savannah.gnu.org/hgweb/octave/rev/e68431e60e3d

regards,
David


reply via email to

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