### Question:
Rescheduler { void reschedule(long delay, TimeUnit timeUnit) { long delayNanos = timeUnit.toNanos(delay); long newRunAtNanos = nanoTime() + delayNanos; enabled = true; if (newRunAtNanos - runAtNanos < 0 || wakeUp == null) { if (wakeUp != null) { wakeUp.cancel(false); } wakeUp = scheduler.schedule(new FutureRunnable(), delayNanos, TimeUnit.NANOSECONDS); } runAtNanos = newRunAtNanos; } Rescheduler(
      Runnable r,
      Executor serializingExecutor,
      ScheduledExecutorService scheduler,
      Stopwatch stopwatch);   }### Answer:
@Test public void runs() { assertFalse(runner.ran); rescheduler.reschedule(1, TimeUnit.NANOSECONDS); assertFalse(runner.ran); scheduler.forwardNanos(1); assertTrue(runner.ran); }
@Test public void reschedules() { assertFalse(runner.ran); rescheduler.reschedule(1, TimeUnit.NANOSECONDS); assertFalse(runner.ran); assertFalse(exec.executed); rescheduler.reschedule(50, TimeUnit.NANOSECONDS); assertFalse(runner.ran); assertFalse(exec.executed); scheduler.forwardNanos(1); assertFalse(runner.ran); assertTrue(exec.executed); scheduler.forwardNanos(50); assertTrue(runner.ran); }
@Test public void reschedulesShortDelay() { assertFalse(runner.ran); rescheduler.reschedule(50, TimeUnit.NANOSECONDS); assertFalse(runner.ran); assertFalse(exec.executed); rescheduler.reschedule(1, TimeUnit.NANOSECONDS); assertFalse(runner.ran); assertFalse(exec.executed); scheduler.forwardNanos(1); assertTrue(runner.ran); assertTrue(exec.executed); }