octave-maintainers
[Top][All Lists]
Advanced

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

Re: Converting DejaGNU tests to Paul's test/assert infrastructure


From: Andy Adler
Subject: Re: Converting DejaGNU tests to Paul's test/assert infrastructure
Date: Mon, 24 Oct 2005 10:06:27 -0400 (EDT)

On Mon, 24 Oct 2005, David Bateman wrote:

> Dear All,
>
> I've written a perl script over the weekend that attempts to
> automatically convert the DejaGNU scripts into scripts usable with
> Paul's test/assert infrastructure. It seems to work well in the cases
> I've currently tested it against (definitely not all of them). However I
> have a particular problem with the test/octave.test/args DejaGNU tests.
> These tests are of the form
>
> 1;
> function [varargout] = f (varargin)
>  printf ("nargin: %d, nargout: %d\n", nargin, nargout);
> endfunction
> [s, t, u, v] = f (1, 2, 3);
>
> and the DejaGNU expected result is
>
> set test args-10
> set prog_output "nargin: 3, nargout: 4"
> do_test args-10.m
>
> The only fashion I see of converting this test is something like
>
> %!test
> %! global nout nin;
> %! function [varargout] = f (varargin)
> %!   global nout, nin;
> %!   nout = nargout; nin = nargin;
> %! endfunction
> %! [s, t, u, v] = f (1, 2, 3);
> %! assert(nout,4);
> %! assert(nin,3);

You could make the conversion slightly easier to automate like this:
*warning* untested code.

 1;
 function [varargout] = f (varargin)
  prinf_to_assert ("nargin: %d, nargout: %d\n", nargin, nargout);
 endfunction
 [s, t, u, v] = f (1, 2, 3);
 assert_prog_output( "nargin: 3, nargout: 4" );

with auxilary functions

function printf_to_assert(varargin)
  global _assert_program_output_;
  _assert_program_output_= sprintf( varargin );

and

function assert_prog_output( str )
  global _assert_program_output_;
  assert( strcmp( _assert_program_output_ , str ));


--
Andy Adler <address@hidden> 1(613)562-5800x6218




reply via email to

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