1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
-- This source is licensed under the Sunset License v1.0
pragma Polling (On);
with
Ada.Text_IO,
Ada.Command_Line,
Ada.Characters.Latin_1,
Unit_Tests,
Packrat.Errors,
Packrat.Tokens,
Rat_Tests.Errors,
Rat_Tests.Tokens,
Rat_Tests.Lexers,
Rat_Tests.Utilities,
Rat_Tests.Parse_Graphs,
Rat_Tests.Parsers;
use
Ada.Text_IO,
Unit_Tests;
procedure Test_Main is
package Latin renames Ada.Characters.Latin_1;
Help_String : String :=
"Runs unit tests on the Packrat parser combinator library." & Latin.LF &
"Usage: rattest [switches]" & Latin.LF &
Latin.LF &
"Valid switches:" & Latin.LF &
"--help" & Latin.HT & Latin.HT & "Shows this information" & Latin.LF &
"--verbose" & Latin.HT & "Enables extra verbosity" & Latin.LF &
Latin.LF &
"All other command line input will be ignored.";
How_Verbose : Unit_Tests.Verbosity := Weak;
type My_Labels is (A, B, C);
package My_Tokens is new Packrat.Tokens (My_Labels, Character, String);
Err : Packrat.Errors.Error_Message := Packrat.Errors.Encode ("A", 1);
Tok : My_Tokens.Token_Type := My_Tokens.Create (A, 1, "abc");
Fin_Tok : My_Tokens.Finished_Token_Type := (Tok, 5);
begin
for N in 1 .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (N) = "--help" then
Put_Line (Help_String);
return;
end if;
end loop;
for N in 1 .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (N) = "--verbose" then
How_Verbose := Strong;
exit;
end if;
end loop;
Put_Line ("Running tests for Packrat.Errors...");
Run_Tests (Rat_Tests.Errors.Tests, How_Verbose);
New_Line;
Put_Line ("Displaying Error_Message debug string output example:");
Put (Packrat.Errors.Debug_String (Err));
New_Line;
Put_Line ("Running tests for Packrat.Tokens...");
Run_Tests (Rat_Tests.Tokens.Tests, How_Verbose);
New_Line;
Put_Line ("Displaying Token debug string output examples:");
Put (My_Tokens.Debug_String (Tok));
Put (My_Tokens.Debug_String (Fin_Tok));
New_Line;
Put_Line ("Running tests for Packrat.Lexers...");
Put_Line ("Testing lexer combinators...");
Run_Tests (Rat_Tests.Lexers.Combinator_Tests, How_Verbose);
Put_Line ("Testing lexer scanners...");
Run_Tests (Rat_Tests.Lexers.Lexer_Tests, How_Verbose);
New_Line;
Put_Line ("Running tests for Packrat.Utilities...");
Put_Line ("Testing set predicates...");
Run_Tests (Rat_Tests.Utilities.Set_Predicate_Tests, How_Verbose);
Put_Line ("Testing ordinary predicates...");
Run_Tests (Rat_Tests.Utilities.Predicate_Tests, How_Verbose);
New_Line;
Put_Line ("Running tests for Packrat.Parse_Graphs...");
Run_Tests (Rat_Tests.Parse_Graphs.Tests, How_Verbose);
New_Line;
Put_Line ("Displaying Parse_Graph debug string output example:");
Put (Rat_Tests.Parse_Graphs.Debug_String_Check);
New_Line;
Put_Line ("Running tests for Packrat.Parsers...");
Put_Line ("Testing parser combinators...");
Run_Tests (Rat_Tests.Parsers.Combinator_Tests, How_Verbose);
Put_Line ("Testing parser parsers...");
Run_Tests (Rat_Tests.Parsers.Parser_Tests, How_Verbose);
Put_Line ("Testing other tests...");
Run_Tests (Rat_Tests.Parsers.Other_Tests, How_Verbose, 2.0);
end Test_Main;
|