Natools

Check-in [9f0014f72d]
Login
Overview
Comment:Migrate from Subpraser to Stream_Parser in the whole code base
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9f0014f72ded06800968ce88c110786cd5d1d71f
User & Date: nat on 2014-03-26 19:10:41
Other Links: manifest | tags
Context
2014-03-27
21:24
s_expressions-parsers-tests: adapt the test suite to the new Parsers packet check-in: b02835bdfa user: nat tags: trunk
2014-03-26
19:10
Migrate from Subpraser to Stream_Parser in the whole code base check-in: 9f0014f72d user: nat tags: trunk
2014-03-25
19:09
s_expressions-parsers: redesign the whole package around an abstract type with user-provided data source check-in: bdd6a2a904 user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-cache_tests.adb from [f3f37a7b0d] to [47eb5e3287].

315
316
317
318
319
320
321
322
323

324
325
326
327


328
329
330
331
332
333
334
335
336
337
338
339
340
315
316
317
318
319
320
321


322
323
324


325
326
327
328
329
330
331
332
333
334
335
336
337
338
339







-
-
+


-
-
+
+













      Test : NT.Test := Report.Item ("Lockable.Descriptor insterface");
   begin
      declare
         Cache : Caches.Reference;
      begin
         declare
            Input : aliased Test_Tools.Memory_Stream;
            Parser : aliased Parsers.Parser;
            Subparser : Parsers.Subparser (Parser'Access, Input'Access);
            Parser : Parsers.Stream_Parser (Input'Access);
         begin
            Input.Set_Data (Lockable.Tests.Test_Expression);
            Test_Tools.Next_And_Check (Test, Subparser, Events.Open_List, 1);
            Printers.Transfer (Subparser, Cache);
            Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
            Printers.Transfer (Parser, Cache);
         end;

         declare
            Cursor : Caches.Cursor := Cache.First;
         begin
            Lockable.Tests.Test_Interface (Test, Cursor);
         end;
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Lockable_Interface;

end Natools.S_Expressions.Cache_Tests;

Modified tests/natools-s_expressions-lockable-tests.adb from [231d964525] to [7792651601].

264
265
266
267
268
269
270
271

272
273

274
275
276
277
278
279
280
264
265
266
267
268
269
270

271


272
273
274
275
276
277
278
279







-
+
-
-
+









   procedure Test_Wrapper_Extra (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Extra tests of wrapper");
   begin
      declare
         Input : aliased Test_Tools.Memory_Stream;
         Parser : aliased Parsers.Parser;
         Parser : aliased Parsers.Stream_Parser (Input'Access);
         Subparser : aliased Parsers.Subparser (Parser'Access, Input'Access);
         Tested : Wrapper (Subparser'Access);
         Tested : Wrapper (Parser'Access);
         State : Lock_State;
      begin
         Input.Set_Data (To_Atom ("(cmd1 arg1)(cmd2 4:arg2"));

         --  Check Events.Error is returned by Next when finished

         Test_Tools.Next_And_Check (Test, Tested, Events.Open_List, 1);
300
301
302
303
304
305
306
307

308
309

310
311
312

313
314
315
316
317
318
319
299
300
301
302
303
304
305

306


307
308
309

310
311
312
313
314
315
316
317







-
+
-
-
+


-
+








   procedure Test_Wrapper_Interface (Report : in out NT.Reporter'Class) is
      Test : NT.Test
        := Report.Item ("Lockable.Descriptor interface of wrapper");
   begin
      declare
         Input : aliased Test_Tools.Memory_Stream;
         Parser : aliased Parsers.Parser;
         Parser : aliased Parsers.Stream_Parser (Input'Access);
         Subparser : aliased Parsers.Subparser (Parser'Access, Input'Access);
         Tested : Wrapper (Subparser'Access);
         Tested : Wrapper (Parser'Access);
      begin
         Input.Set_Data (Test_Expression);
         Test_Tools.Next_And_Check (Test, Subparser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Interface (Test, Tested);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Test_Wrapper_Interface;

end Natools.S_Expressions.Lockable.Tests;

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

208
209
210
211
212
213
214
215
216

217
218
219
220
221
222
223
208
209
210
211
212
213
214


215
216
217
218
219
220
221
222







-
-
+







   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;
         Input : aliased Test_Tools.Memory_Stream;
         Parser : aliased Parsers.Parser;
         Subparser : Parsers.Subparser (Parser'Access, Input'Access);
         Parser : Parsers.Stream_Parser (Input'Access);
      begin
         Input.Write (To_Atom
           ("(width 80)"
            & "(newline cr-lf atom-atom all)"
            & "utf-8"
            & "(space none open-open open-atom open-close atom-open atom-atom"
            & " atom-close close-open close-atom close-close)"
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
285
286
287
288
289
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
285
286
287
288







-
-
+
+










-
-
+
+







-
-
+
+






-
-
+
+






-
-
+
+







               Quoted => Single_Line,
               Token => Standard_Token,
               Hex_Casing => Encodings.Lower,
               Quoted_Escape => Hex_Escape,
               Char_Encoding => UTF_8,
               Fallback => Hexadecimal,
               Newline => CR_LF);
         Test_Tools.Next_And_Check (Test, Subparser, Events.Open_List, 1);
         Update (Param, Subparser);
         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)"
            & "(newline (not close-close))"));
         Expected.Indentation := 3;
         Expected.Indent := Spaces;
         Expected.Width := 0;
         Expected.Token := Extended_Token;
         Expected.Newline_At (Closing, Closing) := False;
         Test_Tools.Next_And_Check (Test, Subparser, Events.Open_List, 1);
         Update (Param, Subparser);
         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, Subparser, Events.Open_List, 1);
         Update (Param, Subparser);
         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)"));
         Expected.Indentation := 0;
         Expected.Token := No_Token;
         Test_Tools.Next_And_Check (Test, Subparser, Events.Add_Atom, 0);
         Update (Param, Subparser);
         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)"));
         Expected.Token := Standard_Token;
         Expected.Hex_Casing := Encodings.Lower;
         Test_Tools.Next_And_Check (Test, Subparser, Events.Add_Atom, 0);
         Update (Param, Subparser);
         Test_Tools.Next_And_Check (Test, Parser, Events.Add_Atom, 0);
         Update (Param, Parser);
         Check_Param (Test, Param, Expected, "In fifth expression:");
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Read_Test;


298
299
300
301
302
303
304
305
306

307
308
309
310
311
312


313
314
315
316
317
318
319
297
298
299
300
301
302
303


304
305
306
307
308


309
310
311
312
313
314
315
316
317







-
-
+




-
-
+
+







      procedure Testcase
        (Title : in String;
         Param : in Parameters;
         Expr : in String)
      is
         Buffer : aliased Test_Tools.Memory_Stream;
         Output : Printers.Canonical (Buffer'Access);
         Parser : aliased Parsers.Parser;
         Subparser : Parsers.Subparser (Parser'Access, Buffer'Access);
         Parser : Parsers.Stream_Parser (Buffer'Access);
         Reread : Parameters := Pretty.Canonical;
      begin
         Buffer.Set_Expected (To_Atom (Expr));
         Print (Output, Param);
         Subparser.Next;
         Update (Reread, Subparser);
         Parser.Next;
         Update (Reread, Parser);
         Check_Param (Test, Reread, Param, Title);
         Buffer.Check_Stream (Test);
      end Testcase;
   begin
      Testcase ("First case:",
        (Width => 80,
         Newline_At => (others => (others => True)),

Modified tests/natools-s_expressions-printers-pretty-tests.adb from [4985db0008] to [c8351fae34].

40
41
42
43
44
45
46
47
48

49
50
51
52
53
54
55


56
57
58
59
60
61
62
40
41
42
43
44
45
46


47
48
49
50
51
52


53
54
55
56
57
58
59
60
61







-
-
+





-
-
+
+







   procedure Parse_Print_Test
     (Test : in out NT.Test;
      Param : in Parameters;
      Expected : in Atom) is
   begin
      declare
         Input, Output : aliased Test_Tools.Memory_Stream;
         Parser : aliased Parsers.Parser;
         Subparser : Parsers.Subparser (Parser'Access, Input'Access);
         Parser : Parsers.Stream_Parser (Input'Access);
         Pretty_Printer : Printer (Output'Access);
      begin
         Input.Set_Data (Expected);
         Output.Set_Expected (Expected);
         Pretty_Printer.Set_Parameters (Param);
         Subparser.Next;
         Transfer (Subparser, Pretty_Printer);
         Parser.Next;
         Transfer (Parser, Pretty_Printer);
         Output.Check_Stream (Test);
      end;
   exception
      when Error : others =>
         Test.Report_Exception (Error);
   end Parse_Print_Test;