Natools

Diff
Login

Differences From Artifact [61b239fe3b]:

To Artifact [a0aaebe821]:


63
64
65
66
67
68
69


70
71
72
73
74
75
76
      Atom_Encodings (Report);
      Base64_Subexpression (Report);
      Special_Subexpression (Report);
      Nested_Subpexression (Report);
      Number_Prefixes (Report);
      Quoted_Escapes (Report);
      Lockable_Interface (Report);


   end All_Tests;



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







>
>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
      Atom_Encodings (Report);
      Base64_Subexpression (Report);
      Special_Subexpression (Report);
      Nested_Subpexression (Report);
      Number_Prefixes (Report);
      Quoted_Escapes (Report);
      Lockable_Interface (Report);
      Reset (Report);
      Locked_Next (Report);
   end All_Tests;



   -----------------------
   -- Inidividual Tests --
   -----------------------
127
128
129
130
131
132
133

































134
135
136
137
138
139
140
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Lockable.Tests.Test_Interface (Test, Parser);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Lockable_Interface;



































   procedure Nested_Subpexression (Report : in out NT.Reporter'Class) is
      procedure Test is new Blackbox_Test
        (Name => "Nested base-64 subepxressions",
         Source => To_Atom ("(5:begin"
           & "{KG5lc3RlZCB7S0dSbFpYQWdjR0Y1Ykc5aFpDaz19KQ==}"
           & "end)"),







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







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
171
172
173
174
175
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Lockable.Tests.Test_Interface (Test, Parser);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Lockable_Interface;


   procedure Locked_Next (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Next on locked parser");
   begin
      declare
         Input : aliased Test_Tools.Memory_Stream;
         Parser : Parsers.Stream_Parser (Input'Access);
         Lock_State : Lockable.Lock_State;
      begin
         Input.Set_Data (To_Atom ("(command (subcommand arg (arg list)))0:"));
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("command"), 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 2);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("subcommand"), 2);
         Parser.Lock (Lock_State);
         Test_Tools.Test_Atom_Accessors
           (Test, Parser, To_Atom ("subcommand"), 0);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("arg"), 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("arg"), 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("list"), 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.End_Of_Input, 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.End_Of_Input, 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.End_Of_Input, 0);
         Parser.Unlock (Lock_State);
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 0);
         Test_Tools.Next_And_Check (Test, Parser, Null_Atom, 0);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Locked_Next;


   procedure Nested_Subpexression (Report : in out NT.Reporter'Class) is
      procedure Test is new Blackbox_Test
        (Name => "Nested base-64 subepxressions",
         Source => To_Atom ("(5:begin"
           & "{KG5lc3RlZCB7S0dSbFpYQWdjR0Y1Ykc5aFpDaz19KQ==}"
           & "end)"),
185
186
187
188
189
190
191











































192
193
194
195
196
197
198
           & "(5:octal14:head \04\xtail)"
           & "(11:hexadecimal15:head *-\x2gtail)"
           & "(7:special2:\x1:"")"));
   begin
      Test (Report);
   end Quoted_Escapes;













































   procedure Special_Subexpression (Report : in out NT.Reporter'Class) is
      procedure Test is new Blackbox_Test
        (Name => "Special base-64 subexpression",
         Source => To_Atom ("(begin "
           & "{aGlkZGVuLWVuZCkoaGlkZGVuLWJlZ2lu}"
           & " end)"







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







220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
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
           & "(5:octal14:head \04\xtail)"
           & "(11:hexadecimal15:head *-\x2gtail)"
           & "(7:special2:\x1:"")"));
   begin
      Test (Report);
   end Quoted_Escapes;


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

         use type Atom_Buffers.Atom_Buffer;
         use type Lockable.Lock_Stack;
      begin
         Input.Write (To_Atom ("(begin(first second"));
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("begin"), 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 2);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("first"), 2);
         Test_Tools.Next_And_Check (Test, Parser, Events.End_Of_Input, 2);
         Parser.Reset (Hard => False);
         Input.Write (To_Atom ("other(new list)end"));
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("other"), 0);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("new"), 1);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("list"), 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 0);
         Parser.Reset (Hard => True);

         if Parser.Internal /= Empty.Internal
           or else Parser.Next_Event /= Empty.Next_Event
           or else Parser.Latest /= Empty.Latest
           or else Parser.Pending /= Empty.Pending
           or else Parser.Buffer /= Empty.Buffer
           or else Parser.Level /= Empty.Level
           or else Parser.Lock_Stack /= Empty.Lock_Stack
           or else Parser.Locked /= Empty.Locked
         then
            Test.Fail ("Parser after hard reset is not empty");
         end if;
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Reset;


   procedure Special_Subexpression (Report : in out NT.Reporter'Class) is
      procedure Test is new Blackbox_Test
        (Name => "Special base-64 subexpression",
         Source => To_Atom ("(begin "
           & "{aGlkZGVuLWVuZCkoaGlkZGVuLWJlZ2lu}"
           & " end)"