summaryrefslogtreecommitdiff
path: root/test/ratnest-tests.adb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ratnest-tests.adb')
-rw-r--r--test/ratnest-tests.adb82
1 files changed, 82 insertions, 0 deletions
diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb
index 3d51081..5153b9f 100644
--- a/test/ratnest-tests.adb
+++ b/test/ratnest-tests.adb
@@ -6,6 +6,7 @@ with
Ada.Strings.Maps,
Ada.Exceptions,
Packrat.Lexer.Debug,
+ Packrat.Graphs,
Packrat.Util;
@@ -1240,6 +1241,87 @@ package body Ratnest.Tests is
+ 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);
+
+
+ use type My_Interfaces.Cursor;
+ use type My_Graphs.Parse_Graph;
+
+
+ function Node_Check
+ return Test_Result
+ 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
+ then
+ return Fail;
+ end if;
+ return Pass;
+ end Node_Check;
+
+
+ function Cursor_Check
+ return Test_Result is
+ begin
+ return Fail;
+ end Cursor_Check;
+
+
+ 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
+ return Fail;
+ end if;
+ return Pass;
+ end Empty_Check;
+
+
+ function Attachment_Check
+ return Test_Result is
+ begin
+ return Fail;
+ end Attachment_Check;
+
+
+ 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;
+ begin
+ Combined.Attach_Choice (Combined.Root (1), Leafeon);
+ declare
+ Expected_Result : My_Interfaces.Cursor'Class := Combined.Root (1).First_Child;
+ begin
+ if Combined.Find ("abc") /= Expected_Result or
+ Combined.Find ("def") /= My_Graphs.No_Position or
+ Brancheon.Find ("any") /= My_Graphs.No_Position
+ then
+ return Fail;
+ end if;
+ end;
+ return Pass;
+ end Find_Check;
+
+
+ end Graphs;
+
+
+
+
+
package body Util is