deadunit-core
Advanced tools
Comparing version 5.0.5 to 5.0.6
@@ -137,2 +137,3 @@ "use strict"; | ||
this.history = [] | ||
this.emitDepth = 0 // records how many futures are waiting on eachother, so we can make sure maximum stack depth isn't exceeded | ||
this.lastEmitFuture = Future(undefined) | ||
@@ -147,11 +148,20 @@ } | ||
var that = this | ||
this.lastEmitFuture = this.lastEmitFuture.then(function() { | ||
return eventDataFuture | ||
}).then(function(eventData){ | ||
if(eventData !== undefined) | ||
recordAndTriggerHandlers.call(that, type, eventData) | ||
}).catch(function(e) { | ||
that.warningHandler(e) | ||
}) | ||
var doStuff = function() { | ||
that.lastEmitFuture = that.lastEmitFuture.then(function() { | ||
return eventDataFuture | ||
}).then(function(eventData){ | ||
if(eventData !== undefined) | ||
recordAndTriggerHandlers.call(that, type, eventData) | ||
}).catch(function(e) { | ||
that.warningHandler(e) | ||
}) | ||
} | ||
this.emitDepth++ | ||
if(this.emitDepth%50 == 0) { | ||
doStuff() | ||
} else { | ||
setTimeout(doStuff, 0) // make sure we don't get a "too much recursion error" // todo: test not doing this once browsers all support proper tail calls | ||
} | ||
return this.lastEmitFuture | ||
@@ -499,6 +509,8 @@ } | ||
that.manager.emit('end', Future({ | ||
type: type, | ||
time: now() | ||
})) | ||
setTimeout(function() { // setTimeout here is to make it so the currently running threadlet that caused the test to end can finish before the end event is sent | ||
that.manager.emit('end', Future({ | ||
type: type, | ||
time: now() | ||
})) | ||
},0) | ||
} | ||
@@ -505,0 +517,0 @@ |
@@ -158,3 +158,3 @@ "use strict"; | ||
var result = { | ||
fn: infoElement.getFunctionName(), | ||
function: infoElement.getFunctionName(), | ||
file: infoElement.getFileName(), | ||
@@ -161,0 +161,0 @@ line: infoElement.getLineNumber(), |
{"name":"deadunit-core", | ||
"description": "The core for deadunit - a dead-simple nestable unit testing library for javascript in node.js and the browser.", | ||
"keywords": ["unit", "test", "testing", "javascript", "node", "deadunit", "asynchronous"], | ||
"version":"5.0.5", | ||
"version":"5.0.6", | ||
"dependencies":{ | ||
@@ -16,3 +16,3 @@ "async-future":"1.0.0", | ||
"devDependencies": { | ||
"deadunit":"5.0.0", | ||
"deadunit":"5.1.1", | ||
"fibers":"", | ||
@@ -19,0 +19,0 @@ "requirejs":"", |
@@ -305,2 +305,5 @@ `deadunitCore` | ||
* 5.0.6 | ||
* ensuring that the end event is only called once the test threadlet (e.g. a setTimeout callback) has finished | ||
* trying to mitigate "too much recursion" errors by using setTimeout | ||
* 5.0.5 - updating stackinfo to support sourcemapping for newer versions of firefox (that have a new stacktrace format) | ||
@@ -307,0 +310,0 @@ * 5.0.4 |
@@ -8,4 +8,4 @@ | ||
return function(t) { | ||
this.count(2) | ||
this.timeout(10 * 1000) | ||
//this.count(2) | ||
//this.timeout(10 * 1000) | ||
var browserSpecificFutures = [] | ||
@@ -54,3 +54,3 @@ | ||
this.count(4) | ||
//* | ||
var FailUnit = require('./deadunitCore.browserAjaxFailure') | ||
@@ -71,3 +71,3 @@ | ||
t.ok(results.results.length === 2, results.results.length) | ||
t.ok(results.results.length === 3, results.results.length) | ||
t.ok(results.exceptions.length >= 2, results.exceptions.length) // honestly i'm just happy if this test doesn't crash the browser | ||
@@ -78,3 +78,3 @@ | ||
}) | ||
//*/ | ||
//* | ||
@@ -107,2 +107,4 @@ var FailUnit2 = require('./deadunitCore.browserAjaxThrow') | ||
//* | ||
Future.all(browserSpecificFutures).then(function() { | ||
@@ -109,0 +111,0 @@ t.test("common tests", tests.getTests(Unit, 'web', {return: function(){}})) |
@@ -33,2 +33,3 @@ "use strict"; | ||
//* | ||
@@ -255,3 +256,3 @@ this.test('simple success', function(t) { | ||
} else { | ||
var subtest3line = 7872 | ||
var subtest3line = 7887 | ||
this.ok(subtest3.line === subtest3line, subtest3.line) // browserify bug causes sourcemap to not be found | ||
@@ -258,0 +259,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1313581
17023
369