cjohansen/Sinon.JS — pull request #399 by timotheeg (2014-02-12 15:21:28+00:00)
Title: Fake timers work cycle support

This pull requests introduces several elements (all tests still pass in chrome on osx)
1. deterministic order for timers
2. support for browser work cycles, by introducing a different way of handling tick(0)
3. minor code refactoring (deleting unnecessary code)

tick(0) does not move time forward. The old approach of running firstTimerInRange() in a while loop would cause any setTimeout(0) introduced by the timers to also run immediately. In worse case scenario, a timer that set itself with another setTimeout(0) would cause an infinite loop. The approach introduced here mimicks the concept of work cycle in a browser: it runs all the timers which are due, then yields. If any of these timers sets an additional setTimeout(0), that is *not* run. The test code will need to execute a separate tick() for them to run.