summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2019-01-18 22:00:36 +1100
committerJed Barber <jjbarber@y7mail.com>2019-01-18 22:00:36 +1100
commit26cb20d3cf5d6148f2e2baa603a0c61a87642f3a (patch)
tree7e426bde31bb63aef6136351e7cd4a3f3dfc1c3e /test
parent4e42761354c2de557c0166d46aabe9dcd9b77073 (diff)
Packrat.Lexer Stamp, Ignore, Scan, Scan_Only functions/procedures completed
Diffstat (limited to 'test')
-rw-r--r--test/packrat-lexer-debug.adb80
-rw-r--r--test/packrat-lexer-debug.ads16
-rw-r--r--test/ratnest-tests.adb219
3 files changed, 158 insertions, 157 deletions
diff --git a/test/packrat-lexer-debug.adb b/test/packrat-lexer-debug.adb
index 335e3d2..d4cc2e2 100644
--- a/test/packrat-lexer-debug.adb
+++ b/test/packrat-lexer-debug.adb
@@ -4,57 +4,22 @@ package body Packrat.Lexer.Debug is
function Create_Result
- (Length : in Natural;
- Status : in Result_Status;
- Value : in Element_Array)
- return Combinator_Result
- is
- This : Combinator_Result;
+ (Finish : in Natural;
+ Status : in Result_Status)
+ return Combinator_Result is
begin
- This.Length := Length;
- This.Status := Status;
- This.Value := new Element_Array (1 .. Value'Length);
- This.Value.all := Value;
- return This;
+ return (Finish, Status);
end Create_Result;
function Join
(Left, Right : in Combinator_Result)
- return Combinator_Result
- is
- Merge : Combinator_Result;
- Left_Valsize, Right_Valsize, Total_Valsize : Natural;
+ return Combinator_Result is
begin
- if Left.Value /= null then
- Left_Valsize := Left.Value.all'Length;
- else
- Left_Valsize := 0;
- end if;
- if Right.Value /= null then
- Right_Valsize := Right.Value.all'Length;
- else
- Right_Valsize := 0;
- end if;
- Total_Valsize := Left_Valsize + Right_Valsize;
-
if Left.Status = Success or Left.Status = Optional_More then
- Merge.Length := Left.Length + Right.Length;
- Merge.Status := Right.Status;
- if Total_Valsize > 0 then
- Merge.Value := new Element_Array (1 .. Total_Valsize);
- if Left.Value /= null then
- Merge.Value.all (1 .. Left_Valsize) := Left.Value.all;
- end if;
- if Right.Value /= null then
- Merge.Value.all (Left_Valsize + 1 .. Total_Valsize) := Right.Value.all;
- end if;
- end if;
- return Merge;
+ return Right;
elsif Left.Status = Needs_More then
- Merge := Left;
- Merge.Status := Failure;
- return Merge;
+ return (Left.Finish, Failure);
else
return Left;
end if;
@@ -71,18 +36,10 @@ package body Packrat.Lexer.Debug is
function Debug_String
(This : in Combinator_Result)
- return String
- is
- Value_Length : Natural;
+ return String is
begin
- if This.Value = null then
- Value_Length := 0;
- else
- Value_Length := This.Value.all'Length;
- end if;
- return Integer'Image (This.Length)
- & " " & Result_Status'Image (This.Status)
- & " " & Integer'Image (Value_Length);
+ return Integer'Image (This.Finish)
+ & " " & Result_Status'Image (This.Status);
end Debug_String;
@@ -133,6 +90,23 @@ package body Packrat.Lexer.Debug is
end Element;
+
+
+ function Is_Failure
+ (Result : in Component_Result)
+ return Boolean is
+ begin
+ return Result = Component_Failure;
+ end Is_Failure;
+
+ function Is_Success
+ (Result : in Component_Result)
+ return Boolean is
+ begin
+ return Result = Component_Success;
+ end Is_Success;
+
+
end Packrat.Lexer.Debug;
diff --git a/test/packrat-lexer-debug.ads b/test/packrat-lexer-debug.ads
index 77614aa..a1cb768 100644
--- a/test/packrat-lexer-debug.ads
+++ b/test/packrat-lexer-debug.ads
@@ -13,9 +13,8 @@ package Packrat.Lexer.Debug is
function Create_Result
- (Length : in Natural;
- Status : in Result_Status;
- Value : in Element_Array)
+ (Finish : in Natural;
+ Status : in Result_Status)
return Combinator_Result;
function Join
@@ -61,6 +60,17 @@ package Packrat.Lexer.Debug is
return Gen_Tokens.Token;
+
+
+ function Is_Failure
+ (Result : in Component_Result)
+ return Boolean;
+
+ function Is_Success
+ (Result : in Component_Result)
+ return Boolean;
+
+
private
diff --git a/test/ratnest-tests.adb b/test/ratnest-tests.adb
index 9a493da..d5c150e 100644
--- a/test/ratnest-tests.adb
+++ b/test/ratnest-tests.adb
@@ -6,7 +6,7 @@ with
Ada.Strings.Maps,
Ada.Exceptions,
Packrat.Lexer.Debug,
- Packrat.Util;
+ Packrat.Util, Ada.Text_IO;
package body Ratnest.Tests is
@@ -251,36 +251,38 @@ package body Ratnest.Tests is
function Join_Check
return Test_Result
is
- One : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "a");
- Two : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Success, "bc");
- Three : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "abc");
-
- Four : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Failure, "xyz");
- Five : Slexy.Combinator_Result :=
- Slebug.Create_Result (4, Packrat.Failure, "axyz");
-
- Six : Slexy.Combinator_Result :=
- Slebug.Create_Result (4, Packrat.Needs_More, "cd");
- Seven : Slexy.Combinator_Result :=
- Slebug.Create_Result (5, Packrat.Needs_More, "acd");
-
- Eight : Slexy.Combinator_Result :=
- Slebug.Create_Result (4, Packrat.Failure, "cd");
-
- Nine : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Optional_More, "abc");
- Ten : Slexy.Combinator_Result :=
- Slebug.Create_Result (5, Packrat.Success, "abcbc");
+ One : Slexy.Combinator_Result :=
+ Slebug.Create_Result (1, Packrat.Success);
+ Two : Slexy.Combinator_Result :=
+ Slebug.Create_Result (3, Packrat.Success);
+ Three : Slexy.Combinator_Result :=
+ Slebug.Create_Result (3, Packrat.Success);
+
+ Four : Slexy.Combinator_Result :=
+ Slebug.Create_Result (4, Packrat.Failure);
+ Five : Slexy.Combinator_Result :=
+ Slebug.Create_Result (4, Packrat.Failure);
+
+ Six : Slexy.Combinator_Result :=
+ Slebug.Create_Result (3, Packrat.Needs_More);
+ Seven : Slexy.Combinator_Result :=
+ Slebug.Create_Result (3, Packrat.Needs_More);
+
+ Eight : Slexy.Combinator_Result :=
+ Slebug.Create_Result (3, Packrat.Failure);
+
+ Nine : Slexy.Combinator_Result :=
+ Slebug.Create_Result (3, Packrat.Optional_More);
+ Ten : Slexy.Combinator_Result :=
+ Slebug.Create_Result (5, Packrat.Success);
+ Eleven : Slexy.Combinator_Result :=
+ Slebug.Create_Result (5, Packrat.Success);
begin
if Slebug.Join (One, Two) /= Three or Slebug.Join (One, Four) /= Five or
Slebug.Join (One, Six) /= Seven or Slebug.Join (Four, Six) /= Four or
Slebug.Join (Five, Two) /= Five or Slebug.Join (Six, Three) /= Eight or
Slebug.Join (Slebug.Empty_Fail, One) /= Slebug.Empty_Fail or
- Slebug.Join (Nine, Two) /= Ten
+ Slebug.Join (Nine, Ten) /= Eleven
then
return Fail;
end if;
@@ -292,9 +294,9 @@ package body Ratnest.Tests is
return Test_Result
is
One : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "abc");
+ Slebug.Create_Result (3, Packrat.Success);
Two : Slexy.Combinator_Result :=
- Slebug.Create_Result (0, Packrat.Failure, "");
+ Slebug.Create_Result (0, Packrat.Failure);
begin
if One = Two or Two /= Slebug.Empty_Fail then
return Fail;
@@ -320,14 +322,14 @@ package body Ratnest.Tests is
Test_Str : String := "aababcabcab";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Failure, "a");
+ Slebug.Create_Result (1, Packrat.Failure);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Needs_More, "ab");
+ Slebug.Create_Result (11, Packrat.Needs_More);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "abc");
+ Slebug.Create_Result (6, Packrat.Success);
Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
Result5 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Failure, "ab");
+ Slebug.Create_Result (3, Packrat.Failure);
begin
if Seq_Abc (Test_Str, 1) /= Result1 or Seq_Abc (Test_Str, 2) /= Result5 or
Seq_Abc (Test_Str, 4) /= Result3 or Seq_Abc (Test_Str, 10) /= Result2 or
@@ -351,15 +353,15 @@ package body Ratnest.Tests is
Test_Str : String := "abaabbaaabbbaaaabbbb";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Failure, "a");
+ Slebug.Create_Result (1, Packrat.Failure);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Success, "aa");
+ Slebug.Create_Result (4, Packrat.Success);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Failure, "b");
+ Slebug.Create_Result (2, Packrat.Failure);
Result4 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Needs_More, "bb");
+ Slebug.Create_Result (20, Packrat.Needs_More);
Result5 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "bbb");
+ Slebug.Create_Result (12, Packrat.Success);
Result6 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Count_2A (Test_Str, 1) /= Result1 or Count_2A (Test_Str, 3) /= Result2 or
@@ -394,22 +396,22 @@ package body Ratnest.Tests is
Test_Str2 : String := "aababcabcab";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "aaa");
+ Slebug.Create_Result (3, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Optional_More, "aa");
+ Slebug.Create_Result (13, Packrat.Optional_More);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (5, Packrat.Success, "aaaaa");
+ Slebug.Create_Result (10, Packrat.Success);
Result4 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Failure, "aaa");
+ Slebug.Create_Result (3, Packrat.Failure);
Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
Result6 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Needs_More, "aa");
+ Slebug.Create_Result (13, Packrat.Needs_More);
Result7 : Slexy.Combinator_Result :=
- Slebug.Create_Result (0, Packrat.Success, "");
+ Slebug.Create_Result (0, Packrat.Success);
Result8 : Slexy.Combinator_Result :=
- Slebug.Create_Result (6, Packrat.Optional_More, "abcabc");
+ Slebug.Create_Result (9, Packrat.Optional_More);
Result9 : Slexy.Combinator_Result :=
- Slebug.Create_Result (6, Packrat.Needs_More, "abcabc");
+ Slebug.Create_Result (9, Packrat.Needs_More);
begin
if Many_0 (Test_Str, 1) /= Result1 or Many_4 (Test_Str, 1) /= Result4 or
Many_4 (Test_Str, 6) /= Result3 or Many_0 (Test_Str, 4) /= Result7 or
@@ -433,11 +435,11 @@ package body Ratnest.Tests is
Test_Str : String := "aaaabbaaa123aaa";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (4, Packrat.Failure, "aaaa");
+ Slebug.Create_Result (4, Packrat.Failure);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "aaa");
+ Slebug.Create_Result (9, Packrat.Success);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Needs_More, "aaa");
+ Slebug.Create_Result (15, Packrat.Needs_More);
Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Many_Until_0 (Test_Str, 1) /= Result1 or
@@ -476,9 +478,9 @@ package body Ratnest.Tests is
Test_Str : String := "abc123456def";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "b");
+ Slebug.Create_Result (2, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "3");
+ Slebug.Create_Result (6, Packrat.Success);
Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Satisfy_123 (Test_Str, 6) /= Result2 or
@@ -520,9 +522,9 @@ package body Ratnest.Tests is
Test_Str : String := "abcde12345";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "c");
+ Slebug.Create_Result (3, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "2");
+ Slebug.Create_Result (7, Packrat.Success);
Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Satisfy_Bcd (Test_Str, 3) /= Result1 or
@@ -546,11 +548,11 @@ package body Ratnest.Tests is
Test_Str : String := "abc1234./5";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "a");
+ Slebug.Create_Result (1, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "/");
+ Slebug.Create_Result (9, Packrat.Success);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "4");
+ Slebug.Create_Result (7, Packrat.Success);
Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Match_A (Test_Str, 1) /= Result1 or
@@ -581,9 +583,9 @@ package body Ratnest.Tests is
Test_Str : String := "abc5678";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "a");
+ Slebug.Create_Result (1, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "6");
+ Slebug.Create_Result (5, Packrat.Success);
Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Match_A (Test_Str, 1) /= Result1 or
@@ -606,13 +608,13 @@ package body Ratnest.Tests is
Test_Str : String := "abcdefabhelloworldab";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "abc");
+ Slebug.Create_Result (3, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Needs_More, "ab");
+ Slebug.Create_Result (20, Packrat.Needs_More);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (5, Packrat.Success, "hello");
+ Slebug.Create_Result (13, Packrat.Success);
Result4 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Failure, "ab");
+ Slebug.Create_Result (8, Packrat.Failure);
Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Match_String1 (Test_Str, 1) /= Result1 or
@@ -637,11 +639,11 @@ package body Ratnest.Tests is
Test_Str : String := "abcdefghi";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "b");
+ Slebug.Create_Result (2, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Needs_More, "ghi");
+ Slebug.Create_Result (9, Packrat.Needs_More);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (5, Packrat.Success, "cdefg");
+ Slebug.Create_Result (7, Packrat.Success);
Result4 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Take_1 (Test_Str, 2) /= Result1 or Take_5 (Test_Str, 7) /= Result2 or
@@ -664,16 +666,16 @@ package body Ratnest.Tests is
Test_Str : String := "abcde,./;'fghi[]=-^563";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (4, Packrat.Success, "bcde");
+ Slebug.Create_Result (5, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (2, Packrat.Success, "hi");
+ Slebug.Create_Result (14, Packrat.Success);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (5, Packrat.Success, ",./;'");
+ Slebug.Create_Result (10, Packrat.Success);
Result4 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Success, "=-^");
+ Slebug.Create_Result (19, Packrat.Success);
Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
Result6 : Slexy.Combinator_Result :=
- Slebug.Create_Result (3, Packrat.Optional_More, "563");
+ Slebug.Create_Result (22, Packrat.Optional_More);
begin
if Take_Letters (Test_Str, 2) /= Result1 or
Take_Letters (Test_Str, 13) /= Result2 or
@@ -698,13 +700,13 @@ package body Ratnest.Tests is
Test_Str : String := "abcde12345;;;fghi67";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (7, Packrat.Success, "de12345");
+ Slebug.Create_Result (10, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (4, Packrat.Optional_More, "hi67");
+ Slebug.Create_Result (19, Packrat.Optional_More);
Result3 : Slexy.Combinator_Result :=
- Slebug.Create_Result (5, Packrat.Success, "abcde");
+ Slebug.Create_Result (5, Packrat.Success);
Result4 : Slexy.Combinator_Result :=
- Slebug.Create_Result (6, Packrat.Success, ";;fghi");
+ Slebug.Create_Result (17, Packrat.Success);
Result5 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if Take_Till_Punch (Test_Str, 4) /= Result1 or
@@ -729,9 +731,9 @@ package body Ratnest.Tests is
Test_Str : String := "abcd" & Latin.LF & "e";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, (1 => Latin.LF));
+ Slebug.Create_Result (5, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "c");
+ Slebug.Create_Result (3, Packrat.Success);
Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if LF_End (Test_Str, 5) /= Result1 or C_End (Test_Str, 3) /= Result2 or
@@ -752,9 +754,9 @@ package body Ratnest.Tests is
Test_Str : String := "abcde";
Result1 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "e");
+ Slebug.Create_Result (5, Packrat.Success);
Result2 : Slexy.Combinator_Result :=
- Slebug.Create_Result (1, Packrat.Success, "c");
+ Slebug.Create_Result (3, Packrat.Success);
Result3 : Slexy.Combinator_Result := Slebug.Empty_Fail;
begin
if C_End (Test_Str, 3) /= Result2 or E_End (Test_Str, 5) /= Result1 or
@@ -775,6 +777,7 @@ package body Ratnest.Tests is
is
use type String_Tokens.Token;
use type Packrat.Result_Status;
+ use type Slexy.Component_Result;
function Match_A is new Slexy.Match ('a');
function Match_B is new Slexy.Match ('b');
@@ -783,15 +786,17 @@ package body Ratnest.Tests is
((Match_A'Unrestricted_Access,
Match_B'Unrestricted_Access,
Match_C'Unrestricted_Access));
- procedure My_Stamp is new Slexy.Stamp (One, Seq_Abc);
+ function 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;
+
+ Comp_Code : Slexy.Component_Result;
begin
- My_Stamp (Test_Str1, Context1);
+ 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.Position (Context1) /= 4 or Slebug.Status (Context1) /= Packrat.Success or
@@ -799,15 +804,15 @@ package body Ratnest.Tests is
then
return Fail;
end if;
- My_Stamp (Test_Str1, Context1);
+ 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.Position (Context1) /= 4 or Slebug.Status (Context1) /= Packrat.Failure or
+ Slebug.Position (Context1) /= 4 or not Slebug.Is_Failure (Comp_Code) or
Slebug.Pass (Context1) /= null
then
return Fail;
end if;
- My_Stamp (Test_Str2, Context2);
+ Comp_Code := 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
@@ -825,29 +830,31 @@ package body Ratnest.Tests is
use type Packrat.Result_Status;
function Match_Abc is new Slexy.Multimatch ("abc");
- procedure My_Ignore is new Slexy.Ignore (Two, Match_Abc);
+ function My_Ignore is new Slexy.Ignore (Two, Match_Abc);
Test_Str1 : String := "abcdefghi";
Test_Str2 : String := "ab";
Context1 : Slexy.Lexer_Context := Slexy.Empty_Context;
Context2 : Slexy.Lexer_Context := Slexy.Empty_Context;
+
+ Comp_Code : Slexy.Component_Result;
begin
- My_Ignore (Test_Str1, Context1);
+ 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
then
return Fail;
end if;
- My_Ignore (Test_Str1, Context1);
+ Comp_Code := 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.Position (Context1) /= 4 or not Slebug.Is_Failure (Comp_Code) or
Slebug.Pass (Context1) /= null
then
return Fail;
end if;
- My_Ignore (Test_Str2, Context2);
+ 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")
@@ -875,8 +882,8 @@ package body Ratnest.Tests is
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 (Whitespace, Many_Whitespace);
+ function Stamp_Word is new Swordy.Stamp (Word, Many_Letter);
+ function Ignore_Whitespace is new Swordy.Ignore (Whitespace, Many_Whitespace);
function Scan_Check
@@ -900,6 +907,12 @@ package body Ratnest.Tests is
My_Scan ("", Test_Context);
begin
if Actual_Result1 /= Intended_Result1 or Actual_Result2 /= Intended_Result2 then
+ for T of Actual_Result1 loop
+ Ada.Text_IO.Put_Line (T.Debug_String);
+ end loop;
+ for T of Actual_Result2 loop
+ Ada.Text_IO.Put_Line (T.Debug_String);
+ end loop;
return Fail;
end if;
return Pass;
@@ -1075,13 +1088,14 @@ package body Ratnest.Tests is
Test_Str : String := "()()";
Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
- Result : Word_Tokens.Token_Array :=
- My_Scan (Test_Str, Test_Context);
-
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
- return Fail;
+ declare
+ Result : Word_Tokens.Token_Array := My_Scan (Test_Str, Test_Context);
+ begin
+ return Fail;
+ end;
exception
when Msg : Packrat.Lexer_Error =>
if Packrat.Errors.Decode (Except.Exception_Message (Msg)) /= Expected_Errors then
@@ -1102,13 +1116,14 @@ package body Ratnest.Tests is
Test_Str : String := "()()";
Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
- Result : Word_Tokens.Token_Array :=
- My_Scan (Test_Str, Test_Context);
-
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
- return Fail;
+ declare
+ Result : Word_Tokens.Token_Array := My_Scan (Test_Str, Test_Context);
+ begin
+ return Fail;
+ end;
exception
when Msg : Packrat.Lexer_Error =>
if Packrat.Errors.Decode (Except.Exception_Message (Msg)) /= Expected_Errors then
@@ -1140,13 +1155,15 @@ package body Ratnest.Tests is
Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
- Result : Word_Tokens.Token_Array :=
- My_Scan (Get_Input'Unrestricted_Access, Test_Context);
-
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
- return Fail;
+ declare
+ Result : Word_Tokens.Token_Array :=
+ My_Scan (Get_Input'Unrestricted_Access, Test_Context);
+ begin
+ return Fail;
+ end;
exception
when Msg : Packrat.Lexer_Error =>
if Packrat.Errors.Decode (Except.Exception_Message (Msg)) /= Expected_Errors then