From e07aa7be550b1ecf557e554f680380dff5eef4cd Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 3 Dec 2020 00:08:05 +1100 Subject: Revised how root nodes are handled in parse graphs --- test/rat_tests-parse_graphs.adb | 66 +++++++++++------------------------------ test/rat_tests-parse_graphs.ads | 8 ++--- 2 files changed, 19 insertions(+), 55 deletions(-) (limited to 'test') diff --git a/test/rat_tests-parse_graphs.adb b/test/rat_tests-parse_graphs.adb index 1a42ea6..5cc0edb 100644 --- a/test/rat_tests-parse_graphs.adb +++ b/test/rat_tests-parse_graphs.adb @@ -238,7 +238,7 @@ package body Rat_Tests.Parse_Graphs is then return Fail; end if; - My_Graph.Set_Root (VP_2, (1 => 4)); + My_Graph.Set_Root ((1 => (VP_2, 4))); if My_Graph.Reachable ((Noun_10, 10)) then return Fail; end if; @@ -254,7 +254,7 @@ package body Rat_Tests.Parse_Graphs is if not My_Graph.All_Reachable then return Fail; end if; - My_Graph.Set_Root (VP_2, (1 => 4)); + My_Graph.Set_Root ((1 => (VP_2, 4))); if My_Graph.All_Reachable then return Fail; end if; @@ -354,7 +354,7 @@ package body Rat_Tests.Parse_Graphs is My_Graph.Include (Sen_1); My_Graph.Include (Noun_1); My_Graph.Include (Verb_2); - My_Graph.Set_Root (Sen_1, (1 => 2)); + My_Graph.Set_Root ((1 => (Sen_1, 2))); if My_Graph.All_Reachable then return Fail; end if; @@ -372,7 +372,7 @@ package body Rat_Tests.Parse_Graphs is return Test_Result is use type My_Traits.Tokens.Token; - use type Graphs.Finish_Array; + use type Graphs.Finished_Token_Array; Paper : Graphs.Parse_Graph := Paper_Graph; begin if not Paper.Contains (Prep_5) then @@ -384,11 +384,11 @@ package body Rat_Tests.Parse_Graphs is then return Fail; end if; - if Paper.Root_Finish_List /= (4, 7, 10) then + if Paper.Root_Elements /= ((Sen_1, 4), (Sen_1, 7), (Sen_1, 10)) then return Fail; end if; Paper.Prune ((Sen_1, 7)); - if Paper.Root_Finish_List /= (4, 10) then + if Paper.Root_Elements /= ((Sen_1, 4), (Sen_1, 10)) then return Fail; end if; Paper.Prune (Paper.Subgroups ((NP_1, 1)) (1)); @@ -404,7 +404,7 @@ package body Rat_Tests.Parse_Graphs is is My_Graph : Graphs.Parse_Graph := Paper_Graph; begin - My_Graph.Set_Root (VP_2, (1 => 4)); + My_Graph.Set_Root ((1 => (VP_2, 4))); if My_Graph.All_Reachable then return Fail; end if; @@ -439,7 +439,7 @@ package body Rat_Tests.Parse_Graphs is My_Graph : Graphs.Parse_Graph := Paper_Graph; begin My_Graph.Clear_Root; - My_Graph.Set_Root (Sen_1, (4, 7, 10)); + My_Graph.Set_Root (((Sen_1, 4), (Sen_1, 7), (Sen_1, 10))); if not My_Graph.Has_Root then return Fail; end if; @@ -462,47 +462,16 @@ package body Rat_Tests.Parse_Graphs is end Clear_Root_Check; - function Root_Token_Check + function Root_Elements_Check return Test_Result is - use type My_Traits.Tokens.Token; - begin - if Paper_Graph.Root_Token /= Sen_1 or - Small_Graph.Root_Token /= VP_2 or - Slide_Graph.Root_Token /= PP_1 - then - return Fail; - end if; - return Pass; - end Root_Token_Check; - - - function Root_Finish_List_Check - return Test_Result - is - use type Graphs.Finish_Array; - begin - if Paper_Graph.Root_Finish_List /= (4, 7, 10) or - Small_Graph.Root_Finish_List /= (1 => 4) - then - return Fail; - end if; - return Pass; - end Root_Finish_List_Check; - - - function Root_Element_Check - return Test_Result - is - use type Graphs.Finished_Token; + use type Graphs.Finished_Token_Array; begin - if Paper_Graph.Root_Element (4) /= (Sen_1, 4) or - Paper_Graph.Root_Element (10) /= (Sen_1, 10) - then + if Paper_Graph.Root_Elements /= ((Sen_1, 4), (Sen_1, 7), (Sen_1, 10)) then return Fail; end if; return Pass; - end Root_Element_Check; + end Root_Elements_Check; @@ -735,8 +704,7 @@ package body Rat_Tests.Parse_Graphs is function Is_Root_Ambiguous_Check return Test_Result is begin - if Graphs.Empty_Graph.Is_Root_Ambiguous or - not Paper_Graph.Is_Root_Ambiguous or + if not Paper_Graph.Is_Root_Ambiguous or Small_Graph.Is_Root_Ambiguous or Slide_Graph.Is_Root_Ambiguous then @@ -871,7 +839,7 @@ begin ((Sen_1, 7), (PP_8, 10))); -- i saw a man in the park with a bat - Paper_Graph.Set_Root (Sen_1, (4, 7, 10)); + Paper_Graph.Set_Root (((Sen_1, 4), (Sen_1, 7), (Sen_1, 10))); @@ -882,7 +850,7 @@ begin ((Verb_2, 2), (NP_3, 4))); -- saw a man - Small_Graph.Set_Root (VP_2, (1 => 4)); + Small_Graph.Set_Root ((1 => (VP_2, 4))); @@ -893,7 +861,7 @@ begin ((Prep_1, 1), (NP_2, 3))); -- in the park - Slide_Graph.Set_Root (PP_1, (1 => 3)); + Slide_Graph.Set_Root ((1 => (PP_1, 3))); @@ -904,7 +872,7 @@ begin ((Verb_1, 1), (NP_2, 3))); -- saw a man - Slid_Small_Graph.Set_Root (VP_1, (1 => 3)); + Slid_Small_Graph.Set_Root ((1 => (VP_1, 3))); end Rat_Tests.Parse_Graphs; diff --git a/test/rat_tests-parse_graphs.ads b/test/rat_tests-parse_graphs.ads index 7323071..2ffe9bb 100644 --- a/test/rat_tests-parse_graphs.ads +++ b/test/rat_tests-parse_graphs.ads @@ -33,9 +33,7 @@ package Rat_Tests.Parse_Graphs is function Has_Root_Check return Test_Result; function Set_Root_Check return Test_Result; function Clear_Root_Check return Test_Result; - function Root_Token_Check return Test_Result; - function Root_Finish_List_Check return Test_Result; - function Root_Element_Check return Test_Result; + function Root_Elements_Check return Test_Result; function Finish_List_Check return Test_Result; function Is_Leaf_Check return Test_Result; @@ -82,9 +80,7 @@ package Rat_Tests.Parse_Graphs is (+"Has_Root", Has_Root_Check'Access), (+"Set_Root", Set_Root_Check'Access), (+"Clear_Root", Clear_Root_Check'Access), - (+"Root_Token", Root_Token_Check'Access), - (+"Root_Finish_List", Root_Finish_List_Check'Access), - (+"Root_Element", Root_Element_Check'Access), + (+"Root_Elements", Root_Elements_Check'Access), (+"Finish_List", Finish_List_Check'Access), (+"Is_Leaf", Is_Leaf_Check'Access), -- cgit