Guest User

Untitled

a guest
Apr 26th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // just how my cute lua test thingo worked, without setup and
  2. // teardown and nesting :) in javascript!
  3.  
  4. var testrunner = {
  5. run: function(tests) {
  6. for (var test in tests) {
  7. if (tests[test].call()) {
  8. print(test + " passed.")
  9. } else {
  10. print(test + " FAILED!")
  11. }
  12. }
  13. }
  14. }
  15.  
  16. var tests = {
  17. 'does 1 + 1 == 2?' : function() { return 1+1 == 2 },
  18. 'does 1 + 1 == 3?' : function() { return 1+1 == 3 },
  19. 'does true == true?' : function() { return true == true },
  20. 'does true == false?' : function() { return true == false },
  21. }
  22.  
  23. testrunner.run(tests)
  24.  
  25. /*
  26. ~/dev/jtestthingo $ js jtestthingo.js
  27. does 1 + 1 == 2? passed.
  28. does 1 + 1 == 3? FAILED!
  29. does true == true? passed.
  30. does true == false? FAILED!
  31. ~/dev/jtestthingo $
  32. */
Add Comment
Please, Sign In to add comment