kolodny/exercises

The problem of the 4th test suite for `throttle`

2hu12 opened this issue · 2 comments

2hu12 commented

Ideally, the 4th test suite for throttle, will execute every threshold ms, the throttled function will executed 6 times, as 1st time right away and every time when time counts to 10ms from 10 to 50.
But the test case is unstable, sometimes it passes, sometimes it doesn't. I test it on both my solution and yours. My method to verify it is to run this test case in a loop for multiple times, says, 10. This test case won't all pass.
I think the reason for this problem is the timeout 55ms of assert.equal is too strict.
Maybe you should consider reset it as 59, which I think it is reasonable.

And I run the same test with timeout 59, I got my solution all passes, also the other test case. But yours still won't all pass, I have not figure out what's your solution's problem yet.

Also I create a pull request about this.

tkh44 commented

3bff2ef breaks the test.
The test will now no longer pass for any solution including the provided, underscore, and lodash.

@tkh44 not sure what you mean:

➜  exercises git:(solutions) git checkout 3bff2ef
Note: checking out '3bff2ef'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 3bff2ef... get rid of throttle race conditions, closes #30
➜  exercises git:(3bff2ef) cd throttle
➜  throttle git:(3bff2ef) git checkout solutions index.js
➜  throttle git:(3bff2ef) ✗ git checkout solutions ../flip.js
➜  throttle git:(3bff2ef) ✗ ../flip.js index.js
➜  throttle git:(3bff2ef) ✗ npm test

> @ test /Users/Moshe/Documents/RandomProjects/exercises/throttle
> node ../node_modules/mocha/bin/mocha



  throttle
    ✓ executes right away
    ✓ won't execute more than once within the threshold
    ✓ will execute at least once more to make up for swallowed calls
    ✓ will execute every threshold ms
    ✓ gets called with context
    ✓ gets called with arguments
    ✓ gets called with the later arguments


  7 passing (17ms)