comp.lang.ada
 help / color / mirror / Atom feed
From: Dan <dan@irvine.com>
Subject: Re: ANN: Ahven 1.8
Date: Fri, 4 Jun 2010 10:12:37 -0700 (PDT)
Date: 2010-06-04T10:12:37-07:00	[thread overview]
Message-ID: <d506859b-e891-4376-abec-dc2479f621d1@v12g2000prb.googlegroups.com> (raw)
In-Reply-To: 827hmf17i8.fsf@stephe-leake.org

On Jun 4, 2:17 am, Stephen Leake <stephen_le...@stephe-leake.org>
wrote:
> Dan <d...@irvine.com> writes:
> > On Jun 3, 5:08 am, Stephen Leake <stephen_le...@stephe-leake.org>
> > wrote:
> >> How does it compare to AUnit?
>
> > I am able to use Ahven in a table-driven manner, as shown below.
> > But I don't see a way to use AUnit similarly (replacing the Ahven-
> > specific code below the line of dashes).
>
> > ...
> > with p1, p2, p3;
> > with test_suite; use test_suite;
> > package p_suite is new test_suite.suites(
> >      suite_name => "p",
> >      suite_arr => (
> >         (p1'access, +"p1"),
> >         (p2'access, +"p3"),
> >         (p3'access, +"p3")));
>
> In AUnit, tests are 'registered' in a test_case:
>
>    overriding procedure Register_Tests (T : in out Test_Case)
>    is
>    begin
>         Register_Routine (T, Nominal'Access, "Nominal");
>         Register_Routine (T, Commands'Access, "Commands");
>         Register_Routine (T, Glitches'Access, "Glitches");
>         Register_Routine (T, Multi_Cycle'Access, "Multi_Cycle");
>   end Register_Tests;
>
> Then test_cases are added to suites:
>
>    Add_Test (Suite, new Test_Hardware.Analog_In_Out_Wrappers.Test_Case);
>    Add_Test (Suite, new Test_Hardware.Analog_In_Wrapper_Common.Test_Case);
>    Add_Test (Suite, new Test_Hardware.Analog_Out_Wrapper_Common.Test_Case);
>
> This seems roughly equivalent to Ahven.
>
> AUnit also has setup and teardown functions for initializing and finalizing
> each test and/or each Test_Case; those are very helpful.
>
> --
> -- Stephe

There is a significant difference in registering tests between Ahven
and Aunit, which Tero mentions, but I will expand on.

Ahven accepts parameterless procedures as test routines,
such as the p1,p2,p3,q1,q2,q3 in my example.  AUnit, in contrast,
requires test routines to have a parameter of type
AUnit.Test_Cases.Test_Case'Class.  I have thousands of procedures that
I would like to test using a test driver, but unfortunately not a
single one of those comes in the form AUnit requires.

If you start with an array of parameterless test procedures, AUnit
requires that you traverse the array, creating a new test procedure
(containing the required parameter) for each parameterless test
procedure in the array.  Then you can register the newly created test
procedures.

The problem is that Ada doesn't have a good way for one procedure to
create other procedures, that can then be registered (using 'access).
I tried using generics to instantiate the new test procedures, but ran
into accessiblity-level problems.  I also tried using an allocator of
a protected type that contains a procedure, but that results in a
protected procedure, and AUnit only knows how to register normal
(unprotected) procedures.

I presume that it may be possible to modify AUnit to support
registering parameterless test procedures (or even better, an array of
them), which would be convenient for my purposes.  It would also be
possible to write some sort of offline test-generator that creates the
kind of test procedures that AUnit expects.



  parent reply	other threads:[~2010-06-04 17:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-02 16:24 ANN: Ahven 1.8 Tero Koskinen
2010-06-03 12:08 ` Stephen Leake
2010-06-03 19:36   ` Dan
2010-06-03 19:43     ` Dan
2010-06-04  9:17     ` Stephen Leake
2010-06-04 15:37       ` Tero Koskinen
2010-06-05 12:41         ` Simon Wright
2010-06-05 19:17           ` Ludovic Brenta
2010-06-06 12:31             ` Stephen Leake
2010-06-06 16:20               ` Ludovic Brenta
2010-06-06 16:45                 ` Simon Wright
2010-06-06 17:48                   ` Ludovic Brenta
2010-06-07  8:26                 ` Stephen Leake
2010-06-07 19:21                   ` Simon Wright
2010-06-04 17:12       ` Dan [this message]
2010-06-05  4:08         ` Stephen Leake
2010-06-08 15:24 ` Jérôme Haguet
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox