// Path: src/main/java/co/unruly/control/ThrowingLambdas.java
// static <T, X extends Exception> Predicate<T> throwingRuntime(ThrowingPredicate<T, X> p) {
//     return x -> {
//         try {
//             return p.test(x);
//         } catch (Exception ex) {
//             throw new RuntimeException(ex);
//         }
//     };
// }


import org.junit.Test;
import java.util.function.Predicate;
import static co.unruly.control.ThrowingLambdas.ThrowingPredicate.throwingRuntime;
import static org.junit.Assert.assertTrue;
package co.unruly.control;




public class ThrowingLambdasTest {

//    @Test
//    public void cannotCompileWhenPassingLambdaThatThrows() throws Exception {
//        assertTrue(test(2, ThrowingLambdasTest::dodgyIsEven));
//    }

    @Test
    public void canHandleThrowingMethodsWithAppropriateFunctionalInterfaceType() {
        assertTrue(tryToTest(2, ThrowingLambdasTest::dodgyIsEven));
    }

    @Test
    public void canHandleMultiThrowingMethodsWithAppropriateFunctionalInterfaceType() {
        assertTrue(tryToTest(2, ThrowingLambdasTest::veryDodgyIsEven));
    }

    @Test
    public void canConvertThrowingLambdasToNonThrowingLambdas() throws Exception {
// Path: src/main/java/co/unruly/control/ThrowingLambdas.java
// static <T, X extends Exception> Predicate<T> throwingRuntime(ThrowingPredicate<T, X> p) {
//     return x -> {
//         try {
//             return p.test(x);
//         } catch (Exception ex) {
//             throw new RuntimeException(ex);
//         }
//     };
// }


// Path: src/test/java/co/unruly/control/ThrowingLambdasTest.java
import org.junit.Test;
import java.util.function.Predicate;
import static co.unruly.control.ThrowingLambdas.ThrowingPredicate.throwingRuntime;
import static org.junit.Assert.assertTrue;

package co.unruly.control;




public class ThrowingLambdasTest {

//    @Test
//    public void cannotCompileWhenPassingLambdaThatThrows() throws Exception {
//        assertTrue(test(2, ThrowingLambdasTest::dodgyIsEven));
//    }

    @Test
    public void canHandleThrowingMethodsWithAppropriateFunctionalInterfaceType() {
        assertTrue(tryToTest(2, ThrowingLambdasTest::dodgyIsEven));
    }

    @Test
    public void canHandleMultiThrowingMethodsWithAppropriateFunctionalInterfaceType() {
        assertTrue(tryToTest(2, ThrowingLambdasTest::veryDodgyIsEven));
    }

    @Test
    public void canConvertThrowingLambdasToNonThrowingLambdas() throws Exception {
        assertTrue(test(2, throwingRuntime(ThrowingLambdasTest::dodgyIsEven)));