russplaysguitar / UnderscoreCF

An UnderscoreJS port for Coldfusion. Functional programming library.
http://russplaysguitar.github.com/UnderscoreCF/
MIT License
89 stars 38 forks source link

Debounce like a boss #18

Closed atuttle closed 11 years ago

atuttle commented 11 years ago

Debounce, Debounce Tests (both immediate true and false), and updated the doc generator for debounce. Also added some linebreaks in generated docs.

russplaysguitar commented 11 years ago

I can't wait to test this out! I wish travis-ci worked with CF so I didn't have to manually re-test!

atuttle commented 11 years ago

I've got Jenkins running for Taffy. I'd be happy to host the tests for Underscore too. Maybe I'll do that as one of my pull requests. ;)

russplaysguitar commented 11 years ago

A jenkins server would be great!

russplaysguitar commented 11 years ago

Thanks for the css fix.

I'm getting intermittent test failures for debounce in CF. I'm running Win7 64 with CF 10 update 6. Only 1gb RAM (it's in a VM).

The failures appear when using runTests.cfm. If you can't reproduce the issues then I'll try to investigate further and provide more feedback.

atuttle commented 11 years ago

There are some assertions have have to do with time elapsed, which could be different on different hardware. I'll take a look at them tonight. Can you provide any detail on the failures?

atuttle commented 11 years ago

Oh and I haven't installed update 6 yet locally. Will try that too and see if it changes anything.

atuttle commented 11 years ago

Installed update 6 and re-ran the tests a bunch of times. Average run time for testDebounce_ImmediateTrue is about 107ms for me. One time I saw it go up to 127ms, and the actual result went up to 4 instead of 3. If there were something unrelated that caused a 20ms delay in there, the debounce test assertions would be wrong because it's possible that enough time would have passed from the external delay to allow the function to run. The tests are kind of written assuming they're running in a vacuum. Without adding significant sleep durations that would slow down the test suite I don't see a way around it. But it only failed for me once out of more than 30 runs.

russplaysguitar commented 11 years ago

Intermittent failures:

testDebounce_ImmediateTrue: once on the leading edge Expected [2] BUT RECEIVED [3.0]. These values should be the same.

testDebounce_ImmediateFalse: debounce calms overzealous method calling Expected [2] BUT RECEIVED [1.0]. These values should be the same.

testDelay: function delay is at least as long as requested

atuttle commented 11 years ago

How about now? With the latest changes I'm not getting any failures at all with dozens and dozens of runs.

russplaysguitar commented 11 years ago

Awesome, I just confirmed that this works in CF10.

It doesn't work in Railo 4, but I have a fix for that already which I'll apply after this is merged.

Thanks a ton for implementing this!

atuttle commented 11 years ago

Your changes look good. I'd have used isDefined too. I'm curious about the Railo bug tho. Have you reported it?

russplaysguitar commented 11 years ago

I haven't reported it yet. Honestly, their issue tracker scares me.

atuttle commented 11 years ago

https://issues.jboss.org/browse/RAILO-2230

russplaysguitar commented 11 years ago

Nice, thanks