Ad
  • Custom User Avatar
    • No random tests

    • JS Node 18. with chai framework should be used

  • Default User Avatar

    reusability/purity is not specified/tested: what should happen for a test like this ?

    it('reusability', function() {
      const chain = lazyChain([1, 2, 3]);
      const once  = chain.invoke('map', x => x * x);
      const twice = chain.invoke('map', x => x * x);
      // [1, 16, 81] or [1, 4, 9] ?
      Test.assertSimilar(once.value(), [1, 4, 9]);
      Test.assertSimilar(twice.value(), [1, 4, 9]);
    });
    
  • Custom User Avatar

    Nice idea but no random tests.

  • Custom User Avatar

    Approved

  • Custom User Avatar

    The syntax for expectError is different, and you had the test always expecting errors. That won't discriminate between lazy (no error) and eager (error) of course. The test was testing for its own incorrect syntax, and always passing. :P

    I fixed the test; have a look at it. You give a function that throws an error as the argument, so you wrap the user solution in a dummy function. Unfortunately, I haven't been able to figure out how to give a message when the test fails, and the docs are out of date on this. So there is only the default error message when failing the test.

    But at least it should now work as intended. :]

  • Default User Avatar

    Thanks I couldn't think of a proper way to check for laziness. I believe it checks for it now, but let me know if you see any more issues. Thanks again for the feedback.

  • Custom User Avatar

    You're still not testing for the laziness of the solution.

    ATM, all you need to do is parse an awkward alternate syntax of standard JS methods. There need be no thunking involved. See my solution. (The last one, with the Eager class.)

    The way to test this, of course, is invoke some method that will run forever if evaluated, and then test without invoking value.

  • Default User Avatar

    The issue should be fixed, you could say I was being lazy with my testing.

  • Custom User Avatar

    Laziness should really be tested. My eager solution passes.