Package org.apache.regexp
Class RETest
- java.lang.Object
-
- org.apache.regexp.RETest
-
public class RETest extends java.lang.ObjectData driven (and optionally interactive) testing harness to exercise regular expression compiler and matching engine.- Version:
- $Id: RETest.java 518156 2007-03-14 14:31:26Z vgritsenko $
- Author:
- Jonathan Locke, Jon S. Stevens, Michael McCallum
-
-
Field Summary
Fields Modifier and Type Field Description (package private) REDebugCompilercompiler(package private) intfailures(package private) static java.lang.StringNEW_LINE(package private) static booleanshowSuccesses(package private) inttestCount
-
Constructor Summary
Constructors Constructor Description RETest()Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertEquals(java.lang.String message, int expected, int actual)voidassertEquals(java.lang.String message, java.lang.String expected, java.lang.String actual)(package private) voiddie(java.lang.String s)Exit with a fatal error.(package private) voidfail(java.lang.String s)Fail with an error.(package private) voidfail(java.lang.StringBuffer log, java.lang.String s)Fail with an error.private java.lang.StringfindNextTest(java.io.BufferedReader br)Finds next test description in a given script.private booleangetExpectedResult(java.lang.String yesno)Converts yesno string to boolean.private RETestCasegetNextTestCase(java.io.BufferedReader br)Creates testcase for the next test description in the script file.static voidmain(java.lang.String[] args)Main program entrypoint.(package private) voidrunAutomatedTests(java.lang.String testDocument)Run automated tests in RETest.txt file (from Perl 4.0 test battery)(package private) voidrunInteractiveTests(java.lang.String expr)Compile and test matching against a single expression(package private) voidsay(java.lang.String s)Say something to standard out(package private) voidshowParens(RE r)Dump parenthesized subexpressions found by a regular expression matcher objectstatic booleantest(java.lang.String[] args)Testing entrypoint.(package private) voidtestOther()Run automated unit testprivate voidtestPrecompiledRE()private voidtestSplitAndGrep()private voidtestSubst()
-
-
-
Field Detail
-
showSuccesses
static final boolean showSuccesses
- See Also:
- Constant Field Values
-
NEW_LINE
static final java.lang.String NEW_LINE
-
compiler
final REDebugCompiler compiler
-
testCount
int testCount
-
failures
int failures
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Main program entrypoint. If an argument is given, it will be compiled and interactive matching will ensue. If no argument is given, the file RETest.txt will be used as automated testing input.- Parameters:
args- Command line arguments (optional regular expression)
-
test
public static boolean test(java.lang.String[] args) throws java.lang.ExceptionTesting entrypoint.- Parameters:
args- Command line arguments- Throws:
java.lang.Exception- thrown in case of error
-
runInteractiveTests
void runInteractiveTests(java.lang.String expr)
Compile and test matching against a single expression- Parameters:
expr- Expression to compile and test
-
die
void die(java.lang.String s)
Exit with a fatal error.- Parameters:
s- Last famous words before exiting
-
fail
void fail(java.lang.StringBuffer log, java.lang.String s)Fail with an error. Will print a big failure message to System.out.- Parameters:
log- Output before failures- Failure description
-
fail
void fail(java.lang.String s)
Fail with an error. Will print a big failure message to System.out.- Parameters:
s- Failure description
-
say
void say(java.lang.String s)
Say something to standard out- Parameters:
s- What to say
-
showParens
void showParens(RE r)
Dump parenthesized subexpressions found by a regular expression matcher object- Parameters:
r- Matcher object with results to show
-
runAutomatedTests
void runAutomatedTests(java.lang.String testDocument) throws java.lang.ExceptionRun automated tests in RETest.txt file (from Perl 4.0 test battery)- Throws:
java.lang.Exception- thrown in case of error
-
testOther
void testOther() throws java.lang.ExceptionRun automated unit test- Throws:
java.lang.Exception- thrown in case of error
-
testPrecompiledRE
private void testPrecompiledRE()
-
testSplitAndGrep
private void testSplitAndGrep()
-
testSubst
private void testSubst()
-
assertEquals
public void assertEquals(java.lang.String message, java.lang.String expected, java.lang.String actual)
-
assertEquals
public void assertEquals(java.lang.String message, int expected, int actual)
-
getExpectedResult
private boolean getExpectedResult(java.lang.String yesno)
Converts yesno string to boolean.- Parameters:
yesno- string representation of expected result- Returns:
- true if yesno is "YES", false if yesno is "NO" stops program otherwise.
-
findNextTest
private java.lang.String findNextTest(java.io.BufferedReader br) throws java.io.IOExceptionFinds next test description in a given script.- Parameters:
br-BufferedReaderfor a script file- Returns:
- strign tag for next test description
- Throws:
java.io.IOException- if some io problems occured
-
getNextTestCase
private RETestCase getNextTestCase(java.io.BufferedReader br) throws java.io.IOException
Creates testcase for the next test description in the script file.- Parameters:
br-BufferedReaderfor script file.- Returns:
- a new tescase or null.
- Throws:
java.io.IOException- if some io problems occured
-
-