From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2273a296de8c1b6d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!v12g2000prb.googlegroups.com!not-for-mail From: Dan Newsgroups: comp.lang.ada Subject: Re: ANN: Ahven 1.8 Date: Fri, 4 Jun 2010 10:12:37 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <20100602192413.ff36db38.tero.koskinen@iki.fi> <82ocfs1fpv.fsf@stephe-leake.org> <357172d2-0e3f-4700-bcbb-3351f93c8372@s1g2000prf.googlegroups.com> <827hmf17i8.fsf@stephe-leake.org> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1275671557 11208 127.0.0.1 (4 Jun 2010 17:12:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 Jun 2010 17:12:37 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v12g2000prb.googlegroups.com; posting-host=66.126.103.122; posting-account=mj1SqQkAAAC-ugS7xMajTlZAhqdqcRbD User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.14) Gecko/2009090216 Ubuntu/9.04 (jaunty) Firefox/3.0.14,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:11285 Date: 2010-06-04T10:12:37-07:00 List-Id: On Jun 4, 2:17=A0am, Stephen Leake wrote: > Dan writes: > > On Jun 3, 5:08=A0am, Stephen Leake > > 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( > > =A0 =A0 =A0suite_name =3D> "p", > > =A0 =A0 =A0suite_arr =3D> ( > > =A0 =A0 =A0 =A0 (p1'access, +"p1"), > > =A0 =A0 =A0 =A0 (p2'access, +"p3"), > > =A0 =A0 =A0 =A0 (p3'access, +"p3"))); > > In AUnit, tests are 'registered' in a test_case: > > =A0 =A0overriding procedure Register_Tests (T : in out Test_Case) > =A0 =A0is > =A0 =A0begin > =A0 =A0 =A0 =A0 Register_Routine (T, Nominal'Access, "Nominal"); > =A0 =A0 =A0 =A0 Register_Routine (T, Commands'Access, "Commands"); > =A0 =A0 =A0 =A0 Register_Routine (T, Glitches'Access, "Glitches"); > =A0 =A0 =A0 =A0 Register_Routine (T, Multi_Cycle'Access, "Multi_Cycle"); > =A0 end Register_Tests; > > Then test_cases are added to suites: > > =A0 =A0Add_Test (Suite, new Test_Hardware.Analog_In_Out_Wrappers.Test_Cas= e); > =A0 =A0Add_Test (Suite, new Test_Hardware.Analog_In_Wrapper_Common.Test_C= ase); > =A0 =A0Add_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 finalizi= ng > 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.