Skip to content

Commit 3b4dd7a

Browse files
author
Viviane Garèse
committed
Fix unhandled exceptions in assertion test
For light runtimes the exception raised by unsatisfied assertions can only be caught by Silent_Last_Chance, rendering the exception catcher in the tests uncovered. Only rely on Silent_Last_Chance for the needed cases.
1 parent 89bf881 commit 3b4dd7a

File tree

7 files changed

+33
-20
lines changed

7 files changed

+33
-20
lines changed
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
with Ada.Assertions;
21
with Assertions; use Assertions;
2+
with Silent_Last_Chance;
33

44
procedure Assertions_2
55
is
66
Y : Integer := 2;
77
begin
8-
begin
9-
-- Call to Foo with a parameter that does not satisfy the
10-
-- precondition.
8+
-- Call to Foo with a parameter that does not satisfy the
9+
-- precondition.
1110

12-
Y := Foo (-2); -- # foo_2
13-
exception
14-
when Ada.Assertions.Assertion_Error => null; -- # catch_2
15-
end;
11+
Y := Foo (-2); -- # foo_2
1612
end Assertions_2;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
with Ada.Assertions;
2+
with Assertions_2;
3+
4+
procedure Catch_Assertions_2 is
5+
begin
6+
begin
7+
Assertions_2;
8+
exception
9+
when Ada.Assertions.Assertion_Error => null;
10+
end;
11+
end Catch_Assertions_2;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
with Ada.Assertions;
2+
with Expr_Func;
3+
4+
procedure Catch_Expr_Func is
5+
begin
6+
begin
7+
Expr_Func;
8+
exception
9+
when Ada.Assertions.Assertion_Error => null;
10+
end;
11+
end Catch_Expr_Func;

testsuite/tests/O212-062-assertions/src/expr_func.adb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pragma Assertion_Policy (Check);
22
pragma Ada_2012;
33

4-
with Ada.Assertions;
4+
with Silent_Last_Chance;
55

66
procedure Expr_Func
77
is
@@ -21,9 +21,5 @@ is
2121
begin
2222
Dummy := Foo (0); -- # foo_call
2323

24-
begin
25-
Dummy := Bar (42); -- # bar_call
26-
exception
27-
when Ada.Assertions.Assertion_Error => null; -- # catch
28-
end;
24+
Dummy := Bar (42); -- # bar_call
2925
end Expr_Func;

testsuite/tests/O212-062-assertions/src/test_assertions_2.adb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
with Assertions_2;
1+
with Catch_Assertions_2;
22

33
procedure Test_Assertions_2 is
44
begin
5-
Assertions_2;
5+
Catch_Assertions_2;
66
end Test_Assertions_2;
77

88
--# assertions.ads
@@ -27,4 +27,3 @@ end Test_Assertions_2;
2727
-- /same_ret/ l- ## s-
2828
--# assertions_2.adb
2929
-- /foo_2/ l+ ## c!
30-
-- /catch_2/ l+ ## 0

testsuite/tests/O212-062-assertions/src/test_expr_func.adb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
with Expr_Func;
1+
with Catch_Expr_Func;
22

33
procedure Test_Expr_Func is
44
begin
5-
Expr_Func;
5+
Catch_Expr_Func;
66
end Test_Expr_Func;
77

88
--# expr_func.adb
@@ -15,4 +15,3 @@ end Test_Expr_Func;
1515
-- /dummy_decl/ l+ ## 0
1616
-- /foo_call/ l+ ## 0
1717
-- /bar_call/ l+ ## 0
18-
-- /catch/ l+ ## 0

testsuite/tests/O212-062-assertions/src/test_type_inv_false.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
with Silent_Last_Chance;
12
with Pack_Type_Invariant;
23

34
with Ada.Assertions;

0 commit comments

Comments
 (0)