// Path: src/main/java/com/google/code/tempusfugit/ClassInvariantViolation.java
// public class ClassInvariantViolation extends RuntimeException {
// 
//     public ClassInvariantViolation() {
//         super();
//     }
// 
//     public ClassInvariantViolation(String message) {
//         super(message);
//     }
// 
//     public ClassInvariantViolation(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ClassInvariantViolation(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/ThreadUtils.java
// public final class ThreadUtils {
// 
//     public static void sleep(Duration duration) {
//         resetInterruptFlagWhen(sleepingIsInterrupted(duration));
//     }
// 
//     private static Interruptible<Void> sleepingIsInterrupted(Duration duration) {
//         return () -> {
//             Thread.sleep(duration.inMillis());
//             return null;
//         };
//     }
// 
//     public static <T> T resetInterruptFlagWhen(Interruptible<T> interruptible) {
//         try {
//             return interruptible.call();
//         } catch (InterruptedException e) {
//             Thread.currentThread().interrupt();
//         }
//         return null;
//     }
// 
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/ThreadUtils.java
// public static void sleep(Duration duration) {
//     resetInterruptFlagWhen(sleepingIsInterrupted(duration));
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/temporal/Duration.java
// public static Duration millis(long millis) {
//     validate(millis, TimeUnit.MILLISECONDS);
//     return new Duration(millis, TimeUnit.MILLISECONDS);
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/temporal/Duration.java
// public static Duration seconds(long seconds) {
//     validate(seconds, TimeUnit.SECONDS);
//     return new Duration(seconds, TimeUnit.SECONDS);
// }


import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.number.OrderingComparison.greaterThan;
import com.google.code.tempusfugit.ClassInvariantViolation;
import com.google.code.tempusfugit.concurrency.ThreadUtils;
import org.junit.Test;
import java.util.function.Function;
import java.util.function.Supplier;
import static com.google.code.tempusfugit.concurrency.ThreadUtils.sleep;
import static com.google.code.tempusfugit.temporal.Duration.millis;
import static com.google.code.tempusfugit.temporal.Duration.seconds;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.core.Is.is;
    @Test
    public void returnsTotalElapsedTime() {
        timer.reset();
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(equalTo(millis(5))));
    }

    @Test
    public void stoppingMultipleTimesReturnsTotalElapsedTime() {
        timer.reset();
        clock.incrementBy(millis(5));
        timer.lap();
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(millis(10)));
    }

    @Test
    public void shouldRecordElapsedTimeBetweenStartAndStop() {
        timer.reset();
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(millis(5)));
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(millis(10)));
        timer.reset();
        clock.incrementBy(millis(20));
        timer.lap();
// Path: src/main/java/com/google/code/tempusfugit/ClassInvariantViolation.java
// public class ClassInvariantViolation extends RuntimeException {
// 
//     public ClassInvariantViolation() {
//         super();
//     }
// 
//     public ClassInvariantViolation(String message) {
//         super(message);
//     }
// 
//     public ClassInvariantViolation(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ClassInvariantViolation(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/ThreadUtils.java
// public final class ThreadUtils {
// 
//     public static void sleep(Duration duration) {
//         resetInterruptFlagWhen(sleepingIsInterrupted(duration));
//     }
// 
//     private static Interruptible<Void> sleepingIsInterrupted(Duration duration) {
//         return () -> {
//             Thread.sleep(duration.inMillis());
//             return null;
//         };
//     }
// 
//     public static <T> T resetInterruptFlagWhen(Interruptible<T> interruptible) {
//         try {
//             return interruptible.call();
//         } catch (InterruptedException e) {
//             Thread.currentThread().interrupt();
//         }
//         return null;
//     }
// 
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/concurrency/ThreadUtils.java
// public static void sleep(Duration duration) {
//     resetInterruptFlagWhen(sleepingIsInterrupted(duration));
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/temporal/Duration.java
// public static Duration millis(long millis) {
//     validate(millis, TimeUnit.MILLISECONDS);
//     return new Duration(millis, TimeUnit.MILLISECONDS);
// }
// 
// Path: src/main/java/com/google/code/tempusfugit/temporal/Duration.java
// public static Duration seconds(long seconds) {
//     validate(seconds, TimeUnit.SECONDS);
//     return new Duration(seconds, TimeUnit.SECONDS);
// }


// Path: src/test/java/com/google/code/tempusfugit/temporal/TimerTest.java
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.number.OrderingComparison.greaterThan;
import com.google.code.tempusfugit.ClassInvariantViolation;
import com.google.code.tempusfugit.concurrency.ThreadUtils;
import org.junit.Test;
import java.util.function.Function;
import java.util.function.Supplier;
import static com.google.code.tempusfugit.concurrency.ThreadUtils.sleep;
import static com.google.code.tempusfugit.temporal.Duration.millis;
import static com.google.code.tempusfugit.temporal.Duration.seconds;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.core.Is.is;

    @Test
    public void returnsTotalElapsedTime() {
        timer.reset();
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(equalTo(millis(5))));
    }

    @Test
    public void stoppingMultipleTimesReturnsTotalElapsedTime() {
        timer.reset();
        clock.incrementBy(millis(5));
        timer.lap();
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(millis(10)));
    }

    @Test
    public void shouldRecordElapsedTimeBetweenStartAndStop() {
        timer.reset();
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(millis(5)));
        clock.incrementBy(millis(5));
        timer.lap();
        assertThat(timer.elapsedTime(), is(millis(10)));
        timer.reset();
        clock.incrementBy(millis(20));
        timer.lap();
        assertThat(timer.elapsedTime(), is(millis(20)));