Skip to content

Instantly share code, notes, and snippets.

@philsinatra
Created August 16, 2013 14:03
Show Gist options
  • Save philsinatra/6250222 to your computer and use it in GitHub Desktop.
Save philsinatra/6250222 to your computer and use it in GitHub Desktop.
Javascript assertion test function.
// Add 'alert' style fallback for console.log commands (IE8)
var alertFallback = true;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFallback) {
console.log = function(msg) {
alert(msg);
};
}
else
console.log = function() {};
}
function assert (value, desc) {
result = value ? 'pass' : 'fail';
if (!value)
result = 'fail';
console.log(result + ': ' + desc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment