Natools

Check-in [2d7c2f8e09]
Login
Overview
Comment:reference_tests: use the new access-based constructors, to reach full coverage again
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2d7c2f8e09624bc5547f2d1d0bd027af84845054
User & Date: nat on 2014-07-12 16:08:22
Other Links: manifest | tags
Context
2014-07-13
14:27
s_expressions-file_readers: add an atom-reference read function check-in: d6e43fe336 user: nat tags: trunk
2014-07-12
16:08
reference_tests: use the new access-based constructors, to reach full coverage again check-in: 2d7c2f8e09 user: nat tags: trunk
2014-07-11
20:37
references: use access value directly in new constructors, instead of access to functions returning access value check-in: c104c5befa user: nat tags: trunk
Changes

Modified tests/natools-reference_tests.adb from [a304628ce9] to [f6e23bd423].

53
54
55
56
57
58
59







60
61
62
63
64
65
66
   function Factory return Counter is
   begin
      Instance_Count := Instance_Count + 1;
      return Counter'(Ada.Finalization.Limited_Controlled with
         Instance_Number => Instance_Count);
   end Factory;









   overriding procedure Finalize (Object : in out Counter) is
      pragma Unreferenced (Object);
   begin
      Instance_Count := Instance_Count - 1;
   end Finalize;








>
>
>
>
>
>
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
   function Factory return Counter is
   begin
      Instance_Count := Instance_Count + 1;
      return Counter'(Ada.Finalization.Limited_Controlled with
         Instance_Number => Instance_Count);
   end Factory;


   overriding procedure Initialize (Object : in out Counter) is
   begin
      Instance_Count := Instance_Count + 1;
      Object.Instance_Number := Instance_Count;
   end Initialize;


   overriding procedure Finalize (Object : in out Counter) is
      pragma Unreferenced (Object);
   begin
      Instance_Count := Instance_Count - 1;
   end Finalize;

228
229
230
231
232
233
234

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
      Initial_Count : constant Integer := Instance_Count;
      Continue : Boolean := True;
   begin
      declare
         procedure Check (Count_0, Count_1, Count_2, Delta_I : in Integer);

         Ref_0 : Refs.Reference := Refs.Create (Factory'Access);

         Ref_1, Ref_2 : Refs.Reference;

         procedure Check (Count_0, Count_1, Count_2, Delta_I : in Integer) is
         begin
            Check_Ref (Report, Name, Ref_0, Count_0, Continue);
            Check_Ref (Report, Name, Ref_1, Count_1, Continue);
            Check_Ref (Report, Name, Ref_2, Count_2, Continue);
            Check_Consistency (Report, Name, Ref_0, Ref_1, Continue);
            Check_Consistency (Report, Name, Ref_1, Ref_2, Continue);
            Check_Consistency (Report, Name, Ref_2, Ref_0, Continue);
            Check_Count (Report, Name, Initial_Count + Delta_I, Continue);
         end Check;
      begin
         Check (1, 0, 0, 1);

         if Continue then
            Ref_1 := Refs.Create (Factory'Access);
         end if;

         Check (1, 1, 0, 2);

         if Continue then
            Ref_2 := Ref_0;
         end if;

         Check (2, 1, 2, 2);

         if Continue then
            Ref_1 := Ref_0;
         end if;

         Check (3, 3, 3, 1);

         if Continue then
            Ref_2.Replace (Factory'Access);
         end if;

         Check (2, 2, 1, 2);

         if Continue then
            Ref_1.Reset;
            Ref_0 := Ref_1;







>
|















|

















|







235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
      Initial_Count : constant Integer := Instance_Count;
      Continue : Boolean := True;
   begin
      declare
         procedure Check (Count_0, Count_1, Count_2, Delta_I : in Integer);

         Ref_0 : Refs.Reference := Refs.Create (Factory'Access);
         Ref_1 : Refs.Reference := Refs.Create (Refs.Data_Access'(null));
         Ref_2 : Refs.Reference;

         procedure Check (Count_0, Count_1, Count_2, Delta_I : in Integer) is
         begin
            Check_Ref (Report, Name, Ref_0, Count_0, Continue);
            Check_Ref (Report, Name, Ref_1, Count_1, Continue);
            Check_Ref (Report, Name, Ref_2, Count_2, Continue);
            Check_Consistency (Report, Name, Ref_0, Ref_1, Continue);
            Check_Consistency (Report, Name, Ref_1, Ref_2, Continue);
            Check_Consistency (Report, Name, Ref_2, Ref_0, Continue);
            Check_Count (Report, Name, Initial_Count + Delta_I, Continue);
         end Check;
      begin
         Check (1, 0, 0, 1);

         if Continue then
            Ref_1 := Refs.Create (new Counter);
         end if;

         Check (1, 1, 0, 2);

         if Continue then
            Ref_2 := Ref_0;
         end if;

         Check (2, 1, 2, 2);

         if Continue then
            Ref_1 := Ref_0;
         end if;

         Check (3, 3, 3, 1);

         if Continue then
            Ref_2.Replace (new Counter);
         end if;

         Check (2, 2, 1, 2);

         if Continue then
            Ref_1.Reset;
            Ref_0 := Ref_1;

Modified tests/natools-reference_tests.ads from [eb6f847a7f] to [695396ae27].

43
44
45
46
47
48
49

50
51
52
53
54
55
56
57
58
59
   Instance_Count : Integer := 0;

   type Counter is new Ada.Finalization.Limited_Controlled with record
      Instance_Number : Natural := 0;
   end record;

   function Factory return Counter;

   overriding procedure Finalize (Object : in out Counter);

   Pool : GNAT.Debug_Pools.Debug_Pool;

   package Refs is new Natools.References
     (Counter,
      System.Storage_Pools.Root_Storage_Pool'Class (Pool),
      System.Storage_Pools.Root_Storage_Pool'Class (Pool));

end Natools.Reference_Tests;







>










43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
   Instance_Count : Integer := 0;

   type Counter is new Ada.Finalization.Limited_Controlled with record
      Instance_Number : Natural := 0;
   end record;

   function Factory return Counter;
   overriding procedure Initialize (Object : in out Counter);
   overriding procedure Finalize (Object : in out Counter);

   Pool : GNAT.Debug_Pools.Debug_Pool;

   package Refs is new Natools.References
     (Counter,
      System.Storage_Pools.Root_Storage_Pool'Class (Pool),
      System.Storage_Pools.Root_Storage_Pool'Class (Pool));

end Natools.Reference_Tests;