// Path: src/main/java/co/unruly/control/Piper.java
// public static <T> Piper<T> pipe(T element) {
//     return new Piper<T>(element);
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isFailureOf(F expectedValue) {
//     return isFailureThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isSuccessOf(S expectedValue) {
//     return isSuccessThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/result/Introducers.java
// @SuppressWarnings("unchecked")
// static <IS, OS extends IS> Function<IS, Result<OS, IS>> castTo(Class<OS> targetClass) {
//     return input -> targetClass.isAssignableFrom(input.getClass())
//         ? Result.success((OS)input)
//         : Result.failure(input);
// }


import org.junit.Test;
import static co.unruly.control.Piper.pipe;
import static co.unruly.control.matchers.ResultMatchers.isFailureOf;
import static co.unruly.control.matchers.ResultMatchers.isSuccessOf;
import static co.unruly.control.result.Introducers.castTo;
import static org.junit.Assert.assertThat;
package co.unruly.control.result;



public class CastsTest {

    @Test
    public void castingToCorrectTypeYieldsSuccess() {
        final Object helloWorld = "Hello World";

        Result<String, Object> cast = pipe(helloWorld)
                .resolveWith(castTo(String.class));

        assertThat(cast, isSuccessOf("Hello World"));
    }

    @Test
// Path: src/main/java/co/unruly/control/Piper.java
// public static <T> Piper<T> pipe(T element) {
//     return new Piper<T>(element);
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isFailureOf(F expectedValue) {
//     return isFailureThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/matchers/ResultMatchers.java
// public static <S, F> Matcher<Result<S, F>> isSuccessOf(S expectedValue) {
//     return isSuccessThat(equalTo(expectedValue));
// }
// 
// Path: src/main/java/co/unruly/control/result/Introducers.java
// @SuppressWarnings("unchecked")
// static <IS, OS extends IS> Function<IS, Result<OS, IS>> castTo(Class<OS> targetClass) {
//     return input -> targetClass.isAssignableFrom(input.getClass())
//         ? Result.success((OS)input)
//         : Result.failure(input);
// }


// Path: src/test/java/co/unruly/control/result/CastsTest.java
import org.junit.Test;
import static co.unruly.control.Piper.pipe;
import static co.unruly.control.matchers.ResultMatchers.isFailureOf;
import static co.unruly.control.matchers.ResultMatchers.isSuccessOf;
import static co.unruly.control.result.Introducers.castTo;
import static org.junit.Assert.assertThat;

package co.unruly.control.result;



public class CastsTest {

    @Test
    public void castingToCorrectTypeYieldsSuccess() {
        final Object helloWorld = "Hello World";

        Result<String, Object> cast = pipe(helloWorld)
                .resolveWith(castTo(String.class));

        assertThat(cast, isSuccessOf("Hello World"));
    }

    @Test
    public void castingToIncorrectTypeYieldsFailure() {