Index: tests/natools-s_expressions-parsers-tests.adb ================================================================== --- tests/natools-s_expressions-parsers-tests.adb +++ tests/natools-s_expressions-parsers-tests.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- 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. -- -- -- @@ -67,10 +67,11 @@ Number_Prefixes (Report); Quoted_Escapes (Report); Lockable_Interface (Report); Reset (Report); Locked_Next (Report); + Memory_Parser (Report); end All_Tests; ----------------------- @@ -164,10 +165,37 @@ 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" Index: tests/natools-s_expressions-parsers-tests.ads ================================================================== --- tests/natools-s_expressions-parsers-tests.ads +++ tests/natools-s_expressions-parsers-tests.ads @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- 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. -- -- -- @@ -31,12 +31,13 @@ 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;