Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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 $
- */
Add Comment
Please, Sign In to add comment