From 731e861f233ab90078c00b3dad5ace4eaed45e95 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sun, 24 May 2020 19:07:23 +1000 Subject: Revamped tests to use the basic-unit-test project --- test/rat_tests-tokens.adb | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 test/rat_tests-tokens.adb (limited to 'test/rat_tests-tokens.adb') diff --git a/test/rat_tests-tokens.adb b/test/rat_tests-tokens.adb new file mode 100644 index 0000000..8bfb516 --- /dev/null +++ b/test/rat_tests-tokens.adb @@ -0,0 +1,71 @@ + + +with Packrat; + + +package body Rat_Tests.Tokens is + + + + type My_Labels is (One, Two, Three); + package My_Tokens is new Packrat.Tokens (My_Labels, Character, String); + + + + + + function Adjust_Check + return Test_Result + is + A : My_Tokens.Token; + begin + declare + B : My_Tokens.Token := My_Tokens.Create (One, 1, "abc"); + begin + A := B; + end; + if My_Tokens.Value (A) /= "abc" then + return Fail; + end if; + return Pass; + end Adjust_Check; + + + + + + function Equals_Check + return Test_Result + is + use type My_Tokens.Token; + A : My_Tokens.Token := My_Tokens.Create (One, 1, "abc"); + B : My_Tokens.Token := My_Tokens.Create (One, 1, "abc"); + begin + if A /= B then + return Fail; + end if; + return Pass; + end Equals_Check; + + + + + + function Store_Check + return Test_Result + is + T : My_Tokens.Token := My_Tokens.Create (One, 1, "abc"); + begin + if My_Tokens.Label (T) /= One or else + My_Tokens.Start (T) /= 1 or else + My_Tokens.Value (T) /= "abc" + then + return Fail; + end if; + return Pass; + end Store_Check; + + +end Rat_Tests.Tokens; + + -- cgit