diff options
author | Jed Barber <jjbarber@y7mail.com> | 2019-02-04 19:09:12 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2019-02-04 19:09:12 +1100 |
commit | 68c27cc4e247466964f4b788e70e8453354051f9 (patch) | |
tree | 520e1470ad815af00899acfd6197292144e57495 /test | |
parent | 8eb1ca2817786f48385ba5f5baa43272de8d7eec (diff) |
Reworked Graphs/Interfaces to avoid the Cursors and Nodes being tagged
Diffstat (limited to 'test')
-rw-r--r-- | test/ratnest-tests-graphs.adb | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/test/ratnest-tests-graphs.adb b/test/ratnest-tests-graphs.adb index 8776336..24b03c9 100644 --- a/test/ratnest-tests-graphs.adb +++ b/test/ratnest-tests-graphs.adb @@ -6,12 +6,12 @@ package body Graphs is type My_Labels is (One, Two, Three, Four, Five, Six); - package My_Interfaces is new Packrat.Interfaces (My_Labels, Character, String); - package My_Graphs is new Packrat.Graphs (My_Labels, Character, String, My_Interfaces); + package My_Graphs is new Packrat.Graphs (My_Labels, Character, String); - use type My_Interfaces.Cursor; - use type My_Graphs.Parse_Graph; + use type My_Graphs.Node; + use type My_Graphs.Cursor; + use type My_Graphs.Graph; function Node_Check @@ -20,9 +20,9 @@ package body Graphs is Leafeon : My_Graphs.Node := My_Graphs.Leaf ("abc", 1, 3); Brancheon : My_Graphs.Node := My_Graphs.Branch (One, 4, 3); begin - if Leafeon.Elements /= "abc" or Brancheon.Label /= One or - Leafeon.Start /= 1 or Brancheon.Start /= 4 or - Leafeon.Finish /= 3 or Brancheon.Finish /= 3 + if My_Graphs.Elements (Leafeon) /= "abc" or My_Graphs.Label (Brancheon) /= One or + My_Graphs.Start (Leafeon) /= 1 or My_Graphs.Start (Brancheon) /= 4 or + My_Graphs.Finish (Leafeon) /= 3 or My_Graphs.Finish (Brancheon) /= 3 then return Fail; end if; @@ -33,7 +33,9 @@ package body Graphs is function Empty_Check return Test_Result is begin - if not My_Graphs.Empty_Graph.Is_Empty or not My_Graphs.No_Position.Is_Nothing then + if not My_Graphs.Empty_Graph.Is_Empty or + not My_Graphs.Is_Nothing (My_Graphs.No_Position) + then return Fail; end if; return Pass; @@ -43,19 +45,19 @@ package body Graphs is function Attachment_Check return Test_Result is - Leaf1 : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); - Leaf2 : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Leaf ("def", 4, 6)); - Leaf3 : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 4, 6)); - Leaf4 : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Leaf ("def", 1, 3)); + Leaf1 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); + Leaf2 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("def", 4, 6)); + Leaf3 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 4, 6)); + Leaf4 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("def", 1, 3)); - Brancheon : My_Graphs.Parse_Graph := + Brancheon : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Branch (Three, 1, 15)); - Merge1 : My_Graphs.Parse_Graph := Leaf1; - Merge2 : My_Graphs.Parse_Graph := Leaf3; - Merge3 : My_Graphs.Parse_Graph := Brancheon; + Merge1 : My_Graphs.Graph := Leaf1; + Merge2 : My_Graphs.Graph := Leaf3; + Merge3 : My_Graphs.Graph := Brancheon; - Cursor1 : My_Interfaces.Cursor'Class := Merge3.Root (1); + Cursor1 : My_Graphs.Cursor := Merge3.Root (1); begin Merge1.Append (Leaf2); Merge2.Prepend (Leaf4); @@ -64,13 +66,19 @@ package body Graphs is if Merge1.Root_Count /= 2 or else Merge2.Root_Count /= 2 or else Merge3.Root_Count /= 1 or else - not Merge1.Root (1).Is_Leaf or else not Merge1.Root (2).Is_Leaf or else - Merge1.Root (1).Elements /= "abc" or else Merge1.Root (2).Elements /= "def" or else - not Merge2.Root (1).Is_Leaf or else not Merge2.Root (2).Is_Leaf or else - Merge2.Root (1).Elements /= "def" or else Merge2.Root (2).Elements /= "abc" or else - not Merge3.Root (1).Is_Branch or else - Cursor1.Label /= Three or else Cursor1.Child_Count /= 2 or else - Cursor1.First_Child.Elements /= "abc" or else Cursor1.Last_Child.Elements /= "def" + not My_Graphs.Is_Leaf (Merge1.Root (1)) or else + not My_Graphs.Is_Leaf (Merge1.Root (2)) or else + My_Graphs.Elements (Merge1.Root (1)) /= "abc" or else + My_Graphs.Elements (Merge1.Root (2)) /= "def" or else + not My_Graphs.Is_Leaf (Merge2.Root (1)) or else + not My_Graphs.Is_Leaf (Merge2.Root (2)) or else + My_Graphs.Elements (Merge2.Root (1)) /= "def" or else + My_Graphs.Elements (Merge2.Root (2)) /= "abc" or else + not My_Graphs.Is_Branch (Merge3.Root (1)) or else + My_Graphs.Label (Cursor1) /= Three or else + My_Graphs.Child_Count (Cursor1) /= 2 or else + My_Graphs.Elements (My_Graphs.First_Child (Cursor1)) /= "abc" or else + My_Graphs.Elements (My_Graphs.Last_Child (Cursor1)) /= "def" then return Fail; end if; @@ -81,13 +89,13 @@ package body Graphs is function Find_Check return Test_Result is - Leafeon : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); - Brancheon : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Branch (One, 1, 5)); - Combined : My_Graphs.Parse_Graph := Brancheon; + Leafeon : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); + Brancheon : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Branch (One, 1, 5)); + Combined : My_Graphs.Graph := Brancheon; begin Combined.Attach_Choice (Combined.Root (1), Leafeon); declare - Expected_Result : My_Interfaces.Cursor'Class := Combined.Root (1).First_Child; + Expected_Result : My_Graphs.Cursor := My_Graphs.First_Child (Combined.Root (1)); begin if Combined.Find ("abc") /= Expected_Result or Combined.Find ("def") /= My_Graphs.No_Position or @@ -103,22 +111,22 @@ package body Graphs is function Find_Subgraph_Check return Test_Result is - Leafeon : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); - Branch1 : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Branch (One, 1, 4)); - Branch2 : My_Graphs.Parse_Graph := My_Graphs.Singleton (My_Graphs.Branch (Two, 1, 5)); - Combined : My_Graphs.Parse_Graph := Branch2; + Leafeon : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Leaf ("abc", 1, 3)); + Branch1 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Branch (One, 1, 4)); + Branch2 : My_Graphs.Graph := My_Graphs.Singleton (My_Graphs.Branch (Two, 1, 5)); + Combined : My_Graphs.Graph := Branch2; - My_Cursor : My_Interfaces.Cursor'Class := Combined.Root (1); + My_Cursor : My_Graphs.Cursor := Combined.Root (1); begin Combined.Attach_Choice (My_Cursor, Branch1); - My_Cursor := My_Cursor.First_Child; + My_Cursor := My_Graphs.First_Child (My_Cursor); Combined.Attach_Choice (My_Cursor, Leafeon); declare - Expected_Result : My_Interfaces.Cursor'Class := My_Cursor.First_Child; + Expected_Result : My_Graphs.Cursor := My_Graphs.First_Child (My_Cursor); begin - if My_Cursor.Find_In_Subgraph ("abc") /= Expected_Result or - My_Cursor.Find_In_Subgraph ("def") /= My_Graphs.No_Position + if My_Graphs.Find_In_Subgraph (My_Cursor, "abc") /= Expected_Result or + My_Graphs.Find_In_Subgraph (My_Cursor, "def") /= My_Graphs.No_Position then return Fail; end if; |