@Test @Ignore public void shouldZipTwoInfiniteSequences() throws Exception { final LazyFutureStream<Integer> units = LazyFutureStream.iterate(1, n -> n + 1); final LazyFutureStream<Integer> hundreds = LazyFutureStream.iterate(100, n -> n + 100); final Seq<String> zipped = units.zip(hundreds, (n, p) -> n + ": " + p); assertThat( zipped.limit(5).join(), equalTo(LazyFutureStream.of("1: 100", "2: 200", "3: 300", "4: 400", "5: 500").join())); }
@Test public void shouldZipInfiniteWithFiniteSeq() throws Exception { ThreadPools.setUseCommon(false); final LazyFutureStream<Integer> units = LazyFutureStream.iterate( 1, n -> n + 1); // <-- MEMORY LEAK!- no auto-closing yet, so writes infinetely to it's // async queue final Seq<Integer> hundreds = LazyFutureStream.iterate(100, n -> n + 100).limit(5); final Seq<String> zipped = units.zip(hundreds, (n, p) -> n + ": " + p); assertThat( zipped.limit(5).join(), equalTo(LazyFutureStream.of("1: 100", "2: 200", "3: 300", "4: 400", "5: 500").join())); ThreadPools.setUseCommon(true); }