Natools

Check-in [38b822e5a1]
Login
Overview
Comment:s_expressions-parsers-tests: add a test for Close_Current_List primitive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 38b822e5a18354178838537639b8ee7ca280d62a
User & Date: nat on 2017-06-19 21:20:30
Other Links: manifest | tags
Context
2017-06-20
21:40
constant_indefinite_ordered_maps: add a Rank cursor primitive check-in: e76c115fef user: nat tags: trunk
2017-06-19
21:20
s_expressions-parsers-tests: add a test for Close_Current_List primitive check-in: 38b822e5a1 user: nat tags: trunk
2017-06-18
21:35
s_expressions-conditionals-strings-tests: test the new equality test check-in: e21eaeef3f user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-parsers-tests.adb from [15f9a74f3f] to [bbf8438364].

66
67
68
69
70
71
72

73
74
75
76
77
78
79
      Nested_Subpexression (Report);
      Number_Prefixes (Report);
      Quoted_Escapes (Report);
      Lockable_Interface (Report);
      Reset (Report);
      Locked_Next (Report);
      Memory_Parser (Report);

   end All_Tests;



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







>







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
      Nested_Subpexression (Report);
      Number_Prefixes (Report);
      Quoted_Escapes (Report);
      Lockable_Interface (Report);
      Reset (Report);
      Locked_Next (Report);
      Memory_Parser (Report);
      Close_Current_List (Report);
   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------
114
115
116
117
118
119
120










































121
122
123
124
125
126
127
        (Name => "Canonical encoding",
         Source => To_Atom (Sample_Image),
         Expected => To_Atom (Sample_Image));
   begin
      Test (Report);
   end Canonical_Encoding;












































   procedure Lockable_Interface (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Lockable.Descriptor interface");
   begin
      declare
         Input : aliased Test_Tools.Memory_Stream;
         Parser : Parsers.Stream_Parser (Input'Access);







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







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
        (Name => "Canonical encoding",
         Source => To_Atom (Sample_Image),
         Expected => To_Atom (Sample_Image));
   begin
      Test (Report);
   end Canonical_Encoding;


   procedure Close_Current_List (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Close_Current_List primitive");
   begin
      declare
         Input : aliased Test_Tools.Memory_Stream;
         Parser : Parsers.Stream_Parser (Input'Access);
      begin
         Input.Set_Data (To_Atom ("3:The(5:quick((5:brown3:fox)5:jumps))"
           & "(4:over()3:the)4:lazy(0:3:dog)3:the3:end"));
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("The"), 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("quick"), 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 2);
         Parser.Close_Current_List;
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("over"), 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 2);
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 1);
         Parser.Close_Current_List;
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("lazy"), 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom (""), 1);
         Parser.Close_Current_List;
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("the"), 0);
         Parser.Close_Current_List;

         Check_Last_Event :
         declare
            Last_Event : constant Events.Event := Parser.Current_Event;
         begin
            if Last_Event /= Events.End_Of_Input then
               Test.Fail ("Unexpected last event "
                 & Events.Event'Image (Last_Event));
            end if;
         end Check_Last_Event;
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Close_Current_List;


   procedure Lockable_Interface (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Lockable.Descriptor interface");
   begin
      declare
         Input : aliased Test_Tools.Memory_Stream;
         Parser : Parsers.Stream_Parser (Input'Access);

Modified tests/natools-s_expressions-parsers-tests.ads from [80d82a0df3] to [709abc513e].

27
28
29
30
31
32
33

34
35
36
37
38
39
40
41
42
43
   package NT renames Natools.Tests;

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

   procedure Atom_Encodings (Report : in out NT.Reporter'Class);
   procedure Base64_Subexpression (Report : in out NT.Reporter'Class);
   procedure Canonical_Encoding (Report : in out NT.Reporter'Class);

   procedure Lockable_Interface (Report : in out NT.Reporter'Class);
   procedure Locked_Next (Report : in out NT.Reporter'Class);
   procedure Memory_Parser (Report : in out NT.Reporter'Class);
   procedure Nested_Subpexression (Report : in out NT.Reporter'Class);
   procedure Number_Prefixes (Report : in out NT.Reporter'Class);
   procedure Quoted_Escapes (Report : in out NT.Reporter'Class);
   procedure Reset (Report : in out NT.Reporter'Class);
   procedure Special_Subexpression (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Parsers.Tests;







>










27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
   package NT renames Natools.Tests;

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

   procedure Atom_Encodings (Report : in out NT.Reporter'Class);
   procedure Base64_Subexpression (Report : in out NT.Reporter'Class);
   procedure Canonical_Encoding (Report : in out NT.Reporter'Class);
   procedure Close_Current_List (Report : in out NT.Reporter'Class);
   procedure Lockable_Interface (Report : in out NT.Reporter'Class);
   procedure Locked_Next (Report : in out NT.Reporter'Class);
   procedure Memory_Parser (Report : in out NT.Reporter'Class);
   procedure Nested_Subpexression (Report : in out NT.Reporter'Class);
   procedure Number_Prefixes (Report : in out NT.Reporter'Class);
   procedure Quoted_Escapes (Report : in out NT.Reporter'Class);
   procedure Reset (Report : in out NT.Reporter'Class);
   procedure Special_Subexpression (Report : in out NT.Reporter'Class);

end Natools.S_Expressions.Parsers.Tests;