--- jsr166/src/test/tck/TimeUnitTest.java 2019/08/11 22:29:27 1.33 +++ jsr166/src/test/tck/TimeUnitTest.java 2019/09/04 22:18:03 1.34 @@ -581,7 +581,7 @@ public class TimeUnitTest extends JSR166 } /** - * timedSleep throws InterruptedException when interrupted + * timeUnit.sleep throws InterruptedException when interrupted */ public void testTimedSleep_Interruptible() { final CountDownLatch pleaseInterrupt = new CountDownLatch(1); @@ -613,6 +613,19 @@ public class TimeUnitTest extends JSR166 } /** + * timeUnit.sleep(x) for x <= 0 does not sleep at all. + */ + public void testTimedSleep_nonPositive() throws InterruptedException { + long startTime = System.nanoTime(); + boolean interrupt = randomBoolean(); + if (interrupt) Thread.currentThread().interrupt(); + randomTimeUnit().sleep(0L); + randomTimeUnit().sleep(-1L); + randomTimeUnit().sleep(Long.MIN_VALUE); + if (interrupt) assertTrue(Thread.interrupted()); + } + + /** * a deserialized/reserialized unit is the same instance */ public void testSerialization() throws Exception {