Skip to content

Commit

Permalink
#63. Negative Lookahead Error
Browse files Browse the repository at this point in the history
Fixing some tests.
  • Loading branch information
curious-odd-man committed Aug 29, 2021
1 parent db30529 commit 6d9c924
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,19 @@ public enum TestPattern implements DataInterface {
setUseFindForMatching();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
// FIXME: Special case
POSITIVE_LOOKAHEAD_HAS_SPECIFIC_SYMBOLS("(?=.*[XCV]).*",
new Sequence("foo(?=bar)",
new FinalSymbol("foo"), new FinalSymbol("bar"))
) {{
setUseFindForMatching();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
POSITIVE_LOOKAHEAD_BEFORE("(?=bar).*",
new Sequence("(?=bar).*", new FinalSymbol("bar"), Repeat.minimum(".*", new SymbolSet(), 0))) {{
setUseFindForMatching();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
POSITIVE_LOOKAHEAD_BEFORE_NOT_INFINITE("(?=bar).*car",
new Sequence("(?=bar).*car",
new FinalSymbol("bar"),
Expand All @@ -236,6 +245,7 @@ public enum TestPattern implements DataInterface {
setUseFindForMatching();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
// FIXME: Special case
NEGATIVE_LOOKAHEAD_AFTER("foo(?!bar)",
new Sequence("foo(?!bar)",
new FinalSymbol("foo"), new NotSymbol("bar", new FinalSymbol("bar")))) {{
Expand All @@ -250,6 +260,13 @@ public enum TestPattern implements DataInterface {
setValidated();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
// FIXME: Handle as special case
NEGATIVE_LOOKAHEAD_NOT_IN("(?!.*(AB|AC)).*",
new SymbolSet("[AB]", new Character[]{'A', 'B'}, SymbolSet.TYPE.POSITIVE)) {{
setUseFindForMatching();
setValidated();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
NEGATIVE_LOOKAHEAD_BEFORE_SPANS_TWO_NODES("(?!BB)[AB][AB]",
new Sequence(
"(?!BB)[AB][AB]",
Expand All @@ -271,14 +288,14 @@ public enum TestPattern implements DataInterface {
setUseFindForMatching();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
POSITIVE_LOOKBEHIND_BEFORE("(?<!not)foo",
new Sequence("(?<!not)foo",
new NotSymbol("not", new FinalSymbol("not")), new FinalSymbol("foo"))) {{
POSITIVE_LOOKBEHIND_BEFORE("(?<=not)foo",
new Sequence("(?<=not)foo",
new FinalSymbol("not"), new FinalSymbol("foo"))) {{
setInfinite();
setUseFindForMatching();
}},
//-----------------------------------------------------------------------------------------------------------------------------------------
NEGATIVE_LOOKBEHIND_AFTER(".*(?<=foo)",
POSITIVE_LOOKBEHIND_AFTER_1(".*(?<=foo)",
new Sequence(
".*(?<=foo)",
Repeat.minimum(".*", new SymbolSet(), 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@

import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.StreamSupport;

public final class TestingUtilities {
public static final BigInteger BIG_INTEGER_MINUS_ONE = BigInteger.valueOf(-1);

public static <T> List<T> iteratorToList(Iterator<T> it) {
List<T> lst = new ArrayList<>(100);

while (it.hasNext()) {
T next = it.next();
lst.add(next);
}

return lst;
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, 0), false)
.collect(Collectors.toList());
}

public static Character[] getAllDigits() {
Expand Down

0 comments on commit 6d9c924

Please sign in to comment.