Skip to content

Instantly share code, notes, and snippets.

@collin
Created October 20, 2008 06:57
Show Gist options
  • Save collin/18031 to your computer and use it in GitHub Desktop.
Save collin/18031 to your computer and use it in GitHub Desktop.
function pass() { console.count('pass'); }
function fail(expr, msg) {
console.count('fail')
console.warn((msg||'')+'expected true got', expr);
}
function assert(expr, msg) {
try {
var result = expr();
if(result) pass();
else fail(result, msg);
}
catch(e) {
console.count('error')
console.error(e.message);
console.info('while running');
console.log(expr.toString());
}
}
assert(function(){
return false;
});
assert(function() {
return true;
});
assert(function() {
return gdangle;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment