Common Lisp Package: CL-PPCRE-TEST

README:

CL-PPCRE - Portable Perl-compatible regular expressions for Common Lisp

Abstract

CL-PPCRE is a portable regular expression library for Common Lisp which has the following features:

  • It is compatible with Perl (especially when used in conjunction with cl-interpol, to allow compatible parsing of regexp strings).
  • It is pretty fast.
  • It is portable between ANSI-compliant Common Lisp implementations.
  • It is thread-safe.
  • In addition to specifying regular expressions as strings like in Perl you can also use S-expressions.
  • It comes with a **BSD-style license** so you can basically do with it whatever you want.

CL-PPCRE has been used successfully in various applications like BioBike, clutu, LoGS, CafeSpot, Eboy, or The Regex Coach.

Further documentation can be found in doc/index.html, or on the cl-ppcre homepage.

FUNCTION

Public

RUN-ALL-TESTS (&KEY MORE-TESTS VERBOSE)

Runs all tests for CL-PPCRE and returns a true value iff all tests succeeded. VERBOSE is interpreted by the individual test suites. MORE-TESTS can be a list of function designators designating additional tests to run. This facility is used by the tests for CL-PPCRE-UNICODE.

Private

CREATE-STRING-FROM-INPUT (INPUT)

Converts INPUT to a string which can be used in TEST below. The input file `testdata' encodes strings containing non-printable characters as lists where those characters are represented by their character code.

PERL-TEST (&KEY (FILE-NAME (MAKE-PATHNAME NAME perltestdata TYPE NIL VERSION NIL DEFAULTS *THIS-FILE*) FILE-NAME-PROVIDED-P) (EXTERNAL-FORMAT '(LATIN-1 EOL-STYLE LF)) VERBOSE)

Loops through all test cases in FILE-NAME and prints a report if VERBOSE is true. EXTERNAL-FORMAT is the FLEXI-STREAMS external format which is used to read the file. Returns a true value if all tests succeeded. For the syntax of the tests in FILE-NAME refer to the source code of this function and to the Perl script perltest.pl which generates such test files.

RANDOM-TEST-FUNCTION (PROBABILITY)

Returns a random character test function which contains each character with probability PROBABILITY.

SIMPLE-TESTS (&KEY (FILE-NAME (MAKE-PATHNAME NAME simple TYPE NIL VERSION NIL DEFAULTS *THIS-FILE*)) (EXTERNAL-FORMAT '(LATIN-1 EOL-STYLE LF)) VERBOSE)

Loops through all the forms in the file FILE-NAME and executes each of them using EVAL. It is assumed that each FORM specifies a test which returns a true value iff it succeeds. Prints each test form to *STANDARD-OUTPUT* if VERBOSE is true and shows a simple progress indicator otherwise. EXTERNAL-FORMAT is the FLEXI-STREAMS external format which is used to read the file. Returns a true value iff all tests succeeded.

STRING-LIST-TO-SIMPLE-STRING (STRING-LIST)

Concatenates a list of strings to one simple-string.

TEST-OPTIMIZED-TEST-FUNCTIONS (&KEY VERBOSE)

Runs TEST-OPTIMIZED-TEST-FUNCTIONS% with different probabilities.

TEST-OPTIMIZED-TEST-FUNCTIONS% (PROBABILITY)

Creates a random test function with probability PROBABILITY and six (one for each possible "kind") corresponding optimized test functions, then checks for each character in turn that all functions agree on it.

MACRO

Private

DO-TESTS ((NAME &OPTIONAL SHOW-PROGRESS-P) &BODY BODY)

Helper macro which repeatedly executes BODY until the code in body calls the function DONE. It is assumed that each invocation of BODY will be the execution of one test which returns NIL in case of success and list of string describing errors otherwise. The macro prints a simple progress indicator (one dots for ten tests) to *STANDARD-OUTPUT* unless SHOW-PROGRESS-P is NIL and returns a true value iff all tests succeeded. Errors in BODY are caught and reported (and counted as failures).

VARIABLE

Private

*STANDARD-OPTIMIZE-SETTINGS*

The standard optimize settings used by most declaration expressions.

*TESTS-TO-SKIP*

Some tests we skip because the testdata is generated by a Perl program and CL-PPCRE differs from Perl for these tests - on purpose.

*THIS-FILE*

The location of this source file.