// Path: src/main/java/streams/factories/ExecPushFactory.java
// public class ExecPushFactory extends PushFactory implements ExecStreamAlg<Id.t, Push.t> {
//     @Override
//     public <T> App<Id.t, Long> count(App<Push.t, T> app) {
//         RefCell<Long> temp = new RefCell<>(0L);
//         Push.prj(app).invoke(i -> temp.value++);
//         return Id.inj(new Id<>(temp.value));
//     }
// 
//     @Override
//     public <T> App<Id.t, T> reduce(T identity, BinaryOperator<T> accumulator, App<Push.t, T> app) {
//         final RefCell<T> state = new RefCell<>(identity);
//         Push.prj(app).invoke(i -> state.value = accumulator.apply(state.value, i));
//         return Id.inj(new Id<>(state.value));
//     }
// }
// 
// Path: src/main/java/streams/higher/Id.java
// public class Id<T> implements App<Id.t, T> {
// 
//     public final T value;
// 
//     public Id(T value) {
//         this.value = value;
//     }
// 
//     public static <A> Id<A> prj(App<Id.t, A> app) {
//         return (Id<A>) app;
//     }
// 
//     public static <A> App<Id.t, A> inj(Id<A> app) {
//         return (App<Id.t, A>) app;
//     }
// 
//     public static class t {
//     }
// }


import org.junit.Before;
import org.junit.Test;
import streams.factories.ExecPushFactory;
import streams.higher.Id;
import java.util.stream.IntStream;
import static org.junit.Assert.assertEquals;
    @Test
    public void testMapCountPush() {
        ExecPushFactory alg = new ExecPushFactory();

        Long actual = Id.prj(alg.count(alg.map(x -> x ^ 2, alg.source(v)))).value;

        Long expected = java.util.stream.Stream.of(v)
                .map(x -> x ^ 2)
                .count();

        assertEquals(expected, actual);
    }

    @Test
    public void testFlatMapCountPush() {
        ExecPushFactory alg = new ExecPushFactory();

        Long actual = Id.prj(alg.count(alg.flatMap(x -> {
            return alg.map(y -> x * y, alg.source(v_small));
        }, alg.source(v)))).value;

        Long expected = java.util.stream.Stream.of(v)
                .flatMap(x -> java.util.stream.Stream.of(v_small).map(y -> x * y))
                .count();

        assertEquals(expected, actual);
    }

    @Test
    public void testReducePush() {
// Path: src/main/java/streams/factories/ExecPushFactory.java
// public class ExecPushFactory extends PushFactory implements ExecStreamAlg<Id.t, Push.t> {
//     @Override
//     public <T> App<Id.t, Long> count(App<Push.t, T> app) {
//         RefCell<Long> temp = new RefCell<>(0L);
//         Push.prj(app).invoke(i -> temp.value++);
//         return Id.inj(new Id<>(temp.value));
//     }
// 
//     @Override
//     public <T> App<Id.t, T> reduce(T identity, BinaryOperator<T> accumulator, App<Push.t, T> app) {
//         final RefCell<T> state = new RefCell<>(identity);
//         Push.prj(app).invoke(i -> state.value = accumulator.apply(state.value, i));
//         return Id.inj(new Id<>(state.value));
//     }
// }
// 
// Path: src/main/java/streams/higher/Id.java
// public class Id<T> implements App<Id.t, T> {
// 
//     public final T value;
// 
//     public Id(T value) {
//         this.value = value;
//     }
// 
//     public static <A> Id<A> prj(App<Id.t, A> app) {
//         return (Id<A>) app;
//     }
// 
//     public static <A> App<Id.t, A> inj(Id<A> app) {
//         return (App<Id.t, A>) app;
//     }
// 
//     public static class t {
//     }
// }


// Path: src/test/java/algebras/TestAlgebrasPush.java
import org.junit.Before;
import org.junit.Test;
import streams.factories.ExecPushFactory;
import streams.higher.Id;
import java.util.stream.IntStream;
import static org.junit.Assert.assertEquals;

    @Test
    public void testMapCountPush() {
        ExecPushFactory alg = new ExecPushFactory();

        Long actual = Id.prj(alg.count(alg.map(x -> x ^ 2, alg.source(v)))).value;

        Long expected = java.util.stream.Stream.of(v)
                .map(x -> x ^ 2)
                .count();

        assertEquals(expected, actual);
    }

    @Test
    public void testFlatMapCountPush() {
        ExecPushFactory alg = new ExecPushFactory();

        Long actual = Id.prj(alg.count(alg.flatMap(x -> {
            return alg.map(y -> x * y, alg.source(v_small));
        }, alg.source(v)))).value;

        Long expected = java.util.stream.Stream.of(v)
                .flatMap(x -> java.util.stream.Stream.of(v_small).map(y -> x * y))
                .count();

        assertEquals(expected, actual);
    }

    @Test
    public void testReducePush() {
        ExecPushFactory alg = new ExecPushFactory();