Make test_clear_45877 more reliable and test more behavior
The test depends on the System.currentMillis() method and so its behavior varies based on the time. It was failing consistently but only when the current time was in the afternoon in Los Angeles. This is a change in behavior from M but it looks as though the old behavior was wrong, the new behavior is consistent with the RI. This behavior is described in the class documentation in the #time_resolution section, although it's not very clear. The code works as follows. The test clears HOUR and HOUR_OF_DAY fields whose stamp are marked as UNSET(0), AM_PM was previously computed so is marked as COMPUTED(1). The selectFields() will then select fields HOUR and AM_PM as being the best source of the hours value. HOUR was cleared and set to 0, AM_PM was what was previously computed (which in the morning was 0 and in the afternoon was 1). HOUR_OF_DAY is calculated by multiplying AM_PM by 12 so, HOUR_OF_DAY is set to 0 in the morning and 12 in the afternoon which is exactly what is seen. The test was only added as part of a documentation update so it doesn't look as though it was trying to enforce the M behavior. It looks as though the difference in behavior is related to limitations in how M tracked which fields had been set. M only remembered the last field set not a relative ordering over all the set fields as the new OpenJDK based code does. So in some cases, such as this one, M did not have enough information to make the correct choice. The test has been made more robust (uses a fixed time) and been split into two tests, one of which tests the morning and one the afternoon behavior. Bug: 26022884 Change-Id: I15c8a9173a0819798bec3f11146fa7d5ea85600d
Loading
Please sign in to comment