Ad
  • Default User Avatar

    Can someone explain what is happening inside "if" statement? after for loop?
    Thanks

  • Default User Avatar

    check mine... it has some regex in it :D

  • Custom User Avatar

    I prefer the way it is, since I want to emphasize the type of the function. (IMO the naming is strange, since it doesn't have to be an operator.) ;)

  • Custom User Avatar

    Thanks for your suggestion. I added a similar test to all 4 languages. :)

  • 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

    Test for filterS method should also check for monoticty.

    You mean that it preserves the original elements that satisfy the predicate?

    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.

    Sorry to hear that. I will add a test. Nevertheless, you might want to write tests on your own (I now, most people hate it). ;)

  • 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.