Natools

Check-in [d002179746]
Login
Overview
Comment:s_expressions-printers-pretty-tests: new test for newline output formats
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d002179746f2fe4c63e97cecd168a836788dbf8f
User & Date: nat on 2014-02-05 19:22:06
Other Links: manifest | tags
Context
2014-02-06
22:20
s_expressions-printers-pretty: fix quoted encoding size estimation on inserted newlines check-in: 528e853e08 user: nat tags: trunk
2014-02-05
19:22
s_expressions-printers-pretty-tests: new test for newline output formats check-in: d002179746 user: nat tags: trunk
2014-02-04
19:17
s_expressions-printers-pretty: fix cursor updates in single-line quoted string atoms check-in: a94c289c5f user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-printers-pretty-tests.adb from [79759db515] to [748332722d].

110
111
112
113
114
115
116

117
118
119
120
121
122
123
   begin
      Basic_Printing (Report);
      Atom_Encodings (Report);
      Separators (Report);
      Atom_Width (Report);
      Quoted_String_Escapes (Report);
      Indentation (Report);

   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------







>







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
   begin
      Basic_Printing (Report);
      Atom_Encodings (Report);
      Separators (Report);
      Atom_Width (Report);
      Quoted_String_Escapes (Report);
      Indentation (Report);
      Newline_Formats (Report);
   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------
291
292
293
294
295
296
297


































































































298
299
300
301
302
303
304
         & Latin_1.HT & Latin_1.HT & Latin_1.HT & "2:Q(" & Latin_1.LF
         & Latin_1.HT & Latin_1.HT & "))end)"));

   exception
      when Error : others => Test.Report_Exception (Error);
   end Indentation;




































































































   procedure Quoted_String_Escapes (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Escapes in quoted string atoms");
      Source : constant Atom (0 .. 123) := To_Atom
        ("Special: "  --  indices 0 .. 17
         & Latin_1.BS & Latin_1.HT & Latin_1.LF
         & Latin_1.VT & Latin_1.FF & Latin_1.CR







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
         & Latin_1.HT & Latin_1.HT & Latin_1.HT & "2:Q(" & Latin_1.LF
         & Latin_1.HT & Latin_1.HT & "))end)"));

   exception
      when Error : others => Test.Report_Exception (Error);
   end Indentation;


   procedure Newline_Formats (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Newline formats");

      procedure Print (Pr : in out Printer);

      procedure Print (Pr : in out Printer) is
      begin
         Pr.Open_List;
         Pr.Append_Atom (To_Atom ("begin"));
         Pr.Append_Atom (To_Atom
           ("quoted" & Latin_1.CR & Latin_1.LF & Latin_1.CR & "str"));
         Pr.Close_List;
      end Print;

      Param : Parameters
        := (Width => 7,
            Newline_At => (others => (others => False)),
            Space_At => (others => (others => False)),
            Tab_Stop => 8,  --  unused
            Indentation => 1,
            Indent => Spaces,
            Quoted => When_Shorter,
            Token => Standard_Token,
            Hex_Casing => Encodings.Upper,
            Quoted_Escape => Hex_Escape,
            Char_Encoding => ASCII,
            Fallback => Hexadecimal,
            Newline => CR);
   begin
      Param.Newline_At (Atom_Data, Atom_Data) := True;

      declare
         Output : aliased Test_Tools.Memory_Stream;
         Pr : Printer (Output'Access);
      begin
         Pr.Set_Parameters (Param);
         Output.Set_Expected (To_Atom
           ("(begin" & Latin_1.CR
            & " ""quot\" & Latin_1.CR
            & "ed" & Latin_1.CR
            & "\n" & Latin_1.CR
            & "str"")"));
         Print (Pr);
         Check_Stream (Test, Output);
      end;

      Param.Newline := LF;

      declare
         Output : aliased Test_Tools.Memory_Stream;
         Pr : Printer (Output'Access);
      begin
         Pr.Set_Parameters (Param);
         Output.Set_Expected (To_Atom
           ("(begin" & Latin_1.LF
            & " ""quot\" & Latin_1.LF
            & "ed\r" & Latin_1.LF
            & "\rstr"")"));
         Print (Pr);
         Check_Stream (Test, Output);
      end;

      Param.Newline := CR_LF;

      declare
         Output : aliased Test_Tools.Memory_Stream;
         Pr : Printer (Output'Access);
      begin
         Pr.Set_Parameters (Param);
         Output.Set_Expected (To_Atom
           ("(begin" & Latin_1.CR & Latin_1.LF
            & " ""quot\" & Latin_1.CR & Latin_1.LF
            & "ed" & Latin_1.CR & Latin_1.LF
            & "\rstr"")"));
         Print (Pr);
         Check_Stream (Test, Output);
      end;

      Param.Newline := LF_CR;

      declare
         Output : aliased Test_Tools.Memory_Stream;
         Pr : Printer (Output'Access);
      begin
         Pr.Set_Parameters (Param);
         Output.Set_Expected (To_Atom
           ("(begin" & Latin_1.LF & Latin_1.CR
            & " ""quot\" & Latin_1.LF & Latin_1.CR
            & "ed\r" & Latin_1.LF & Latin_1.CR
            & "str"")"));
         Print (Pr);
         Check_Stream (Test, Output);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Newline_Formats;


   procedure Quoted_String_Escapes (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Escapes in quoted string atoms");
      Source : constant Atom (0 .. 123) := To_Atom
        ("Special: "  --  indices 0 .. 17
         & Latin_1.BS & Latin_1.HT & Latin_1.LF
         & Latin_1.VT & Latin_1.FF & Latin_1.CR

Modified tests/natools-s_expressions-printers-pretty-tests.ads from [d09d9ce64c] to [0ac2dd473a].

28
29
30
31
32
33
34

35
36
37
38

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

   procedure Atom_Encodings (Report : in out NT.Reporter'Class);
   procedure Atom_Width (Report : in out NT.Reporter'Class);
   procedure Basic_Printing (Report : in out NT.Reporter'Class);
   procedure Indentation (Report : in out NT.Reporter'Class);

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

end Natools.S_Expressions.Printers.Pretty.Tests;







>




28
29
30
31
32
33
34
35
36
37
38
39

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

   procedure Atom_Encodings (Report : in out NT.Reporter'Class);
   procedure Atom_Width (Report : in out NT.Reporter'Class);
   procedure Basic_Printing (Report : in out NT.Reporter'Class);
   procedure Indentation (Report : in out NT.Reporter'Class);
   procedure Newline_Formats (Report : in out NT.Reporter'Class);
   procedure Quoted_String_Escapes (Report : in out NT.Reporter'Class);
   procedure Separators (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Printers.Pretty.Tests;