Created
October 4, 2011 05:25
-
-
Save adrianratnapala/1260963 to your computer and use it in GitHub Desktop.
Javascript assert() implementation in 6 lines.
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
function AssertFailed(message) { | |
this.toString = function() { return 'AssertFailed: ' + message; } | |
} | |
function assert(exp, message) { | |
if (!exp) throw new AssertFailed(message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment