diff options
Diffstat (limited to 'test/ratnest-tests-lexer.adb')
-rw-r--r-- | test/ratnest-tests-lexer.adb | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/test/ratnest-tests-lexer.adb b/test/ratnest-tests-lexer.adb index 9728829..dbdf5d6 100644 --- a/test/ratnest-tests-lexer.adb +++ b/test/ratnest-tests-lexer.adb @@ -1,5 +1,9 @@ +with Ada.Text_IO; +use Ada.Text_IO; + + separate (Ratnest.Tests) package body Lexer is @@ -568,17 +572,17 @@ package body Lexer is begin Comp_Code := 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.So_Far (Context1).Element (1) /= String_Tokens.Create (One, 1, "abc")) or Slebug.Position (Context1) /= 4 or Slebug.Status (Context1) /= Packrat.Success or - Slebug.Pass (Context1) /= null + Slebug.Has_Pass (Context1) then return Fail; end if; Comp_Code := 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.So_Far (Context1).Element (1) /= String_Tokens.Create (One, 1, "abc")) or Slebug.Position (Context1) /= 4 or not Slebug.Is_Failure (Comp_Code) or - Slebug.Pass (Context1) /= null + Slebug.Has_Pass (Context1) then return Fail; end if; @@ -586,7 +590,7 @@ package body Lexer is 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") + (not Slebug.Has_Pass (Context2) or else Slebug.Pass (Context2) /= "ab") then return Fail; end if; @@ -613,21 +617,21 @@ package body Lexer is Comp_Code := 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 + Slebug.Has_Pass (Context1) then return Fail; end if; Comp_Code := My_Ignore (Test_Str1, Context1); if Slebug.So_Far (Context1).Length /= 0 or Slebug.Position (Context1) /= 4 or not Slebug.Is_Failure (Comp_Code) or - Slebug.Pass (Context1) /= null + Slebug.Has_Pass (Context1) then return Fail; end if; Comp_Code := 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") + (not Slebug.Has_Pass (Context2) or else Slebug.Pass (Context2) /= "ab") then return Fail; end if; @@ -666,10 +670,10 @@ package body Lexer is Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context; Intended_Result1 : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 1, 3, "one"), - 2 => Word_Tokens.Create (Word, 5, 8, "fine")); + (1 => Word_Tokens.Create (Word, 1, "one"), + 2 => Word_Tokens.Create (Word, 5, "fine")); Intended_Result2 : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 10, 12, "day")); + (1 => Word_Tokens.Create (Word, 10, "day")); Actual_Result1 : Word_Tokens.Token_Array := My_Scan (Test_Str, Test_Context); @@ -693,9 +697,9 @@ package body Lexer is Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context; Intended_Result : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 1, 3, "one"), - 2 => Word_Tokens.Create (Word, 5, 8, "fine"), - 3 => Word_Tokens.Create (Word, 10, 12, "day")); + (1 => Word_Tokens.Create (Word, 1, "one"), + 2 => Word_Tokens.Create (Word, 5, "fine"), + 3 => Word_Tokens.Create (Word, 10, "day")); Actual_Result : Word_Tokens.Token_Array := My_Scan (Test_Str, Test_Context); @@ -731,14 +735,14 @@ package body Lexer is Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context; Intended_Result : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 1, 2, "it"), - 2 => Word_Tokens.Create (Word, 4, 7, "will"), - 3 => Word_Tokens.Create (Word, 9, 14, "happen"), - 4 => Word_Tokens.Create (Word, 17, 21, "again"), - 5 => Word_Tokens.Create (Word, 23, 25, "and"), - 6 => Word_Tokens.Create (Word, 27, 31, "again"), - 7 => Word_Tokens.Create (Word, 33, 35, "and"), - 8 => Word_Tokens.Create (Word, 37, 41, "again")); + (1 => Word_Tokens.Create (Word, 1, "it"), + 2 => Word_Tokens.Create (Word, 4, "will"), + 3 => Word_Tokens.Create (Word, 9, "happen"), + 4 => Word_Tokens.Create (Word, 17, "again"), + 5 => Word_Tokens.Create (Word, 23, "and"), + 6 => Word_Tokens.Create (Word, 27, "again"), + 7 => Word_Tokens.Create (Word, 33, "and"), + 8 => Word_Tokens.Create (Word, 37, "again")); Actual_Result : Word_Tokens.Token_Array := My_Scan (More_Input'Unrestricted_Access, Test_Context); @@ -755,7 +759,7 @@ package body Lexer is is procedure My_Scan is new Swordy.Scan_Set ((Stamp_Word'Access, Ignore_Whitespace'Access), - Latin.EOT, Word_Tokens.Create (Blank, 1, 0, "")); + Latin.EOT, Word_Tokens.Create (Blank, 1, "")); Test_Str1 : String (1 .. 10) := "one tw"; Test_Str2 : String (1 .. 10) := "o three"; @@ -763,16 +767,19 @@ package body Lexer is Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context; Intended_Result1 : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 1, 3, "one"), - 2 => Word_Tokens.Create (Blank, 1, 0, "")); + (1 => Word_Tokens.Create (Word, 1, "one"), + 2 => Word_Tokens.Create (Blank, 1, ""), + 3 => Word_Tokens.Create (Blank, 1, "")); Intended_Result2 : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 9, 11, "two"), - 2 => Word_Tokens.Create (Blank, 1, 0, "")); + (1 => Word_Tokens.Create (Word, 9, "two"), + 2 => Word_Tokens.Create (Blank, 1, ""), + 3 => Word_Tokens.Create (Blank, 1, "")); Intended_Result3 : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 16, 20, "three"), - 2 => Word_Tokens.Create (Blank, 1, 0, "")); + (1 => Word_Tokens.Create (Word, 16, "three"), + 2 => Word_Tokens.Create (Blank, 1, ""), + 3 => Word_Tokens.Create (Blank, 1, "")); - Actual_Result : Word_Tokens.Token_Array (1 .. 2); + Actual_Result : Word_Tokens.Token_Array (1 .. 3); begin My_Scan (Test_Str1, Test_Context, Actual_Result); if Actual_Result /= Intended_Result1 then @@ -810,22 +817,22 @@ package body Lexer is procedure My_Scan is new Swordy.Scan_Set_With ((Stamp_Word'Access, Ignore_Whitespace'Access), - Latin.EOT, Word_Tokens.Create (Blank, 1, 0, "")); + Latin.EOT, Word_Tokens.Create (Blank, 1, "")); Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context; Intended_Result1 : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 1, 2, "it"), - 2 => Word_Tokens.Create (Word, 4, 7, "will"), - 3 => Word_Tokens.Create (Word, 9, 14, "happen"), - 4 => Word_Tokens.Create (Word, 16, 20, "again"), - 5 => Word_Tokens.Create (Word, 22, 24, "and")); + (1 => Word_Tokens.Create (Word, 1, "it"), + 2 => Word_Tokens.Create (Word, 4, "will"), + 3 => Word_Tokens.Create (Word, 9, "happen"), + 4 => Word_Tokens.Create (Word, 16, "again"), + 5 => Word_Tokens.Create (Word, 22, "and")); Intended_Result2 : Word_Tokens.Token_Array := - (1 => Word_Tokens.Create (Word, 26, 30, "again"), - 2 => Word_Tokens.Create (Word, 32, 34, "and"), - 3 => Word_Tokens.Create (Word, 36, 40, "again"), - 4 => Word_Tokens.Create (Blank, 1, 0, ""), - 5 => Word_Tokens.Create (Blank, 1, 0, "")); + (1 => Word_Tokens.Create (Word, 26, "again"), + 2 => Word_Tokens.Create (Word, 32, "and"), + 3 => Word_Tokens.Create (Word, 36, "again"), + 4 => Word_Tokens.Create (Blank, 1, ""), + 5 => Word_Tokens.Create (Blank, 1, "")); Actual_Result : Word_Tokens.Token_Array (1 .. 5); begin @@ -944,7 +951,7 @@ package body Lexer is procedure My_Scan is new Swordy.Scan_Set ((Stamp_Word'Access, Ignore_Whitespace'Access), - Latin.EOT, Word_Tokens.Create (Blank, 1, 0, "")); + Latin.EOT, Word_Tokens.Create (Blank, 1, "")); Test_Str : String := "()()"; Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context; @@ -984,7 +991,7 @@ package body Lexer is procedure My_Scan is new Swordy.Scan_Set_With ((Stamp_Word'Access, Ignore_Whitespace'Access), - Latin.EOT, Word_Tokens.Create (Blank, 1, 0, "")); + Latin.EOT, Word_Tokens.Create (Blank, 1, "")); Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context; |