Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8271302: Regex Test Refresh
Reviewed-by: bchristi, smarks
  • Loading branch information
Ian Graves committed Aug 30, 2021
1 parent f18c0fa commit fecefb8
Show file tree
Hide file tree
Showing 3 changed files with 1,264 additions and 2,033 deletions.
22 changes: 12 additions & 10 deletions test/jdk/java/util/regex/GraphemeTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
Expand All @@ -26,23 +26,25 @@
* @bug 7071819 8221431 8239383
* @summary tests Unicode Extended Grapheme support
* @library /lib/testlibrary/java/lang
* @run main GraphemeTest
* @run testng GraphemeTest
*/

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

import org.testng.annotations.Test;
import static org.testng.Assert.fail;

public class GraphemeTest {

public static void main(String[] args) throws Throwable {
@Test
public static void testGraphemeBreakProperty() throws Throwable {
testProps(UCDFiles.GRAPHEME_BREAK_PROPERTY);
}

@Test
public static void testEmojiData() throws Throwable {
testProps(UCDFiles.EMOJI_DATA);
}

Expand Down Expand Up @@ -78,7 +80,7 @@ private static void testProps(Path path) throws IOException {
System.out.printf("[%x] [%s][%d] -> [%s]%n",
cp, expected, Character.getType(cp), types[getType(cp)]);
else
throw new RuntimeException(String.format(
fail(String.format(
"cp=[%x], expeced:[%s] result:[%s]%n",
cp, expected, types[getType(cp)]));
}
Expand Down
16 changes: 8 additions & 8 deletions test/jdk/java/util/regex/NegativeArraySize.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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
Expand All @@ -26,17 +26,17 @@
* @bug 8223174
* @summary Pattern.compile() can throw confusing NegativeArraySizeException
* @requires os.maxMemory >= 5g
* @run main/othervm NegativeArraySize -Xms5G -Xmx5G
* @run testng/othervm -Xms5G -Xmx5G NegativeArraySize
*/

import org.testng.annotations.Test;
import static org.testng.Assert.assertThrows;

import java.util.regex.Pattern;

public class NegativeArraySize {
public static void main(String[] args) {
try {
Pattern.compile("\\Q" + "a".repeat(42 + Integer.MAX_VALUE / 3));
throw new AssertionError("expected to throw");
} catch (OutOfMemoryError expected) {
}
@Test
public static void testNegativeArraySize() {
assertThrows(OutOfMemoryError.class, () -> Pattern.compile("\\Q" + "a".repeat(42 + Integer.MAX_VALUE / 3)));
}
}

3 comments on commit fecefb8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on fecefb8 Mar 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealMDoerr the backport was successfully created on the branch TheRealMDoerr-backport-fecefb85 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit fecefb85 from the openjdk/jdk repository.

The commit being backported was authored by Ian Graves on 30 Aug 2021 and was reviewed by Brent Christian and Stuart Marks.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev TheRealMDoerr-backport-fecefb85:TheRealMDoerr-backport-fecefb85
$ git checkout TheRealMDoerr-backport-fecefb85
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev TheRealMDoerr-backport-fecefb85

Please sign in to comment.