Skip to content

Commit

Permalink
Correct handling of group names
Browse files Browse the repository at this point in the history
---
 Signed-off-by: Peter Kriens <[email protected]>

Signed-off-by: Peter Kriens <[email protected]>
  • Loading branch information
pkriens committed Jan 15, 2024
1 parent 63837df commit 24cee7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aQute.libg/src/aQute/libg/re/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static RE or(RE... res) {
.append(re);
del = "|";
}
yield new Group(Group.Type.NONCAPTURING, sb.toString());
yield new Group(null, sb.toString(), Group.Type.NONCAPTURING, names(res));
}
};
}
Expand Down Expand Up @@ -910,6 +910,7 @@ public static RE string(char delimeter) {
final public static C tab = new Special("\t");
final public static RE number = some(digit);
public static C hexdigit = cc("0-9A-F");
public static C bindigit = cc("0-1");
public static RE hexnumber = some(hexdigit);
final public static C minus = new CharacterClass("-");
final public static C dquote = new CharacterClass("\"");
Expand Down
12 changes: 12 additions & 0 deletions aQute.libg/test/aQute/libg/re/BasicFunctionalityUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static aQute.libg.re.Catalog.g;
import static aQute.libg.re.Catalog.lit;
import static aQute.libg.re.Catalog.maybe;
import static aQute.libg.re.Catalog.or;
import static aQute.libg.re.Catalog.someAll;
import static aQute.libg.re.Catalog.unicodeCase;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -15,6 +16,17 @@


public class BasicFunctionalityUnitTest {

@Test
public void testGroupNames() {
RE a = g("A", lit("a"));
RE b = g("B", lit("b"));
RE c = g("C", lit("c"));
RE re = g("top", or(a, b, c));

assertThat(re.getGroupNames()).contains("A", "B", "C", "top");
}

@Test
public void testSomething() {
assertThat(someAll.matches(null)).isNotPresent();
Expand Down

0 comments on commit 24cee7c

Please sign in to comment.