Natools

Check-in [01fc582c43]
Login
Overview
Comment:s_expressions-printers-pretty-tests: new test to check tabulation width in quoted strings
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 01fc582c43b464268c9c2eb3b819650a5838f091
User & Date: nat on 2014-07-29 21:53:02
Other Links: manifest | tags
Context
2014-07-30
20:57
s_expressions-printers-pretty-tests: also test width of tab-only indentations check-in: d42a09ad5a user: nat tags: trunk
2014-07-29
21:53
s_expressions-printers-pretty-tests: new test to check tabulation width in quoted strings check-in: 01fc582c43 user: nat tags: trunk
2014-07-28
20:18
s_expressions-printers-pretty: fix cursor position after two-byte newlines in quoted strings check-in: ce1e6e8edb user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-printers-pretty-tests.adb from [73197627eb] to [63945212c8].

73
74
75
76
77
78
79

80
81
82
83
84
85
86
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87







+







      Atom_Width (Report);
      Quoted_String_Escapes (Report);
      Indentation (Report);
      Newline_Formats (Report);
      Token_Separation (Report);
      Parameter_Mutators (Report);
      Expression_Width (Report);
      Tabulation_Width (Report);
   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------
696
697
698
699
700
701
702















































































703
704
705
706
707
708
709
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







         Test_Exp (Pr);
         Output.Check_Stream (Test);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Separators;


   procedure Tabulation_Width (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Width of tabulations");

      procedure Fill (P : in out Stream_Printer; Times : in Natural);

      X : constant Atom := To_Atom ("x");

      procedure Fill (P : in out Stream_Printer; Times : in Natural) is
      begin
         for I in 1 .. Times loop
            P.Append_Atom (X);
         end loop;
      end Fill;

      Tab : constant Character := Latin_1.HT;
      NL : constant Character := Latin_1.LF;
      Param : constant Parameters
        := (Width => 20,
            Newline_At => (others => (others => False)),
            Space_At =>
              (Atom_Data => (Opening => True, others => False),
               others => (others => False)),
            Tab_Stop => 5,
            Indentation => 3,
            Indent => Tabs_And_Spaces,
            Quoted => Single_Line,
            Token => Standard_Token,
            Hex_Casing => Encodings.Upper,
            Quoted_Escape => Hex_Escape,
            Char_Encoding => UTF_8,
            Fallback => Verbatim,
            Newline => LF);
   begin
      declare
         Output : aliased Test_Tools.Memory_Stream;
         P : Stream_Printer (Output'Access);
      begin
         Output.Set_Expected (To_Atom                  --  1234-6789-1234-6789-
            ("(first-level x x x x" & NL               --  (first-level x x x x
           & "   x (second-level x" & NL               --  ...x (second-level x
           & Tab & " x x x x x x x" & NL               --  >----.x x x x x x x
           & Tab & " x x (third x x" & NL              --  >----.x x (third x x
           & Tab & "    x (fourth x" & NL              --  >----....x (fourth x
           & Tab & Tab & "  x x (x x" & NL             --  >---->----..x x (x x
           & Tab & Tab & Tab & "x)x x" & NL            --  >---->---->----x)x x
           & Tab & Tab & "  x))x x x" & NL             --  >---->----..x))x x x
           & Tab & " x))"));                           --  >----.x))

         P.Set_Parameters (Param);

         P.Open_List;
         P.Append_Atom (To_Atom ("first-level"));
         Fill (P, 5);
         P.Open_List;
         P.Append_Atom (To_Atom ("second-level"));
         Fill (P, 10);
         P.Open_List;
         P.Append_Atom (To_Atom ("third"));
         Fill (P, 3);
         P.Open_List;
         P.Append_Atom (To_Atom ("fourth"));
         Fill (P, 3);
         P.Open_List;
         Fill (P, 3);
         P.Close_List;
         Fill (P, 3);
         P.Close_List;
         P.Close_List;
         Fill (P, 4);
         P.Close_List;
         P.Close_List;

         Output.Check_Stream (Test);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Tabulation_Width;


   procedure Token_Separation (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Token separation");
      Token : constant Atom := To_Atom ("token");
   begin
      declare
         Output : aliased Test_Tools.Memory_Stream;

Modified tests/natools-s_expressions-printers-pretty-tests.ads from [181e2b120b] to [fbd3553130].

33
34
35
36
37
38
39

40
41
42
33
34
35
36
37
38
39
40
41
42
43







+



   procedure Basic_Printing (Report : in out NT.Reporter'Class);
   procedure Expression_Width (Report : in out NT.Reporter'Class);
   procedure Indentation (Report : in out NT.Reporter'Class);
   procedure Newline_Formats (Report : in out NT.Reporter'Class);
   procedure Parameter_Mutators (Report : in out NT.Reporter'Class);
   procedure Quoted_String_Escapes (Report : in out NT.Reporter'Class);
   procedure Separators (Report : in out NT.Reporter'Class);
   procedure Tabulation_Width (Report : in out NT.Reporter'Class);
   procedure Token_Separation (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Printers.Pretty.Tests;