Index: tests/natools-s_expressions-parsers-tests.adb ================================================================== --- tests/natools-s_expressions-parsers-tests.adb +++ tests/natools-s_expressions-parsers-tests.adb @@ -68,10 +68,11 @@ Quoted_Escapes (Report); Lockable_Interface (Report); Reset (Report); Locked_Next (Report); Memory_Parser (Report); + Close_Current_List (Report); end All_Tests; ----------------------- @@ -116,10 +117,52 @@ Expected => To_Atom (Sample_Image)); begin Test (Report); end Canonical_Encoding; + + procedure Close_Current_List (Report : in out NT.Reporter'Class) is + Test : NT.Test := Report.Item ("Close_Current_List primitive"); + begin + declare + Input : aliased Test_Tools.Memory_Stream; + Parser : Parsers.Stream_Parser (Input'Access); + begin + Input.Set_Data (To_Atom ("3:The(5:quick((5:brown3:fox)5:jumps))" + & "(4:over()3:the)4:lazy(0:3:dog)3:the3:end")); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("The"), 0); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("quick"), 1); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 2); + Parser.Close_Current_List; + Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 0); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("over"), 1); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 2); + Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 1); + Parser.Close_Current_List; + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("lazy"), 0); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Parser, To_Atom (""), 1); + Parser.Close_Current_List; + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("the"), 0); + Parser.Close_Current_List; + + Check_Last_Event : + declare + Last_Event : constant Events.Event := Parser.Current_Event; + begin + if Last_Event /= Events.End_Of_Input then + Test.Fail ("Unexpected last event " + & Events.Event'Image (Last_Event)); + end if; + end Check_Last_Event; + end; + exception + when Error : others => Test.Report_Exception (Error); + end Close_Current_List; + procedure Lockable_Interface (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Lockable.Descriptor interface"); begin declare Index: tests/natools-s_expressions-parsers-tests.ads ================================================================== --- tests/natools-s_expressions-parsers-tests.ads +++ tests/natools-s_expressions-parsers-tests.ads @@ -29,10 +29,11 @@ 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 Close_Current_List (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);