comp.lang.ada
 help / color / mirror / Atom feed
* Dynamic_Predicate failure -> Assertion_Error?
@ 2014-05-13 11:22 Jacob Sparre Andersen
  2014-05-13 21:26 ` Randy Brukardt
  0 siblings, 1 reply; 2+ messages in thread
From: Jacob Sparre Andersen @ 2014-05-13 11:22 UTC (permalink / raw)


I am experimenting a bit with GNAT-GPL-2013 and some of the new features
in Ada 2012.

% cat primes.ads
package Primes is
   subtype Prime is Integer range 2 .. Integer'Last
     with Dynamic_Predicate
       => (for all N in 2 .. Prime - 1 => Prime mod N /= 0);
end Primes;
% cat test_primes.adb
with Ada.Assertions,
     Ada.Text_IO;
with Primes;

procedure Test_Primes is
   use Primes;
   P : Prime;
begin
   for I in 1 .. 25 loop
      begin
         P := I;
         Ada.Text_IO.Put_Line (Prime'Image (P) & " is a prime.");
      exception
         when Constraint_Error =>
            Ada.Text_IO.Put_Line (Integer'Image (I) &
                                  " is not a prime (constraint).");
         when Ada.Assertions.Assertion_Error =>
            Ada.Text_IO.Put_Line (Integer'Image (I) &
                                  " is not a prime (predicate).");
      end;
   end loop;
end Test_Primes;
% gnatmake -gnat12 -gnata -gnato -fstack-check test_primes
gcc -c -gnat12 -gnata -gnato -fstack-check test_primes.adb
gcc -c -gnat12 -gnata -gnato -fstack-check primes.ads
gnatbind -x test_primes.ali
gnatlink test_primes.ali -fstack-check
% ./test_primes
 1 is not a prime (constraint).
 2 is a prime.
 3 is a prime.
 4 is not a prime (constraint).
[...]

As I read 3.2.4(31/3) the raised exception for 4 should be
Assertion_Error and not Constraint_Error.  Is this correct?

If I am correct, is there any likelihood that I could get a test for
this into ACATS (assuming that I can figure out how to formulate it
properly)?

Greetings,

Jacob
-- 
"I don't want to gain immortality in my works.
 I want to gain it by not dying."

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-13 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-13 11:22 Dynamic_Predicate failure -> Assertion_Error? Jacob Sparre Andersen
2014-05-13 21:26 ` Randy Brukardt

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