@Test
    public void testCloseOperationOnFourSeqs() {
        Consumer<Function4<Seq<Integer>, Seq<Integer>, Seq<Integer>, Seq<Integer>, Seq<?>>> test = f -> {
            AtomicBoolean closed1 = new AtomicBoolean();
            AtomicBoolean closed2 = new AtomicBoolean();
            AtomicBoolean closed3 = new AtomicBoolean();
            AtomicBoolean closed4 = new AtomicBoolean();

            Seq<Integer> s1 = seq(Stream.of(1, 2).onClose(() -> closed1.set(true)));
            Seq<Integer> s2 = seq(Stream.of(3).onClose(() -> closed2.set(true)));
            Seq<Integer> s3 = seq(Stream.of(1, 2).onClose(() -> closed3.set(true)));
            Seq<Integer> s4 = seq(Stream.of(3).onClose(() -> closed4.set(true)));

            try (Seq<?> s5 = f.apply(s1, s2, s3, s4)) {
                s5.limit(1000).collect(Collectors.toList());
            }
            
            assertTrue(closed1.get());
            assertTrue(closed2.get());
            assertTrue(closed3.get());
            assertTrue(closed4.get());
        };
        
        test.accept((s1, s2, s3, s4) -> Seq.crossJoin(s1, s2, s3, s4));
        test.accept((s1, s2, s3, s4) -> Seq.zip(s1, s2, s3, s4));
        test.accept((s1, s2, s3, s4) -> Seq.zipAll(s1, s2, s3, s4, 1, 2, 3, 4));
        test.accept((s1, s2, s3, s4) -> Seq.zipAll(s1, s2, s3, s4, 1, 2, 3, 4, (a, b, c, d) -> a + b + c + d));
    }
@author Lukas Eder
@author Roman Tkalenko
jOOL-java-8/src/test/java/org/jooq/lambda/SeqTest.java