Index: tests/natools-s_expressions-cache_tests.adb ================================================================== --- tests/natools-s_expressions-cache_tests.adb +++ tests/natools-s_expressions-cache_tests.adb @@ -77,10 +77,11 @@ Default_Instantiation (Report); Debug_Instantiation (Report); Descriptor_Interface (Report); Lockable_Interface (Report); Replayable_Interface (Report); + Duplication (Report); end All_Tests; ----------------------- -- Inidividual Tests -- @@ -309,10 +310,69 @@ end; exception when Error : others => Test.Report_Exception (Error); end Descriptor_Interface; + + procedure Duplication (Report : in out NT.Reporter'Class) is + Test : NT.Test := Report.Item ("Duplication of general descriptor"); + begin + Full_Duplication : + declare + Input : aliased Test_Tools.Memory_Stream; + Parser : Parsers.Stream_Parser (Input'Access); + begin + Input.Set_Data (Lockable.Tests.Test_Expression); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1); + + declare + Image : Caches.Cursor := Caches.Move (Parser); + begin + Lockable.Tests.Test_Interface (Test, Image); + end; + end Full_Duplication; + + Partial_Duplication : + declare + Input : aliased Test_Tools.Memory_Stream; + Parser : Parsers.Stream_Parser (Input'Access); + Copy : Caches.Cursor; + begin + Input.Set_Data (To_Atom + ("(first_part (command-1) (command-2 arg-1 arg-2) end)" + & "(second_part (command-3 arg-3) final)")); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("first_part"), 1); + + Copy := Caches.Move (Parser); + + Test_Tools.Test_Atom_Accessors + (Test, Copy, To_Atom ("first_part"), 0); + Test_Tools.Next_And_Check (Test, Copy, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Copy, To_Atom ("command-1"), 1); + Test_Tools.Next_And_Check (Test, Copy, Events.Close_List, 0); + Test_Tools.Next_And_Check (Test, Copy, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Copy, To_Atom ("command-2"), 1); + Test_Tools.Next_And_Check (Test, Copy, To_Atom ("arg-1"), 1); + Test_Tools.Next_And_Check (Test, Copy, To_Atom ("arg-2"), 1); + Test_Tools.Next_And_Check (Test, Copy, Events.Close_List, 0); + Test_Tools.Next_And_Check (Test, Copy, To_Atom ("end"), 0); + Test_Tools.Next_And_Check (Test, Copy, Events.End_Of_Input, 0); + + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 1); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("second_part"), 1); + Test_Tools.Next_And_Check (Test, Parser, Events.Open_List, 2); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("command-3"), 2); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("arg-3"), 2); + Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 1); + Test_Tools.Next_And_Check (Test, Parser, To_Atom ("final"), 1); + Test_Tools.Next_And_Check (Test, Parser, Events.Close_List, 0); + end Partial_Duplication; + exception + when Error : others => Test.Report_Exception (Error); + end Duplication; + procedure Lockable_Interface (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Lockable.Descriptor insterface"); begin declare Index: tests/natools-s_expressions-cache_tests.ads ================================================================== --- tests/natools-s_expressions-cache_tests.ads +++ tests/natools-s_expressions-cache_tests.ads @@ -29,9 +29,10 @@ procedure All_Tests (Report : in out NT.Reporter'Class); procedure Debug_Instantiation (Report : in out NT.Reporter'Class); procedure Default_Instantiation (Report : in out NT.Reporter'Class); procedure Descriptor_Interface (Report : in out NT.Reporter'Class); + procedure Duplication (Report : in out NT.Reporter'Class); procedure Lockable_Interface (Report : in out NT.Reporter'Class); procedure Replayable_Interface (Report : in out NT.Reporter'Class); end Natools.S_Expressions.Cache_Tests;