mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-19 04:13:07 +00:00
8269753: Misplaced caret in PatternSyntaxException's detail message
Reviewed-by: prappo
This commit is contained in:
parent
c3d8e9228d
commit
bb508e1303
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -107,7 +107,9 @@ public class PatternSyntaxException
|
||||
sb.append(pattern);
|
||||
if (index >= 0 && pattern != null && index < pattern.length()) {
|
||||
sb.append(System.lineSeparator());
|
||||
for (int i = 0; i < index; i++) sb.append(' ');
|
||||
for (int i = 0; i < index; i++) {
|
||||
sb.append((pattern.charAt(i) == '\t') ? '\t' : ' ');
|
||||
}
|
||||
sb.append('^');
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
* 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895
|
||||
* 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706
|
||||
* 8194667 8197462 8184692 8221431 8224789 8228352 8230829 8236034 8235812
|
||||
* 8216332 8214245 8237599 8241055 8247546 8258259 8037397
|
||||
* 8216332 8214245 8237599 8241055 8247546 8258259 8037397 8269753
|
||||
*
|
||||
* @library /test/lib
|
||||
* @library /lib/testlibrary/java/lang
|
||||
@ -198,6 +198,7 @@ public class RegExTest {
|
||||
caseInsensitivePMatch();
|
||||
surrogatePairOverlapRegion();
|
||||
droppedClassesWithIntersection();
|
||||
errorMessageCaretIndentation();
|
||||
|
||||
|
||||
if (failure) {
|
||||
@ -5289,5 +5290,23 @@ public class RegExTest {
|
||||
System.out.println("Compiling intersection pattern is matching digits where it should not");
|
||||
}
|
||||
|
||||
report("Dropped classes with intersection.");
|
||||
|
||||
}
|
||||
|
||||
//This test is for 8269753
|
||||
private static void errorMessageCaretIndentation() {
|
||||
String pattern = "\t**";
|
||||
|
||||
try {
|
||||
var res = Pattern.compile(pattern);
|
||||
} catch (PatternSyntaxException e) {
|
||||
var message = e.getMessage();
|
||||
var sep = System.lineSeparator();
|
||||
if (!message.contains(sep + "\t ^")){
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
report("Correct caret indentation for patterns with tabs");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user