Natools

Check-in [6fb20358ef]
Login
Overview
Comment:s_expressions-printers-pretty-config-tests: add tests to reach a decent coverage of the rewritten version
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6fb20358efab318a4ae178509ba0d95c78350201
User & Date: nat on 2014-06-03 21:22:35
Other Links: manifest | tags
Context
2014-06-04
21:05
s_expressions-printers-pretty: redesign the package around an abstract type with user-provided backend write procedure check-in: ee89558365 user: nat tags: trunk
2014-06-03
21:22
s_expressions-printers-pretty-config-tests: add tests to reach a decent coverage of the rewritten version check-in: 6fb20358ef user: nat tags: trunk
2014-06-02
19:16
s_expressions-printers-pretty-config: rewrite the parser using static hash maps check-in: 3cedc46373 user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-printers-pretty-config-tests.adb from [ceb95f4a79] to [3d820bc56d].

12
13
14
15
16
17
18

19
20
21
22
23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26







+







-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

with Natools.S_Expressions.Encodings;
with Natools.S_Expressions.Parsers;
with Natools.S_Expressions.Printers.Pretty.Config.Commands.T;
with Natools.S_Expressions.Test_Tools;

package body Natools.S_Expressions.Printers.Pretty.Config.Tests is

   procedure Check_Param
     (Test : in out NT.Test;
      Result : in Parameters;
191
192
193
194
195
196
197

198
199
200
201
202
203
204
205
206











207
208
209
210
211
212
213
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226







+









+
+
+
+
+
+
+
+
+
+
+








   -------------------------
   -- Complete Test Suite --
   -------------------------

   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Hash_Function_Test (Report);
      Read_Test (Report);
      Write_Test (Report);
   end All_Tests;



   ----------------------
   -- Individual Tests --
   ----------------------

   procedure Hash_Function_Test (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Interpreter hash functions");
   begin
      if not Commands.T then
         Test.Fail;
      end if;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Hash_Function_Test;


   procedure Read_Test (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Read from S-expression");
   begin
      declare
         Param : Parameters := Canonical;
         Expected : Parameters;
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
285
286
287
288
289
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

285
286
287
288
289
290
291
292
293

294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312







+






+
+














-
+


+





-
+





+
+
+
+
+
+







               Newline => CR_LF);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Update (Param, Parser);
         Check_Param (Test, Param, Expected, "In first expression:");

         Input.Write (To_Atom
           ("(indentation 3 spaces)width(token extended)"
            & "LF(quoted never)"
            & "(newline (not close-close))"));
         Expected.Indentation := 3;
         Expected.Indent := Spaces;
         Expected.Width := 0;
         Expected.Token := Extended_Token;
         Expected.Newline_At (Closing, Closing) := False;
         Expected.Newline := LF;
         Expected.Quoted := No_Quoted;
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Update (Param, Parser);
         Check_Param (Test, Param, Expected, "In second expression:");

         Input.Write (To_Atom
           ("(indentation 4 tabbed-spaces)upper-hex(width (10))(token)"));
         Expected.Indentation := 4;
         Expected.Indent := Tabs_And_Spaces;
         Expected.Hex_Casing := Encodings.Upper;
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Update (Param, Parser);
         Check_Param (Test, Param, Expected, "In third expression:");

         Input.Write (To_Atom
           ("no-indentation(token never)"));
           ("no-indentation(token never)(newline)(width 72)"));
         Expected.Indentation := 0;
         Expected.Token := No_Token;
         Expected.Width := 72;
         Test_Tools.Next_And_Check (Test, Parser, Events.Add_Atom, 0);
         Update (Param, Parser);
         Check_Param (Test, Param, Expected, "In fourth expression:");

         Input.Write (To_Atom
           ("lower-case(token standard)"));
           ("lower-case(token standard)(width 0:)"));
         Expected.Token := Standard_Token;
         Expected.Hex_Casing := Encodings.Lower;
         Test_Tools.Next_And_Check (Test, Parser, Events.Add_Atom, 0);
         Update (Param, Parser);
         Check_Param (Test, Param, Expected, "In fifth expression:");

         Input.Write (To_Atom
           ("(token unrecognized-junk)(width 0xBAD)"));
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Update (Param, Parser);
         Check_Param (Test, Param, Expected, "In sixth expression:");
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Read_Test;


   procedure Write_Test (Report : in out NT.Reporter'Class) is

Modified tests/natools-s_expressions-printers-pretty-config-tests.ads from [b41b60ecf9] to [a592363422].

25
26
27
28
29
30
31

32
33
34
35
25
26
27
28
29
30
31
32
33
34
35
36







+




package Natools.S_Expressions.Printers.Pretty.Config.Tests is
   pragma Preelaborate (Tests);

   package NT renames Natools.Tests;

   procedure All_Tests (Report : in out NT.Reporter'Class);

   procedure Hash_Function_Test (Report : in out NT.Reporter'Class);
   procedure Read_Test (Report : in out NT.Reporter'Class);
   procedure Write_Test (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Printers.Pretty.Config.Tests;