Ad
  • Custom User Avatar

    No problem, I actually like writing tests. :)
    Maybe change this:

    // filterS
    {
        for (int i : Stream.fromS(rand.nextInt()).filterS(x -> x % 2 == 0).get().takeS(10)) {
            assertTrue("filtering odds with filterS", i % 2 == 0);
        }
    }
    

    into this:

    // filterS
    {
        int start = rand.nextInt();
        for (int i : Stream.fromS(start).filterS(x -> x % 2 == 0).get().takeS(10)) {
            assertTrue("filtering odds with filterS", i % 2 == 0);
            assertTrue("filtering should return next elements", i >= start);
            start += 2;
        }
    }
    

    Now this test will tell if stream returns next odd numbers or just one over and over again :)

  • Custom User Avatar

    Doesn't look like regex to me :P

  • Custom User Avatar

    Test for filterS method should also check for monoticty. Lost a lot of time here. Filter can return the same stream all the time (as long as the head passes the condition) and all the tests are green but primes takes ages and never completes. Was really hard to find this bug without debugger.