Created
December 24, 2009 04:25
-
-
Save ryan-allen/263005 to your computer and use it in GitHub Desktop.
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
// just how my cute lua test thingo worked, without setup and | |
// teardown and nesting :) in javascript! | |
var testrunner = { | |
run: function(tests) { | |
for (var test in tests) { | |
if (tests[test].call()) { | |
print(test + " passed.") | |
} else { | |
print(test + " FAILED!") | |
} | |
} | |
} | |
} | |
var tests = { | |
'does 1 + 1 == 2?' : function() { return 1+1 == 2 }, | |
'does 1 + 1 == 3?' : function() { return 1+1 == 3 }, | |
'does true == true?' : function() { return true == true }, | |
'does true == false?' : function() { return true == false }, | |
} | |
testrunner.run(tests) | |
/* | |
~/dev/jtestthingo $ js jtestthingo.js | |
does 1 + 1 == 2? passed. | |
does 1 + 1 == 3? FAILED! | |
does true == true? passed. | |
does true == false? FAILED! | |
~/dev/jtestthingo $ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment