On Wed, 18 Aug 2021 18:35:53 GMT, Ian Graves <igra...@openjdk.org> wrote:

>> 8271302: Regex Test Refresh
>
> Ian Graves has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Couple of fixes

test/jdk/java/util/regex/NegativeArraySize.java line 2:

> 1: /*
> 2:  * Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights 
> reserved.

Add comma after 2021, or the copyright headers check won't pass.

test/jdk/java/util/regex/NegativeArraySize.java line 29:

> 27:  * @summary Pattern.compile() can throw confusing 
> NegativeArraySizeException
> 28:  * @requires os.maxMemory >= 5g
> 29:  * @run testng/othervm -Xms5G -Xmx5G NegativeArraySize

I note that the order of the arguments has changed. Will that work as expected? 
Had it worked as expected before?

test/jdk/java/util/regex/NegativeArraySize.java line 40:

> 38:     @Test
> 39:     public static void testNegativeArraySize() {
> 40:         assertThrows(OutOfMemoryError.class, () -> Pattern.compile("\\Q" 
> + "a".repeat(42 + Integer.MAX_VALUE / 3)));

One observation on this regex. Although the regex looks invalid because `\\Q` 
misses the pairing `\\E`, it can still be compiled (with a reasonable number of 
a's, of course). Moreover, the resulting pattern matches strings in a 
surprising way:


jshell> Pattern.compile("\\Qaaa").matcher("aaa").matches()
$1 ==> true

test/jdk/java/util/regex/RegExTest.java line 27:

> 25:  * @test
> 26:  * @summary tests RegExp framework (use -Dseed=X to set PRNG seed)
> 27:  * @author Mike McCloskey

What happened to Mike here? :-)

test/jdk/java/util/regex/RegExTest.java line 121:

> 119:     private static void check(String p, String s, boolean expected) {
> 120:         Matcher matcher = Pattern.compile(p).matcher(s);
> 121:         assertSame(matcher.find(), expected);

Why use `assertSame(Object, Object)`? I would expect `assertEquals(boolean, 
boolean)`.

test/jdk/java/util/regex/RegExTest.java line 206:

> 204:     }
> 205: 
> 206:     // Regular expression test// Most of the tests are in a file

Mistakenly joined comment lines?

-------------

PR: https://git.openjdk.java.net/jdk/pull/5092

Reply via email to