Natools

Check-in [35261eb800]
Login
Overview
Comment:s_expressions-parsers-tests: test the new memory-backed parser
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 35261eb800e6aad0ff8bcfb62023d8f6b039ea42
User & Date: nat on 2017-04-11 21:28:00
Other Links: manifest | tags
Context
2017-04-12
20:54
cron-tests: new test to show an issue with unsafe access to Event_List

Thanks to OpenBSD for providing an environment where this issue could happen accidentally. Now to find a fix... check-in: 3267d1247d user: nat tags: trunk

2017-04-11
21:28
s_expressions-parsers-tests: test the new memory-backed parser check-in: 35261eb800 user: nat tags: trunk
2017-04-10
21:30
s_expressions-parsers: add a memory-backed parser check-in: 1b11361e94 user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-parsers-tests.adb from [d7b21f3cbc] to [14fd8e4476].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté                                        --
-- Copyright (c) 2014-2017, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
65
66
67
68
69
70
71

72
73
74
75
76
77
78
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79







+







      Special_Subexpression (Report);
      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 --
   -----------------------
162
163
164
165
166
167
168



























169
170
171
172
173
174
175
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203







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







         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 Memory_Parser (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Memory-backed parser");
   begin
      declare
         Parser : Parsers.Memory_Parser
           := Create_From_String ("(command (subcommand arg (arg list)))0:");
      begin
         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);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("arg"), 2);
         Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 3);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("arg"), 3);
         Test_Tools.Next_And_Check (Test, Parser, To_Atom ("list"), 3);
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 2);
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 1);
         Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 0);
         Test_Tools.Next_And_Check (Test, Parser, Null_Atom, 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);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Memory_Parser;


   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)"),

Modified tests/natools-s_expressions-parsers-tests.ads from [44038e8b1d] to [80d82a0df3].

1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté                                        --
-- Copyright (c) 2014-2017, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
29
30
31
32
33
34
35

36
37
38
39
40
41
42
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43







+







   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;