mirror of https://github.com/apache/lucene.git
in tests, remove RegExp.toString abuse causing hudson fail, for example negated character classes are parsed as intersections but we have RegExp.INTERSECTION disabled in the test
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1027354 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b06f0b0b71
commit
8b7abe6f1c
|
@ -138,7 +138,7 @@ public class TestRegexpRandom2 extends LuceneTestCase {
|
|||
String codec = CodecProvider.getDefaultCodec();
|
||||
int num = codec.equals("PreFlex") ? 100 * RANDOM_MULTIPLIER : 1000 * RANDOM_MULTIPLIER;
|
||||
for (int i = 0; i < num; i++) {
|
||||
String reg = AutomatonTestUtil.randomRegexp(random).toString();
|
||||
String reg = AutomatonTestUtil.randomRegexp(random);
|
||||
assertSame(reg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,16 +33,15 @@ import org.apache.lucene.util._TestUtil;
|
|||
|
||||
public class AutomatonTestUtil {
|
||||
/** Returns random string, including full unicode range. */
|
||||
public static RegExp randomRegexp(Random r) {
|
||||
public static String randomRegexp(Random r) {
|
||||
while (true) {
|
||||
String regexp = randomRegexpString(r);
|
||||
// we will also generate some undefined unicode queries
|
||||
if (!UnicodeUtil.validUTF16String(regexp))
|
||||
continue;
|
||||
try {
|
||||
// NOTE: we parse-tostring-parse again, because we are
|
||||
// really abusing RegExp.toString() here (its just for debugging)
|
||||
return new RegExp(new RegExp(regexp, RegExp.NONE).toString(), RegExp.NONE);
|
||||
new RegExp(regexp, RegExp.NONE);
|
||||
return regexp;
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
@ -254,11 +253,11 @@ public class AutomatonTestUtil {
|
|||
/** return a random NFA/DFA for testing */
|
||||
public static Automaton randomAutomaton(Random random) {
|
||||
// get two random Automata from regexps
|
||||
Automaton a1 = AutomatonTestUtil.randomRegexp(random).toAutomaton();
|
||||
Automaton a1 = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton();
|
||||
if (random.nextBoolean())
|
||||
a1 = BasicOperations.complement(a1);
|
||||
|
||||
Automaton a2 = AutomatonTestUtil.randomRegexp(random).toAutomaton();
|
||||
Automaton a2 = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton();
|
||||
if (random.nextBoolean())
|
||||
a2 = BasicOperations.complement(a2);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ public class TestBasicOperations extends LuceneTestCase {
|
|||
final int ITER2 = 100 * RANDOM_MULTIPLIER;
|
||||
for(int i=0;i<ITER1;i++) {
|
||||
|
||||
final RegExp re = AutomatonTestUtil.randomRegexp(random);
|
||||
final RegExp re = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE);
|
||||
final Automaton a = re.toAutomaton();
|
||||
assertFalse(BasicOperations.isEmpty(a));
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class TestDeterminism extends LuceneTestCase {
|
|||
public void testRegexps() throws Exception {
|
||||
int num = 500 * RANDOM_MULTIPLIER;
|
||||
for (int i = 0; i < num; i++)
|
||||
assertAutomaton(AutomatonTestUtil.randomRegexp(random).toAutomaton());
|
||||
assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton());
|
||||
}
|
||||
|
||||
/** test against a simple, unoptimized det */
|
||||
|
|
|
@ -204,7 +204,7 @@ public class TestUTF32ToUTF8 extends LuceneTestCase {
|
|||
public void testRandomRegexes() throws Exception {
|
||||
int num = 250 * RANDOM_MULTIPLIER;
|
||||
for (int i = 0; i < num; i++) {
|
||||
assertAutomaton(AutomatonTestUtil.randomRegexp(random).toAutomaton());
|
||||
assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue