|
|
@@ -267,12 +267,29 @@ public class RegexTests extends ScriptTestCase {
|
|
|
ScriptException e = expectThrows(ScriptException.class, () -> {
|
|
|
exec("/\\ujjjj/"); // Invalid unicode
|
|
|
});
|
|
|
- assertEquals("invalid regular expression: could not compile regex constant [\\ujjjj] with flags []", e.getCause().getMessage());
|
|
|
+ assertEquals(
|
|
|
+ "invalid regular expression: could not compile regex constant [\\ujjjj] with flags []: Illegal Unicode escape sequence",
|
|
|
+ e.getCause().getMessage()
|
|
|
+ );
|
|
|
|
|
|
// And make sure the location of the error points to the offset inside the pattern
|
|
|
assertScriptStack(e,
|
|
|
"/\\ujjjj/",
|
|
|
" ^---- HERE");
|
|
|
+
|
|
|
+ e = expectThrows(ScriptException.class, () -> {
|
|
|
+ exec("/(?< >.+)/"); // Invalid capture name
|
|
|
+ });
|
|
|
+ assertEquals(
|
|
|
+ "invalid regular expression: could not compile regex constant [(?< >.+)] with flags []: "
|
|
|
+ + "capturing group name does not start with a Latin letter",
|
|
|
+ e.getCause().getMessage()
|
|
|
+ );
|
|
|
+
|
|
|
+ // And make sure the location of the error points to the offset inside the pattern
|
|
|
+ assertScriptStack(e,
|
|
|
+ "/(?< >.+)/",
|
|
|
+ " ^---- HERE");
|
|
|
}
|
|
|
|
|
|
public void testRegexAgainstNumber() {
|