// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/Nothing.java
// public final class Nothing extends RuntimeException {
//   private static final long serialVersionUID = -5459023265330371793L;
// 
//   private Nothing() {
//     throw new Error("No instances!");
//   }
// }
// 
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingSupplier.java
// @FunctionalInterface
// public interface ThrowingSupplier<R, X extends Throwable> {
//   public R get() throws X;
// 
//   default public Supplier<R> fallbackTo(Supplier<? extends R> fallback) {
//     return fallbackTo(fallback, null);
//   }
// 
//   default public Supplier<R> fallbackTo(Supplier<? extends R> fallback,
//       @Nullable Consumer<? super Throwable> thrown) {
//     ThrowingSupplier<R, Nothing> t = fallback::get;
//     return orTry(t, thrown)::get;
//   }
// 
//   default public <Y extends Throwable> ThrowingSupplier<R, Y>
//       orTry(ThrowingSupplier<? extends R, ? extends Y> supplier) {
//     return orTry(supplier, null);
//   }
// 
//   default public <Y extends Throwable> ThrowingSupplier<R, Y> orTry(
//       ThrowingSupplier<? extends R, ? extends Y> supplier,
//       @Nullable Consumer<? super Throwable> thrown) {
//     Objects.requireNonNull(supplier, "supplier");
//     return () -> {
//       try {
//         return get();
//       } catch (Throwable x) {
//         if (thrown != null) {
//           thrown.accept(x);
//         }
// 
//         try {
//           return supplier.get();
//         } catch (Throwable y) {
//           y.addSuppressed(x);
//           throw y;
//         }
//       }
//     };
//   }
// 
//   default public <Y extends Throwable> ThrowingSupplier<R, Y> rethrow(Class<X> x,
//       Function<? super X, ? extends Y> mapper) {
//     Function<Throwable, ? extends Y> rethrower = RethrowChain.castTo(x).rethrow(mapper).finish();
//     return () -> {
//       try {
//         return get();
//       } catch (Throwable t) {
//         throw rethrower.apply(t);
//       }
//     };
//   }
// }


import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import java.io.IOException;
import java.util.function.Supplier;
import org.junit.Test;
import org.mockito.InOrder;
import name.falgout.jeffrey.throwing.Nothing;
import name.falgout.jeffrey.throwing.ThrowingSupplier;
package name.falgout.jeffrey.throwing.stream;





public class ThrowingLambdasTest {
  private <X extends Throwable> ThrowingSupplier<Object, X> failure(Runnable callback, X x) {
    return () -> {
      if (callback != null) {
        callback.run();
      }
      throw x;
    };
  }

  private <X extends Throwable> ThrowingSupplier<Object, X> success() {
    Object o = new Object();
    return () -> o;
  }

  @Test
  public void fallbackFailureTest() {
    IOException e = new IOException("foo");
    Runnable mock = mock(Runnable.class);
    ThrowingSupplier<Object, IOException> s = failure(mock, e);

// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/Nothing.java
// public final class Nothing extends RuntimeException {
//   private static final long serialVersionUID = -5459023265330371793L;
// 
//   private Nothing() {
//     throw new Error("No instances!");
//   }
// }
// 
// Path: throwing-interfaces/src/main/java/name/falgout/jeffrey/throwing/ThrowingSupplier.java
// @FunctionalInterface
// public interface ThrowingSupplier<R, X extends Throwable> {
//   public R get() throws X;
// 
//   default public Supplier<R> fallbackTo(Supplier<? extends R> fallback) {
//     return fallbackTo(fallback, null);
//   }
// 
//   default public Supplier<R> fallbackTo(Supplier<? extends R> fallback,
//       @Nullable Consumer<? super Throwable> thrown) {
//     ThrowingSupplier<R, Nothing> t = fallback::get;
//     return orTry(t, thrown)::get;
//   }
// 
//   default public <Y extends Throwable> ThrowingSupplier<R, Y>
//       orTry(ThrowingSupplier<? extends R, ? extends Y> supplier) {
//     return orTry(supplier, null);
//   }
// 
//   default public <Y extends Throwable> ThrowingSupplier<R, Y> orTry(
//       ThrowingSupplier<? extends R, ? extends Y> supplier,
//       @Nullable Consumer<? super Throwable> thrown) {
//     Objects.requireNonNull(supplier, "supplier");
//     return () -> {
//       try {
//         return get();
//       } catch (Throwable x) {
//         if (thrown != null) {
//           thrown.accept(x);
//         }
// 
//         try {
//           return supplier.get();
//         } catch (Throwable y) {
//           y.addSuppressed(x);
//           throw y;
//         }
//       }
//     };
//   }
// 
//   default public <Y extends Throwable> ThrowingSupplier<R, Y> rethrow(Class<X> x,
//       Function<? super X, ? extends Y> mapper) {
//     Function<Throwable, ? extends Y> rethrower = RethrowChain.castTo(x).rethrow(mapper).finish();
//     return () -> {
//       try {
//         return get();
//       } catch (Throwable t) {
//         throw rethrower.apply(t);
//       }
//     };
//   }
// }


// Path: throwing-interfaces/src/test/java/name/falgout/jeffrey/throwing/stream/ThrowingLambdasTest.java
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import java.io.IOException;
import java.util.function.Supplier;
import org.junit.Test;
import org.mockito.InOrder;
import name.falgout.jeffrey.throwing.Nothing;
import name.falgout.jeffrey.throwing.ThrowingSupplier;

package name.falgout.jeffrey.throwing.stream;





public class ThrowingLambdasTest {
  private <X extends Throwable> ThrowingSupplier<Object, X> failure(Runnable callback, X x) {
    return () -> {
      if (callback != null) {
        callback.run();
      }
      throw x;
    };
  }

  private <X extends Throwable> ThrowingSupplier<Object, X> success() {
    Object o = new Object();
    return () -> o;
  }

  @Test
  public void fallbackFailureTest() {
    IOException e = new IOException("foo");
    Runnable mock = mock(Runnable.class);
    ThrowingSupplier<Object, IOException> s = failure(mock, e);

    Supplier<Object> fallback = this.<Nothing> success()::get;