Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit d347d2e

Browse files
committedJun 2, 2020
8246261: TCKLocalTime.java failed due to "AssertionError: expected [18:14:22] but found [18:14:23]"
Reviewed-by: lancea, joehw
1 parent 3dc78e7 commit d347d2e

File tree

3 files changed

+10
-30
lines changed

3 files changed

+10
-30
lines changed
 

‎test/jdk/java/time/tck/java/time/TCKLocalDateTime.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -110,6 +110,7 @@
110110
import java.time.Clock;
111111
import java.time.DateTimeException;
112112
import java.time.DayOfWeek;
113+
import java.time.Duration;
113114
import java.time.Instant;
114115
import java.time.LocalDate;
115116
import java.time.LocalDateTime;
@@ -284,15 +285,8 @@ public void now_ZoneId() {
284285
ZoneId zone = ZoneId.of("UTC+01:02:03");
285286
LocalDateTime expected = LocalDateTime.now(Clock.system(zone));
286287
LocalDateTime test = LocalDateTime.now(zone);
287-
for (int i = 0; i < 100; i++) {
288-
if (expected.equals(test)) {
289-
return;
290-
}
291-
expected = LocalDateTime.now(Clock.system(zone));
292-
test = LocalDateTime.now(zone);
293-
}
294-
assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
295-
expected.truncatedTo(ChronoUnit.SECONDS));
288+
assertEquals(Duration.between(expected, test).truncatedTo(ChronoUnit.SECONDS),
289+
Duration.ZERO);
296290
}
297291

298292
//-----------------------------------------------------------------------

‎test/jdk/java/time/tck/java/time/TCKLocalTime.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -241,15 +241,8 @@ public void now_ZoneId() {
241241
ZoneId zone = ZoneId.of("UTC+01:02:03");
242242
LocalTime expected = LocalTime.now(Clock.system(zone));
243243
LocalTime test = LocalTime.now(zone);
244-
for (int i = 0; i < 100; i++) {
245-
if (expected.equals(test)) {
246-
return;
247-
}
248-
expected = LocalTime.now(Clock.system(zone));
249-
test = LocalTime.now(zone);
250-
}
251-
assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
252-
expected.truncatedTo(ChronoUnit.SECONDS));
244+
assertEquals(Duration.between(expected, test).truncatedTo(ChronoUnit.SECONDS),
245+
Duration.ZERO);
253246
}
254247

255248
//-----------------------------------------------------------------------

‎test/jdk/java/time/tck/java/time/TCKZonedDateTime.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -253,15 +253,8 @@ public void now_ZoneId() {
253253
ZoneId zone = ZoneId.of("UTC+01:02:03");
254254
ZonedDateTime expected = ZonedDateTime.now(Clock.system(zone));
255255
ZonedDateTime test = ZonedDateTime.now(zone);
256-
for (int i = 0; i < 100; i++) {
257-
if (expected.equals(test)) {
258-
return;
259-
}
260-
expected = ZonedDateTime.now(Clock.system(zone));
261-
test = ZonedDateTime.now(zone);
262-
}
263-
assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
264-
expected.truncatedTo(ChronoUnit.SECONDS));
256+
assertEquals(Duration.between(expected, test).truncatedTo(ChronoUnit.SECONDS),
257+
Duration.ZERO);
265258
}
266259

267260
//-----------------------------------------------------------------------

0 commit comments

Comments
 (0)
This repository has been archived.