From 81f7e19f212f9d1ac75e04e62933e6c918219cfc Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Wed, 9 Jan 2019 22:58:10 +1100 Subject: Packrat.Tokens added, tested, and functional --- test/ratnest-tests.adb | 42 ++++++++++++++++++++++++++++++++++++++++++ test/ratnest-tests.ads | 10 ++++++++++ test/test_main.adb | 4 ++++ 3 files changed, 56 insertions(+) (limited to 'test') 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); -- cgit