From 621ee53c641a441ab00f4c0ae72360959b01bca0 Mon Sep 17 00:00:00 2001 From: curious_odd_man Date: Sat, 13 Feb 2021 15:27:45 +0200 Subject: [PATCH] #63. Negative Lookahead Error More tests --- .../rgxgen/data/TestPattern.java | 70 ++++++++++++++----- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/github/curiousoddman/rgxgen/data/TestPattern.java b/src/test/java/com/github/curiousoddman/rgxgen/data/TestPattern.java index 489e8ad9..f9de1b56 100644 --- a/src/test/java/com/github/curiousoddman/rgxgen/data/TestPattern.java +++ b/src/test/java/com/github/curiousoddman/rgxgen/data/TestPattern.java @@ -6,7 +6,6 @@ import java.math.BigInteger; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.IntStream; import java.util.stream.Stream; import static com.github.curiousoddman.rgxgen.testutil.TestingUtilities.getAllDigits; @@ -214,26 +213,56 @@ public enum TestPattern implements DataInterface { setInfinite(); }}, //----------------------------------------------------------------------------------------------------------------------------------------- - POSITIVE_LOOKAHEAD("foo(?=bar)", - new Sequence("foo(?=bar)", - new FinalSymbol("foo"), new FinalSymbol("bar")) - ), + POSITIVE_LOOKAHEAD_AFTER("foo(?=bar)", + new Sequence("foo(?=bar)", + new FinalSymbol("foo"), new FinalSymbol("bar")) + ) {{ + setUseFindForMatching(); + }}, + //----------------------------------------------------------------------------------------------------------------------------------------- + // FIXME: Same as "bar.*" + POSITIVE_LOOKAHEAD_BEFORE("(?=bar).*", new FinalSymbol("NOT IMPLEMENTED")) {{ + setUseFindForMatching(); + }}, //----------------------------------------------------------------------------------------------------------------------------------------- - NEGATIVE_LOOKAHEAD("foo(?!bar)", - new Sequence("foo(?!bar)", - new FinalSymbol("foo"), new NotSymbol("bar", new FinalSymbol("bar")))) {{ + NEGATIVE_LOOKAHEAD_AFTER("foo(?!bar)", + new Sequence("foo(?!bar)", + new FinalSymbol("foo"), new NotSymbol("bar", new FinalSymbol("bar")))) {{ setInfinite(); + setUseFindForMatching(); }}, //----------------------------------------------------------------------------------------------------------------------------------------- - POSITIVE_LOOKBEHIND("(?<=foo)bar", - new Sequence("(?<=foo)bar", - new FinalSymbol("foo"), new FinalSymbol("bar")) - ), + // FIXME: Same as "A". + NEGATIVE_LOOKAHEAD_BEFORE("(?!B)[AB]", + new FinalSymbol("NOT IMPLEMENTED")) {{ + setUseFindForMatching(); + }}, + //----------------------------------------------------------------------------------------------------------------------------------------- + // FIXME: Same as "foo" + POSITIVE_LOOKBEHIND_AFTER("fo[od](?<=foo)", + new FinalSymbol("NOT IMPLEMENTED")) {{ + setUseFindForMatching(); + }}, //----------------------------------------------------------------------------------------------------------------------------------------- - NEGATIVE_LOOKBEHIND("(? aAllUniqueValues; boolean aIsUsableWithJavaPattern; + boolean aUseFindForMatching; TestPattern(String pattern, Node resultNode) { aPattern = pattern; aResultNode = resultNode; aEstimatedCount = TestingUtilities.BIG_INTEGER_MINUS_ONE; aIsUsableWithJavaPattern = true; + aUseFindForMatching = false; } public String getPattern() { @@ -437,16 +468,17 @@ public boolean hasAllUniqueValues() { } public boolean useFindForMatching() { - return this == POSITIVE_LOOKAHEAD - || this == NEGATIVE_LOOKAHEAD - || this == POSITIVE_LOOKBEHIND - || this == NEGATIVE_LOOKBEHIND; + return aUseFindForMatching; } public boolean isUsableWithJavaPattern() { return aIsUsableWithJavaPattern; } + protected final void setUseFindForMatching() { + aUseFindForMatching = true; + } + @Override public String toString() { return aPattern;