package cyclops.futurestream.react.lazy;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;

import java.util.Set;
import java.util.function.Supplier;

import cyclops.futurestream.FutureStream;
import org.junit.Test;

import cyclops.futurestream.LazyReact;

public class LazySeqAutoOptimizeTest extends LazySeqTest {
	@Override
	protected <U> FutureStream<U> of(U... array) {
		return new LazyReact()
							.autoOptimizeOn()
							.of(array);
	}
	@Override
	protected <U> FutureStream<U> ofThread(U... array) {
		return new LazyReact()
							.autoOptimizeOn()
							.of(array);
	}

	@Override
	protected <U> FutureStream<U> react(Supplier<U>... array) {
		return new LazyReact().autoOptimizeOn()
								.ofAsync(array);
	}
	@Test
	public void multi(){
		Set<Long> threads = of(1,2,3,4)
								.map(i->i+2)
								.map(i->i*3)
								.peek(i-> sleep(50))
								.map(i->Thread.currentThread().getId())
								.toSet();

		assertThat(threads.size(),greaterThan(0));
	}
	@Test
	public void longRunForEach(){
		new LazyReact().autoOptimizeOn().range(0, 1_000_000)
						.map(i->i+2)
						.map(i->Thread.currentThread().getId())
					//	.peek(System.out::println)
						.forEach(a-> {});
		System.out.println("Finished!");
	}
	@Test
	public void longRun(){
		new LazyReact().autoOptimizeOn().range(0, 1_000_000)
						.map(i->i+2)
						.map(i->Thread.currentThread().getId())
					//	.peek(System.out::println)
						.runOnCurrent();
		System.out.println("Finished!");
	}
}

@@ -125,16 +125,59 @@
 ertThat;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Aimport
@@ -1556,10 +1556,236 @@
 !%22);%0A%09%7D%0A
+    @Override%0A    public void testSkipUntilWithNullsInclusive() %7B%0A        Supplier%3CFutureStream%3CInteger%3E%3E s = () -%3E of(1, 2, null, 3, 4, 5);%0A%0A        assertTrue(s.get().dropUntilInclusive(i -%3E true).toList().size()==5);%0A    %7D%0A
 %7D%0A

fix tests