Clarify unneeded section.

This commit is contained in:
A Samuel Pottinger
2023-05-10 14:01:46 +00:00
parent 674cfe0766
commit 0987f67fc9
2 changed files with 10 additions and 3 deletions

View File

@@ -56,7 +56,7 @@ public class VariableNode implements MutableTreeNode {
public static final int TYPE_VOID = 11;
private static final Pattern ARRAY_REGEX = Pattern.compile(
"^(?<prefix>[^\\]]+)(?<unbounded>(\\[\\])*)(?<bounded>(\\[\\d+\\])+).*$"
"^(?<prefix>[^\\[]+)(?<unbounded>(\\[\\])*)(?<bounded>(\\[\\d+\\])+)(?<unneeded>[^\\[]*)$"
);
protected String type;

View File

@@ -74,9 +74,16 @@ public class VariableNodeTests {
@Test
public void describeArrayFailsafe() {
Value value = buildMockValue("instance of int[x][7] (id=998)");
Value value = buildMockValue("instance of int[x][7] (id=98)");
VariableNode node = new VariableNode("test", "int[][][][]", value);
Assert.assertEquals(node.getStringValue(), "instance of int[x][7] (id=998));
Assert.assertEquals(node.getStringValue(), "instance of int[x][7] (id=98)");
}
@Test
public void describeArrayUnexpectedOrder() {
Value value = buildMockValue("instance of int[7][] (id=98)");
VariableNode node = new VariableNode("test", "int[][][][]", value);
Assert.assertEquals(node.getStringValue(), "instance of int[7][] (id=98)");
}
private Value buildMockValue(String toStringValue) {