with Ada.Text_IO, Ada.Command_Line, Ada.Characters.Latin_1, Unit_Tests, Packrat, Rat_Tests.Errors, Rat_Tests.Tokens, Rat_Tests.Lexer, Rat_Tests.Util; 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 := My_Tokens.Create (A, 1, "abc"); 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 example:"); Put (My_Tokens.Debug_String (Tok)); New_Line; Put_Line ("Running tests for Packrat.Lexer combinators..."); Run_Tests (Rat_Tests.Lexer.Combinator_Tests, How_Verbose); New_Line; Put_Line ("Running tests for Packrat.Lexer lexing..."); Run_Tests (Rat_Tests.Lexer.Lexer_Tests, How_Verbose); New_Line; Put_Line ("Running tests for Packrat.Util..."); Put_Line ("Testing set predicates..."); Run_Tests (Rat_Tests.Util.Set_Predicate_Tests, How_Verbose); Put_Line ("Testing ordinary predicates..."); Run_Tests (Rat_Tests.Util.Predicate_Tests, How_Verbose); end Test_Main;