From e756f3b12819b98df12ab8c6a3ce0c7d624c46de Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Tue, 25 Jul 2017 17:33:26 +0200 Subject: [PATCH] Prepare for new release --- AUTHORS | 4 ++-- History.md | 6 ++++++ lolex.js | 12 +++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index dffd6ed2..08bbffe4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,14 +5,14 @@ Maximilian Antoni Mark Wubben Duncan Beevers Soutaro Matsumoto +Benjamin Gruenbaum Rogier Schouten -Benjamin Gruenbaum Karl O'Keeffe +Elad Nachmias Clark Tomlinson Josh Goldberg Andy Edwards Curtis M. Humphrey, Ph.D -Elad Nachmias Kyle Fleming Mark Banner Nando diff --git a/History.md b/History.md index 2879fe0a..be2d1d77 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,10 @@ +v2.1.2 / 2017-07-25 +================== + + * - does not fake process.nextTick by default - added .idea folder to .gitignore - fixed documentation - added clock teardowns in tests + * overflowing the timer correctly (issue #67) + v2.1.1 / 2017-07-19 ================== diff --git a/lolex.js b/lolex.js index d6122285..e8f335e9 100644 --- a/lolex.js +++ b/lolex.js @@ -4,6 +4,7 @@ var userAgent = global.navigator && global.navigator.userAgent; var isRunningInIE = userAgent && userAgent.indexOf("MSIE ") > -1; +var maxTimeout = Math.pow(2, 31) - 1; //see https://heycam.github.io/webidl/#abstract-opdef-converttoint // Make properties writable in IE, as per // http://www.adequatelygood.com/Replacing-setTimeout-Globally.html @@ -192,6 +193,14 @@ function addTimer(clock, timer) { throw new Error("Callback must be provided to timer calls"); } + if (timer.hasOwnProperty("delay")) { + timer.delay = timer.delay > maxTimeout ? 1 : timer.delay; + } + + if (timer.hasOwnProperty("interval")) { + timer.interval = timer.interval > maxTimeout ? 1 : timer.interval; + } + if (!clock.timers) { clock.timers = {}; } @@ -691,7 +700,8 @@ exports.install = function install(config) { clock.methods = config.toFake || []; if (clock.methods.length === 0) { - clock.methods = keys(timers); + // do not fake nextTick by default - GitHub#126 + clock.methods = keys(timers).filter(function (key) {return key !== "nextTick";}); } for (i = 0, l = clock.methods.length; i < l; i++) {