RFR: 8258813: [TESTBUG] Fix incorrect Vector API test output message
Paul Sandoz
psandoz at openjdk.java.net
Mon Jan 4 18:47:03 UTC 2021
On Mon, 4 Jan 2021 02:03:13 GMT, Xiaohong Gong <xgong at openjdk.org> wrote:
> Some vector api tests have incorrect output messages if assertion fails. The root cause is the improper use of `"org.testng.Assert.assertEqual()"`, whose definition with int type is:
> assertEquals(int actual, int expected, String message);
>
> The method needs the actual value be used as the first argument and expected value as the second one. But in some vector api tests, the two arguments are swapped.
>
> For example, here is part of the fail log in VectorReshapeTests we met:
> expect: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
> output: [1, 2, 3, 4, 5, 6, 7, 8, 1, 0, 0, 0, 0, 0, 0, 0]
> test VectorReshapeTests.testRebracket128(byte(i)): failure
> java.lang.AssertionError: arrays differ firstly at element [8]; expected value is <1> but was <9>.
> at org.testng.Assert.fail(Assert.java:94)
> at org.testng.Assert.assertEquals(Assert.java:774)
> ...
>
> The assertion error should be `"...expected value is <9> but was <1>."`
>
> This does not influence on the test effectiveness. However, the incorrect message is confusing which might mislead people. The simple fix is just to swap the arguments back.
>
> This patch also adjusts the arguments order of all the assertion methods to make the actual values used as the first one. Besides, it also removes two unused assertion methods.
Thank you for fixing this. So easy to get mixed up between TestNG and JUnit!
It's tempting to change the parameter names of the assert methods to be named `expected` and `accepted`, i'll consider doing that rather than impose that on you.
-------------
Marked as reviewed by psandoz (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/1922
More information about the hotspot-compiler-dev
mailing list