diff options
Diffstat (limited to 'test/ratnest-tests.adb')
-rw-r--r-- | test/ratnest-tests.adb | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb index ebe4dae..f9353f3 100644 --- a/test/ratnest-tests.adb +++ b/test/ratnest-tests.adb @@ -765,6 +765,163 @@ package body Ratnest.Tests is end Input_End_Check; + + + + function Stamp_Check + return Test_Result + is + use type String_Tokens.Token; + use type Packrat.Result_Status; + + function Match_A is new Slexy.Match ('a'); + function Match_B is new Slexy.Match ('b'); + function Match_C is new Slexy.Match ('c'); + function Seq_Abc is new Slexy.Sequence + ((Match_A'Unrestricted_Access, + Match_B'Unrestricted_Access, + Match_C'Unrestricted_Access)); + procedure My_Stamp is new Slexy.Stamp (One, Seq_Abc); + + Test_Str1 : String := "abcdefghi"; + Test_Str2 : String := "ab"; + + Context1 : Slexy.Lexer_Context := Slexy.Empty_Context; + Context2 : Slexy.Lexer_Context := Slexy.Empty_Context; + begin + My_Stamp (Test_Str1, Context1); + if (Slebug.So_Far (Context1).Length /= 1 or else + Slebug.So_Far (Context1).Element (1) /= String_Tokens.Create (One, 1, 3, "abc")) or + Slebug.Position (Context1) /= 4 or Slebug.Status (Context1) /= Packrat.Success or + Slebug.Pass (Context1) /= null + then + return Fail; + end if; + My_Stamp (Test_Str1, Context1); + if (Slebug.So_Far (Context1).Length /= 1 or else + Slebug.So_Far (Context1).Element (1) /= String_Tokens.Create (One, 1, 3, "abc")) or + Slebug.Position (Context1) /= 4 or Slebug.Status (Context1) /= Packrat.Failure or + Slebug.Pass (Context1) /= null + then + return Fail; + end if; + My_Stamp (Test_Str2, Context2); + if Slebug.So_Far (Context2).Length /= 0 or + Slebug.Position (Context2) /= 1 or + Slebug.Status (Context2) /= Packrat.Needs_More or + (Slebug.Pass (Context2) = null or else Slebug.Pass (Context2).all /= "ab") + then + return Fail; + end if; + return Pass; + end Stamp_Check; + + + function Ignore_Check + return Test_Result + is + use type Packrat.Result_Status; + + function Match_Abc is new Slexy.Multimatch ("abc"); + procedure My_Ignore is new Slexy.Ignore (Match_Abc); + + Test_Str1 : String := "abcdefghi"; + Test_Str2 : String := "ab"; + + Context1 : Slexy.Lexer_Context := Slexy.Empty_Context; + Context2 : Slexy.Lexer_Context := Slexy.Empty_Context; + begin + My_Ignore (Test_Str1, Context1); + if Slebug.So_Far (Context1).Length /= 0 or + Slebug.Position (Context1) /= 4 or Slebug.Status (Context1) /= Packrat.Success or + Slebug.Pass (Context1) /= null + then + return Fail; + end if; + My_Ignore (Test_Str1, Context1); + if Slebug.So_Far (Context1).Length /= 0 or + Slebug.Position (Context1) /= 4 or Slebug.Status (Context1) /= Packrat.Failure or + Slebug.Pass (Context1) /= null + then + return Fail; + end if; + My_Ignore (Test_Str2, Context2); + if Slebug.So_Far (Context2).Length /= 0 or + Slebug.Position (Context2) /= 1 or Slebug.Status (Context2) /= Packrat.Needs_More or + (Slebug.Pass (Context2) = null or else Slebug.Pass (Context2).all /= "ab") + then + return Fail; + end if; + return Pass; + end Ignore_Check; + + + + + + type Word_Enum is (Word); + + package Word_Tokens is new Packrat.Tokens (Word_Enum, Character, String); + package Swordy is new Packrat.Lexer (Word_Enum, Character, String, Word_Tokens); + package Swolbug is new Swordy.Debug; + + function Satisfy_Letter is new Swordy.Satisfy (PU.Is_Letter); + function Many_Letter is new Swordy.Many (Satisfy_Letter, 1); + function Satisfy_Whitespace is new Swordy.Satisfy (PU.Is_Whitespace); + function Many_Whitespace is new Swordy.Many (Satisfy_Whitespace, 1); + + procedure Stamp_Word is new Swordy.Stamp (Word, Many_Letter); + procedure Ignore_Whitespace is new Swordy.Ignore (Many_Whitespace); + + + function Scan_Check + return Test_Result + is + begin + return Fail; + end Scan_Check; + + + function Scan_Set_Check + return Test_Result + is + begin + return Fail; + end Scan_Set_Check; + + + function Scan_Only_Check + return Test_Result + is + begin + return Fail; + end Scan_Only_Check; + + + function Scan_Set_Only_Check + return Test_Result + is + begin + return Fail; + end Scan_Set_Only_Check; + + + function Scan_With_Check + return Test_Result + is + begin + return Fail; + end Scan_With_Check; + + + function Scan_Set_With_Check + return Test_Result + is + begin + return Fail; + end Scan_Set_With_Check; + + end Lexer; |