Index: tests/natools-s_expressions-parsers-tests.adb ================================================================== --- tests/natools-s_expressions-parsers-tests.adb +++ tests/natools-s_expressions-parsers-tests.adb @@ -12,10 +12,11 @@ -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ +with Natools.S_Expressions.Lockable.Tests; with Natools.S_Expressions.Printers; with Natools.S_Expressions.Test_Tools; package body Natools.S_Expressions.Parsers.Tests is @@ -121,10 +122,11 @@ Nested_Subpexression (Report); Number_Prefixes (Report); Quoted_Escapes (Report); Parser_Interface (Report); Subparser_Interface (Report); + Lockable_Interface (Report); end All_Tests; ----------------------- @@ -169,10 +171,27 @@ Expected => To_Atom ("4:head((7:sublist)5:token)4:tail")); begin Test (Report); end Base64_Subexpression; + + 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 : aliased Parsers.Parser; + Sub : Subparser (Parser'Access, Input'Access); + begin + Input.Set_Data (Lockable.Tests.Test_Expression); + Test_Tools.Next_And_Check (Test, Sub, Events.Open_List, 1); + Lockable.Tests.Test_Interface (Test, Sub); + 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" @@ -441,14 +460,14 @@ pragma Assert (Parser.Current_Event = Events.Add_Atom and then Parser.Current_Atom = To_Atom ("command")); -- Use subparser as command arguments - Test_Tools.Next_And_Check (Test, Sub, To_Atom ("arg1"), 2); - Test_Tools.Next_And_Check (Test, Sub, Events.Open_List, 3); - Test_Tools.Next_And_Check (Test, Sub, To_Atom ("subarg1"), 3); - Test_Tools.Next_And_Check (Test, Sub, To_Atom ("subarg2"), 3); + Test_Tools.Next_And_Check (Test, Sub, To_Atom ("arg1"), 0); + Test_Tools.Next_And_Check (Test, Sub, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Sub, To_Atom ("subarg1"), 1); + Test_Tools.Next_And_Check (Test, Sub, To_Atom ("subarg2"), 1); Sub.Finish; -- Check final state of parser @@ -477,16 +496,16 @@ -- Check subparser error states if Sub.Current_Event /= Events.End_Of_Input then Test.Fail ("Unexpected subparser final state: " - & Events.Event'Image (Parser.Current_Event)); + & Events.Event'Image (Sub.Current_Event)); end if; - if Sub.Current_Level /= 2 then + if Sub.Current_Level /= 0 then Test.Fail ("Unexpected subparser final level:" - & Natural'Image (Parser.Current_Level)); + & Natural'Image (Sub.Current_Level)); end if; begin declare Buffer : constant Atom := Sub.Current_Atom; @@ -495,11 +514,11 @@ ("No exception raised in Current_Atom on finished subparser"); Test_Tools.Dump_Atom (Test, Buffer); end; return; exception - when Constraint_Error => null; + when Program_Error => null; when Error : others => Test.Report_Exception (Error); Test.Info ("in Current_Atom"); end; @@ -511,11 +530,11 @@ Test.Fail ("No exception raised in Read_Atom on finished subparser"); Test_Tools.Dump_Atom (Test, Buffer (1 .. Length)); return; exception - when Constraint_Error => null; + when Program_Error => null; when Error : others => Test.Report_Exception (Error); Test.Info ("in Read_Atom"); Test_Tools.Dump_Atom (Test, Buffer (1 .. Length), "Buffer"); return; @@ -539,11 +558,11 @@ if Called then Test_Tools.Dump_Atom (Test, Output.Get_Data, "Process called with"); end if; exception - when Constraint_Error => null; + when Program_Error => null; when Error : others => Test.Report_Exception (Error); Test.Info ("in Query_Event"); if Called then Test_Tools.Dump_Atom (Test, Output.Get_Data, Index: tests/natools-s_expressions-parsers-tests.ads ================================================================== --- tests/natools-s_expressions-parsers-tests.ads +++ tests/natools-s_expressions-parsers-tests.ads @@ -29,13 +29,14 @@ 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 Nested_Subpexression (Report : in out NT.Reporter'Class); procedure Number_Prefixes (Report : in out NT.Reporter'Class); procedure Parser_Interface (Report : in out NT.Reporter'Class); procedure Quoted_Escapes (Report : in out NT.Reporter'Class); procedure Special_Subexpression (Report : in out NT.Reporter'Class); procedure Subparser_Interface (Report : in out NT.Reporter'Class); end Natools.S_Expressions.Parsers.Tests;