Skip to content

Instantly share code, notes, and snippets.

@ryan-allen
Created December 24, 2009 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan-allen/263005 to your computer and use it in GitHub Desktop.
Save ryan-allen/263005 to your computer and use it in GitHub Desktop.
// 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