summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2019-01-09 22:58:10 +1100
committerJed Barber <jjbarber@y7mail.com>2019-01-09 22:58:10 +1100
commit81f7e19f212f9d1ac75e04e62933e6c918219cfc (patch)
tree2f353225fc46d619e1f09c6e26ec7c3f6f6b53a3 /test
parente9862fcf976878cdec96b5f00adee010fd1c8382 (diff)
Packrat.Tokens added, tested, and functional
Diffstat (limited to 'test')
-rw-r--r--test/ratnest-tests.adb42
-rw-r--r--test/ratnest-tests.ads10
-rw-r--r--test/test_main.adb4
3 files changed, 56 insertions, 0 deletions
diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb
index df17775..1f0950d 100644
--- a/test/ratnest-tests.adb
+++ b/test/ratnest-tests.adb
@@ -162,6 +162,48 @@ package body Ratnest.Tests is
+ function Token_Adjust_Check
+ return Test_Result
+ is
+ type My_Labels is (One, Two, Three);
+ package My_Tokens is new Packrat.Tokens (My_Labels, Character, String);
+
+ A : My_Tokens.Token;
+ begin
+ declare
+ B : My_Tokens.Token := My_Tokens.Create (One, 1, 3, "abc");
+ begin
+ A := B;
+ end;
+ if not A.Initialized or else A.Value /= "abc" then
+ return Failure;
+ end if;
+ return Success;
+ end Token_Adjust_Check;
+
+
+ function Token_Store_Check
+ return Test_Result
+ is
+ type My_Labels is (One, Two, Three);
+ package My_Tokens is new Packrat.Tokens (My_Labels, Character, String);
+
+ T : My_Tokens.Token := My_Tokens.Create (One, 1, 3, "abc");
+ begin
+ if not T.Initialized or else
+ T.Label /= One or else
+ T.Start /= 1 or else T.Finish /= 3 or else
+ T.Value /= "abc"
+ then
+ return Failure;
+ end if;
+ return Success;
+ end Token_Store_Check;
+
+
+
+
+
function In_Set_Check
return Test_Result
is
diff --git a/test/ratnest-tests.ads b/test/ratnest-tests.ads
index db20313..3c83a23 100644
--- a/test/ratnest-tests.ads
+++ b/test/ratnest-tests.ads
@@ -25,6 +25,16 @@ package Ratnest.Tests is
+ function Token_Adjust_Check return Test_Result;
+ function Token_Store_Check return Test_Result;
+
+ Token_Tests : Test_Array :=
+ ((+"Token Adjust", Token_Adjust_Check'Access),
+ (+"Token Storage", Token_Store_Check'Access));
+
+
+
+
function In_Set_Check return Test_Result;
function Not_In_Set_Check return Test_Result;
diff --git a/test/test_main.adb b/test/test_main.adb
index 0ce72b1..404e690 100644
--- a/test/test_main.adb
+++ b/test/test_main.adb
@@ -18,6 +18,10 @@ begin
Run_Tests (Error_Tests);
New_Line;
+ Put_Line ("Running tests for Packrat.Tokens...");
+ Run_Tests (Token_Tests);
+ New_Line;
+
Put_Line ("Running tests for Packrat.Util...");
Put_Line ("Testing set predicates...");
Run_Tests (Set_Predicate_Tests);