Created
December 8, 2010 15:51
-
-
Save mikebannister/733458 to your computer and use it in GitHub Desktop.
Wondering why I can't catch this assertion error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var EventEmitter = require('events').EventEmitter; | |
var TestEmitter = function() { | |
var self = this; | |
EventEmitter.call(this); | |
setTimeout(function() { | |
self.emit('any', false); | |
}, 2000); | |
}; | |
TestEmitter.prototype = Object.create(EventEmitter.prototype); | |
var funcThatThrowsAssertionError = function(fn) { | |
var testEmitter = new TestEmitter(); | |
testEmitter.on('any', function(val) { | |
assert.ok(val); | |
}); | |
fn(); | |
}; | |
try { | |
funcThatThrowsAssertionError(function() { | |
console.log('done'); | |
}); | |
} catch(err) { | |
console.log(err); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment