summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/packrat-lexers-debug.ads4
-rw-r--r--test/rat_tests-lexers.adb86
-rw-r--r--test/rat_tests-lexers.ads16
3 files changed, 48 insertions, 58 deletions
diff --git a/test/packrat-lexers-debug.ads b/test/packrat-lexers-debug.ads
index 5c5320a..0dace45 100644
--- a/test/packrat-lexers-debug.ads
+++ b/test/packrat-lexers-debug.ads
@@ -9,6 +9,8 @@ generic
package Packrat.Lexers.Debug is
+ Empty_Context : constant Lexer_Context;
+
Empty_Fail : constant Combinator_Result;
@@ -78,6 +80,8 @@ package Packrat.Lexers.Debug is
private
+ Empty_Context : constant Lexer_Context := Packrat.Lexers.Empty_Context;
+
Empty_Fail : constant Combinator_Result := Packrat.Lexers.Empty_Fail;
diff --git a/test/rat_tests-lexers.adb b/test/rat_tests-lexers.adb
index 0087f60..95324a9 100644
--- a/test/rat_tests-lexers.adb
+++ b/test/rat_tests-lexers.adb
@@ -571,8 +571,8 @@ package body Rat_Tests.Lexers is
Test_Str1 : String := "abcdefghi";
Test_Str2 : String := "ab";
- Context1 : Slexy.Lexer_Context := Slexy.Empty_Context;
- Context2 : Slexy.Lexer_Context := Slexy.Empty_Context;
+ Context1 : Slexy.Lexer_Context := Slebug.Empty_Context;
+ Context2 : Slexy.Lexer_Context := Slebug.Empty_Context;
Comp_Code : Slexy.Component_Result;
begin
@@ -615,8 +615,8 @@ package body Rat_Tests.Lexers is
Test_Str1 : String := "abcdefghi";
Test_Str2 : String := "ab";
- Context1 : Slexy.Lexer_Context := Slexy.Empty_Context;
- Context2 : Slexy.Lexer_Context := Slexy.Empty_Context;
+ Context1 : Slexy.Lexer_Context := Slebug.Empty_Context;
+ Context2 : Slexy.Lexer_Context := Slebug.Empty_Context;
Comp_Code : Slexy.Component_Result;
begin
@@ -666,14 +666,13 @@ package body Rat_Tests.Lexers is
function Ignore_Whitespace is new Swordy.Ignore (Whitespace, Many_Whitespace);
- function Scan_Check
+ function Scan_Parts_Check
return Test_Result
is
- function My_Scan is new Swordy.Scan
+ package My_Scanner is new Swordy.Scan_Parts
((Stamp_Word'Access, Ignore_Whitespace'Access));
Test_Str : String := "one fine day";
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
Intended_Result1 : Swordy_Traits.Tokens.Token_Array :=
(1 => Swordy_Traits.Tokens.Create (Word, 1, "one"),
@@ -682,25 +681,24 @@ package body Rat_Tests.Lexers is
(1 => Swordy_Traits.Tokens.Create (Word, 10, "day"));
Actual_Result1 : Swordy_Traits.Tokens.Token_Array :=
- My_Scan (Test_Str, Test_Context);
+ My_Scanner.Scan (Test_Str);
Actual_Result2 : Swordy_Traits.Tokens.Token_Array :=
- My_Scan ("", Test_Context);
+ My_Scanner.Scan ("");
begin
if Actual_Result1 /= Intended_Result1 or Actual_Result2 /= Intended_Result2 then
return Fail;
end if;
return Pass;
- end Scan_Check;
+ end Scan_Parts_Check;
- function Scan_Only_Check
+ function Scan_Once_Check
return Test_Result
is
- function My_Scan is new Swordy.Scan_Only
+ package My_Scanner is new Swordy.Scan_Once
((Stamp_Word'Access, Ignore_Whitespace'Access));
Test_Str : String := "one fine day";
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
Intended_Result : Swordy_Traits.Tokens.Token_Array :=
(1 => Swordy_Traits.Tokens.Create (Word, 1, "one"),
@@ -708,13 +706,13 @@ package body Rat_Tests.Lexers is
3 => Swordy_Traits.Tokens.Create (Word, 10, "day"));
Actual_Result : Swordy_Traits.Tokens.Token_Array :=
- My_Scan (Test_Str, Test_Context);
+ My_Scanner.Scan (Test_Str);
begin
if Actual_Result /= Intended_Result then
return Fail;
end if;
return Pass;
- end Scan_Only_Check;
+ end Scan_Once_Check;
function Scan_With_Check
@@ -735,11 +733,9 @@ package body Rat_Tests.Lexers is
end if;
end More_Input;
- function My_Scan is new Swordy.Scan_With
+ package My_Scanner is new Swordy.Scan_With
((Stamp_Word'Access, Ignore_Whitespace'Access));
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
-
Intended_Result : Swordy_Traits.Tokens.Token_Array :=
(1 => Swordy_Traits.Tokens.Create (Word, 1, "it"),
2 => Swordy_Traits.Tokens.Create (Word, 4, "will"),
@@ -751,7 +747,7 @@ package body Rat_Tests.Lexers is
8 => Swordy_Traits.Tokens.Create (Word, 37, "again"));
Actual_Result : Swordy_Traits.Tokens.Token_Array :=
- My_Scan (More_Input'Unrestricted_Access, Test_Context);
+ My_Scanner.Scan (More_Input'Unrestricted_Access);
begin
if Actual_Result /= Intended_Result then
return Fail;
@@ -763,14 +759,13 @@ package body Rat_Tests.Lexers is
function Scan_Set_Check
return Test_Result
is
- procedure My_Scan is new Swordy.Scan_Set
+ package My_Scanner is new Swordy.Scan_Set
((Stamp_Word'Access, Ignore_Whitespace'Access),
Latin.EOT, Swordy_Traits.Tokens.Create (Blank, 1, ""));
Test_Str1 : String (1 .. 10) := "one tw";
Test_Str2 : String (1 .. 10) := "o three";
Test_Str3 : String (1 .. 10) := Latin.EOT & " ";
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
Intended_Result1 : Swordy_Traits.Tokens.Token_Array :=
(1 => Swordy_Traits.Tokens.Create (Word, 1, "one"),
@@ -787,15 +782,15 @@ package body Rat_Tests.Lexers is
Actual_Result : Swordy_Traits.Tokens.Token_Array (1 .. 3);
begin
- My_Scan (Test_Str1, Test_Context, Actual_Result);
+ My_Scanner.Scan (Test_Str1, Actual_Result);
if Actual_Result /= Intended_Result1 then
return Fail;
end if;
- My_Scan (Test_Str2, Test_Context, Actual_Result);
+ My_Scanner.Scan (Test_Str2, Actual_Result);
if Actual_Result /= Intended_Result2 then
return Fail;
end if;
- My_Scan (Test_Str3, Test_Context, Actual_Result);
+ My_Scanner.Scan (Test_Str3, Actual_Result);
if Actual_Result /= Intended_Result3 then
return Fail;
end if;
@@ -821,12 +816,10 @@ package body Rat_Tests.Lexers is
end if;
end More_Input;
- procedure My_Scan is new Swordy.Scan_Set_With
+ package My_Scanner is new Swordy.Scan_Set_With
((Stamp_Word'Access, Ignore_Whitespace'Access),
Latin.EOT, Swordy_Traits.Tokens.Create (Blank, 1, ""));
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
-
Intended_Result1 : Swordy_Traits.Tokens.Token_Array :=
(1 => Swordy_Traits.Tokens.Create (Word, 1, "it"),
2 => Swordy_Traits.Tokens.Create (Word, 4, "will"),
@@ -842,11 +835,11 @@ package body Rat_Tests.Lexers is
Actual_Result : Swordy_Traits.Tokens.Token_Array (1 .. 5);
begin
- My_Scan (More_Input'Unrestricted_Access, Test_Context, Actual_Result);
+ My_Scanner.Scan (More_Input'Unrestricted_Access, Actual_Result);
if Actual_Result /= Intended_Result1 then
return Fail;
end if;
- My_Scan (More_Input'Unrestricted_Access, Test_Context, Actual_Result);
+ My_Scanner.Scan (More_Input'Unrestricted_Access, Actual_Result);
if Actual_Result /= Intended_Result2 then
return Fail;
end if;
@@ -854,22 +847,21 @@ package body Rat_Tests.Lexers is
end Scan_Set_With_Check;
- function Scan_Error_Check
+ function Scan_Parts_Error_Check
return Test_Result
is
use type Packrat.Errors.Error_Info_Array;
- function My_Scan is new Swordy.Scan
+ package My_Scanner is new Swordy.Scan_Parts
((Stamp_Word'Access, Ignore_Whitespace'Access));
Test_Str : String := "()()";
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
declare
- Result : Swordy_Traits.Tokens.Token_Array := My_Scan (Test_Str, Test_Context);
+ Result : Swordy_Traits.Tokens.Token_Array := My_Scanner.Scan (Test_Str);
begin
return Fail;
end;
@@ -879,25 +871,24 @@ package body Rat_Tests.Lexers is
return Fail;
end if;
return Pass;
- end Scan_Error_Check;
+ end Scan_Parts_Error_Check;
- function Scan_Only_Error_Check
+ function Scan_Once_Error_Check
return Test_Result
is
use type Packrat.Errors.Error_Info_Array;
- function My_Scan is new Swordy.Scan_Only
+ package My_Scanner is new Swordy.Scan_Once
((Stamp_Word'Access, Ignore_Whitespace'Access));
Test_Str : String := "()()";
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
declare
- Result : Swordy_Traits.Tokens.Token_Array := My_Scan (Test_Str, Test_Context);
+ Result : Swordy_Traits.Tokens.Token_Array := My_Scanner.Scan (Test_Str);
begin
return Fail;
end;
@@ -907,7 +898,7 @@ package body Rat_Tests.Lexers is
return Fail;
end if;
return Pass;
- end Scan_Only_Error_Check;
+ end Scan_Once_Error_Check;
function Scan_With_Error_Check
@@ -927,17 +918,15 @@ package body Rat_Tests.Lexers is
end if;
end Get_Input;
- function My_Scan is new Swordy.Scan_With
+ package My_Scanner is new Swordy.Scan_With
((Stamp_Word'Access, Ignore_Whitespace'Access));
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
-
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
declare
Result : Swordy_Traits.Tokens.Token_Array :=
- My_Scan (Get_Input'Unrestricted_Access, Test_Context);
+ My_Scanner.Scan (Get_Input'Unrestricted_Access);
begin
return Fail;
end;
@@ -955,19 +944,18 @@ package body Rat_Tests.Lexers is
is
use type Packrat.Errors.Error_Info_Array;
- procedure My_Scan is new Swordy.Scan_Set
+ package My_Scanner is new Swordy.Scan_Set
((Stamp_Word'Access, Ignore_Whitespace'Access),
Latin.EOT, Swordy_Traits.Tokens.Create (Blank, 1, ""));
Test_Str : String := "()()";
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
Result : Swordy_Traits.Tokens.Token_Array (1 .. 5);
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
- My_Scan (Test_Str, Test_Context, Result);
+ My_Scanner.Scan (Test_Str, Result);
return Fail;
exception
when Msg : Packrat.Lexer_Error =>
@@ -995,18 +983,16 @@ package body Rat_Tests.Lexers is
end if;
end Get_Input;
- procedure My_Scan is new Swordy.Scan_Set_With
+ package My_Scanner is new Swordy.Scan_Set_With
((Stamp_Word'Access, Ignore_Whitespace'Access),
Latin.EOT, Swordy_Traits.Tokens.Create (Blank, 1, ""));
- Test_Context : Swordy.Lexer_Context := Swordy.Empty_Context;
-
Result : Swordy_Traits.Tokens.Token_Array (1 .. 5);
Expected_Errors : Packrat.Errors.Error_Info_Array :=
((+"WORD", 1), (+"WHITESPACE", 1));
begin
- My_Scan (Get_Input'Unrestricted_Access, Test_Context, Result);
+ My_Scanner.Scan (Get_Input'Unrestricted_Access, Result);
return Fail;
exception
when Msg : Packrat.Lexer_Error =>
diff --git a/test/rat_tests-lexers.ads b/test/rat_tests-lexers.ads
index 0cf86b7..fe6cca8 100644
--- a/test/rat_tests-lexers.ads
+++ b/test/rat_tests-lexers.ads
@@ -49,14 +49,14 @@ package Rat_Tests.Lexers is
function Stamp_Check return Test_Result;
function Ignore_Check return Test_Result;
- function Scan_Check return Test_Result;
- function Scan_Only_Check return Test_Result;
+ function Scan_Parts_Check return Test_Result;
+ function Scan_Once_Check return Test_Result;
function Scan_With_Check return Test_Result;
function Scan_Set_Check return Test_Result;
function Scan_Set_With_Check return Test_Result;
- function Scan_Error_Check return Test_Result;
- function Scan_Only_Error_Check return Test_Result;
+ function Scan_Parts_Error_Check return Test_Result;
+ function Scan_Once_Error_Check return Test_Result;
function Scan_With_Error_Check return Test_Result;
function Scan_Set_Error_Check return Test_Result;
function Scan_Set_With_Error_Check return Test_Result;
@@ -64,13 +64,13 @@ package Rat_Tests.Lexers is
Lexer_Tests : Test_Array :=
((+"Stamp", Stamp_Check'Access),
(+"Ignore", Ignore_Check'Access),
- (+"Scan", Scan_Check'Access),
- (+"Scan_Only", Scan_Only_Check'Access),
+ (+"Scan_Parts", Scan_Parts_Check'Access),
+ (+"Scan_Once", Scan_Once_Check'Access),
(+"Scan_With", Scan_With_Check'Access),
(+"Scan_Set", Scan_Set_Check'Access),
(+"Scan_Set_With", Scan_Set_With_Check'Access),
- (+"Scan Exception", Scan_Error_Check'Access),
- (+"Scan_Only Exception", Scan_Only_Error_Check'Access),
+ (+"Scan_Parts Exception", Scan_Parts_Error_Check'Access),
+ (+"Scan_Once Exception", Scan_Once_Error_Check'Access),
(+"Scan_With Exception", Scan_With_Error_Check'Access),
(+"Scan_Set Exception", Scan_Set_Error_Check'Access),
(+"Scan_Set_With Exception", Scan_Set_With_Error_Check'Access));