RFR: 8340493: Fix some Asserts failure messages

Daniel Jeliński djelinski at openjdk.org
Tue Dec 17 13:00:38 UTC 2024


On Tue, 17 Dec 2024 00:48:58 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> test/lib/jdk/test/lib/Asserts.java line 272:
>> 
>>> 270:             msg = Objects.toString(msg, "assertEqualsByteArray")
>>> 271:                     + ": expected " + HexFormat.of().formatHex(lhs)
>>> 272:                     + " but was " + HexFormat.of().formatHex(rhs);
>> 
>> The original message is about these two bytes being unequal, but with the new message, it seems to imply that the first argument `lhs` is the expected value and `rhs` is the actual value. I grokked a few calls of this method and it seems that this may not always be the case?
>
> Are those calls from me? I know I haven't followed this pattern and I'm thinking about fixing them later.
> 
> The reason I want to make this change is to make it consistent with the current `assertEquals` method that shows " expected: LEFT but was: RIGHT". There are quite a lot of calls like `assertEquals(variable, "literal")`, but I think that's the callers' problem instead of the method's.

Could you rename `lhs` and `rhs` to `expected` and `actual`? Just to avoid the problems mentioned in https://github.com/openjdk/jdk/pull/17952#issuecomment-1973131407

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21101#discussion_r1888477642


More information about the core-libs-dev mailing list