Starting an Ada track

Sweet!

Okay, so next up… we need some unit tests.

The original issue from when an Ada track was first requested listed GNATtest as a unit testing framework we could use.

Does that sound right, still?

If so, what would a simple test suite look like?

1 Like

Perhaps it’s better to use Ahven unit test library instead of gnattest.

1 Like

I don’t have any context about either. Do you have a sense of pros/cons with respect to our setup at Exercism?

1 Like

Spread pretty thin these days. I might be able to port an exercise or two to help you spin up if you get the track tooling in place, but I can’t really help with maintainership. I used Ada 95 for some systems programming courses at West Point way back when, but I haven’t touched the language since.

One thing to keep in mind is that once this thing it up, people will be requesting mentorship. The track tools also have to be maintained. This is an indefinite open-ended commitment. Getting to 20 exercises with the necessary tooling is just the start.

2 Likes

You may find the makings for a few exercises on Rosettacode.org

1 Like

We need to choose a testing framework if we’re going to move forward with an Ada track.

So far I’ve heard one vote for GNATtest, and one vote for Ahven, but I’ve not yet heard any reasoning around either of the choices.

If it doesn’t matter which we choose, I’m happy to just flip a coin.

Here’s a test suite that uses GNATtest:

with GNATtest; use GNATtest;
with Hello;

procedure Hello_Test is
begin
   Assert.Equal(Hello.Hello, "Hello, World!");
end Hello_Test;

And here’s the equivalent test suite using Ahven:

with Ahven;
with Hello;

procedure Hello_Test is new Test_Unit
  with Procedure => Hello_Test_Case;

procedure Hello_Test_Case is
begin
   Assert.String_Equal(Hello.Hello, "Hello, World!");
end Hello_Test_Case;

Thoughts?

I have no real Ada knowledge, but I prefer the shorter simplicity of GNATtest.

1 Like

AFAIK gnattest doesn’t provides GNATtest package,because it’s a tool, not a library:

gnattest tool is a utility that creates unit-test skeletons as well as a test driver infrastructure (harness).

It uses AUnit in the generated code. Here is example of a test with AUnit (in examples/simple_test/tests/math-test.adb of the repo):

with AUnit.Assertions; use AUnit.Assertions;

package body Math.Test is

   function Name (T : Test) return AUnit.Message_String is
      pragma Unreferenced (T);
   begin
      return AUnit.Format ("Test Math package");
   end Name;

   procedure Run_Test (T : in out Test) is
      pragma Unreferenced (T);
      I1 : constant Int := 5;
      I2 : constant Int := 3;
   begin
      Assert (I1 + I2 = 8, "Incorrect result after addition");
      Assert (I1 - I2 = 2, "Incorrect result after subtraction");
   end Run_Test;

end Math.Test;

I have been taking a look at the Ada track, I’ve already done the “Hello, World” and “Leap” problems, will tackle a test generator next (to read the test cases from the problem specification JSON and generate the unit tests) and probably a test runner after that

3 Likes

In the event that I’m able to contribute, which Ada are you targeting?

I can contribute an exercise or two as well once we figure out the testing framework.