Skip to content

Commit

Permalink
Fix line numbers for invariant test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
eggrobin committed Sep 21, 2024
1 parent c409cfe commit 76c4122
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static int testInvariants(String inputFile, String suffix, boolean doRang
}
final var noComments = new StringBuilder();
final List<String> lines = new ArrayList<>();
final List<Integer> lineBeginnings = new ArrayList();
final List<Integer> lineBeginnings = new ArrayList<>();
try (final BufferedReader in = getInputReader(inputFile)) {
in.lines()
.forEach(
Expand Down Expand Up @@ -233,8 +233,8 @@ public static int testInvariants(String inputFile, String suffix, boolean doRang
final Function<ParsePosition, Integer> getLineNumber =
position -> {
for (int i = 0; i < lineBeginnings.size(); ++i) {
if (lineBeginnings.get(i) > position.getIndex()) {
return i; // 1-based line number.
if (lineBeginnings.get(i) >= position.getIndex()) {
return i + 1; // 1-based line number.
}
}
return lineBeginnings.size();
Expand Down

0 comments on commit 76c4122

Please sign in to comment.