Natools

Check-in [24ac878eae]
Login
Overview
Comment:s_expressions-interpreter_tests: add a test for new inspection functions
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 24ac878eae51ba569bf6a674774d75c5a4dcc173
User & Date: nat on 2014-03-16 13:03:14
Other Links: manifest | tags
Context
2014-03-17
20:00
s_expression: new version of Descriptor.Next without event output check-in: 34988e159c user: nat tags: trunk
2014-03-16
13:03
s_expressions-interpreter_tests: add a test for new inspection functions check-in: 24ac878eae user: nat tags: trunk
2014-03-15
20:20
s_expressions-interpreters: add inspection functions Has_Command and Is_Empty check-in: 2ee5aec7e2 user: nat tags: trunk
Changes

Modified tests/natools-s_expressions-interpreter_tests.adb from [bb3b982bef] to [7fea09b85b].

138
139
140
141
142
143
144

145
146
147
148
149
150
151
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152







+







   procedure All_Tests (Report : in out NT.Reporter'Class) is
   begin
      Test_Basic_Usage (Report);
      Test_Unknown_Commands (Report);
      Test_Premanent_Fallback (Report);
      Test_Local_Fallback (Report);
      Test_Exception_Fallback (Report);
      Test_Inspection (Report);
   end All_Tests;



   ----------------------
   -- Individual Tests --
   ----------------------
234
235
236
237
238
239
240


































241
242
243
244
245
246
247
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
277
278
279
280
281
282







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







         Test_Tools.Next_And_Check (Test, Cursor, Events.Close_List, 0);
         Test_Tools.Next_And_Check (Test, Cursor, Events.End_Of_Input, 0);
      end;
   exception
      when Error : others => Test.Report_Exception (Error);
   end Test_Exception_Fallback;


   procedure Test_Inspection (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Inspection");
   begin
      declare
         Inter : Test_Interpreters.Interpreter;
      begin
         if not Inter.Is_Empty then
            Test.Fail ("Default interpreter is not empty");
         end if;

         if Inter.Has_Command (To_Atom ("cmd")) then
            Test.Fail ("Default interpreter has command ""cmd""");
         end if;

         Inter := Test_Interpreter;

         if Inter.Is_Empty then
            Test.Fail ("Test interpreter is empty");
         end if;

         if not Inter.Has_Command (To_Atom ("cmd")) then
            Test.Fail ("Test interpreter has not command ""cmd""");
         end if;

         if Inter.Has_Command (To_Atom ("not-a-cmd")) then
            Test.Fail ("Test interpreter has command ""not-a-cmd""");
         end if;

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


   procedure Test_Local_Fallback (Report : in out NT.Reporter'Class) is
      Test : NT.Test := Report.Item ("Local fallback");
   begin
      declare
         Inter : Test_Interpreters.Interpreter := Test_Interpreter;
         Buffer : aliased Test_Tools.Memory_Stream;

Modified tests/natools-s_expressions-interpreter_tests.ads from [7f959bf8ab] to [3986bcf3da].

30
31
32
33
34
35
36

37
38
39
40
41
42
43
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 Test_Basic_Usage (Report : in out NT.Reporter'Class);
   procedure Test_Exception_Fallback (Report : in out NT.Reporter'Class);
   procedure Test_Inspection (Report : in out NT.Reporter'Class);
   procedure Test_Local_Fallback (Report : in out NT.Reporter'Class);
   procedure Test_Premanent_Fallback (Report : in out NT.Reporter'Class);
   procedure Test_Unknown_Commands (Report : in out NT.Reporter'Class);

private

   package Test_Interpreters is new Natools.S_Expressions.Interpreters