Created
August 13, 2014 02:27
-
-
Save bran921007/7352450784c1ccab1df3 to your computer and use it in GitHub Desktop.
Debugging Asserts JavaScript
This file contains hidden or 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
<html> | |
<head> | |
<title>Test Suite</title> | |
<script> | |
function assert(value, desc) { | |
var li = document.createElement("li"); | |
li.className = value ? "pass" : "fail"; | |
li.appendChild(document.createTextNode(desc)); | |
document.getElementById("results").appendChild(li); | |
} | |
window.onload = function() { | |
assert(true, "The test suite is running."); | |
assert(false, "Fail!"); | |
}; | |
</script> | |
<style> | |
#results li.pass { color: green; } | |
#results li.fail { color: red; } | |
</style> | |
</head> | |
<body> | |
<ul id="results"></ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment