@Test
    public void testWindowFunctionCollect() {
        assertEquals(asList(
            asList(1, 2, 4, 2, 3), 
            asList(1, 2, 4, 2, 3), 
            asList(1, 2, 4, 2, 3), 
            asList(1, 2, 4, 2, 3), 
            asList(1, 2, 4, 2, 3)), 
            Seq.of(1, 2, 4, 2, 3).window().map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(1, 2), 
            asList(1, 2, 4), 
            asList(2, 4, 2), 
            asList(4, 2, 3), 
            asList(2, 3)), 
            Seq.of(1, 2, 4, 2, 3).window(-1, 1).map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(), 
            asList(1), 
            asList(1, 2), 
            asList(1, 2, 4), 
            asList(2, 4, 2)), 
            Seq.of(1, 2, 4, 2, 3).window(-3, -1).map(w -> w.collect(toList())).toList());

        
        assertEquals(asList(
            asList(1, 3), 
            asList(2, 4, 2), 
            asList(2, 4, 2), 
            asList(2, 4, 2), 
            asList(1, 3)),
            Seq.of(1, 2, 4, 2, 3).window(i -> i % 2).map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(1, 3), 
            asList(2, 4), 
            asList(2, 4, 2), 
            asList(4, 2), 
            asList(1, 3)),
            Seq.of(1, 2, 4, 2, 3).window(i -> i % 2, -1, 1).map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(), 
            asList(), 
            asList(2), 
            asList(2, 4), 
            asList(1)),
            Seq.of(1, 2, 4, 2, 3).window(i -> i % 2, -3, -1).map(w -> w.collect(toList())).toList());

        
        assertEquals(asList(
            asList(1), 
            asList(1, 2), 
            asList(1, 2, 2, 3, 4), 
            asList(1, 2, 2), 
            asList(1, 2, 2, 3)),
            Seq.of(1, 2, 4, 2, 3).window(naturalOrder()).map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(1, 2), 
            asList(1, 2, 2), 
            asList(3, 4), 
            asList(2, 2, 3), 
            asList(2, 3, 4)),
            Seq.of(1, 2, 4, 2, 3).window(naturalOrder(), -1, 1).map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(), 
            asList(1), 
            asList(2, 2, 3), 
            asList(1, 2), 
            asList(1, 2, 2)),
            Seq.of(1, 2, 4, 2, 3).window(naturalOrder(), -3, -1).map(w -> w.collect(toList())).toList());

        
        assertEquals(asList(
            asList(1), 
            asList(2), 
            asList(2, 2, 4), 
            asList(2, 2), 
            asList(1, 3)),
            Seq.of(1, 2, 4, 2, 3).window(i -> i % 2, naturalOrder()).map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(1, 3), 
            asList(2, 2), 
            asList(2, 4), 
            asList(2, 2, 4), 
            asList(1, 3)),
            Seq.of(1, 2, 4, 2, 3).window(i -> i % 2, naturalOrder(), -1, 1).map(w -> w.collect(toList())).toList());
        
        assertEquals(asList(
            asList(), 
            asList(), 
            asList(2, 2), 
            asList(2), 
            asList(1)),
            Seq.of(1, 2, 4, 2, 3).window(i -> i % 2, naturalOrder(), -3, -1).map(w -> w.collect(toList())).toList());
    }
@author Lukas Eder
@author Roman Tkalenko
jOOL-java-8/src/test/java/org/jooq/lambda/SeqTest.java