Test.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. smalltalk.addPackage('Test', {});
  2. smalltalk.addClass('NodeTestRunner', smalltalk.Object, [], 'Test');
  3. smalltalk.addMethod(
  4. "_initialize",
  5. smalltalk.method({
  6. selector: "initialize",
  7. category: 'not yet classified',
  8. fn: function () {
  9. var self = this;
  10. smalltalk.send(self, "_runTestSuite", []);
  11. return self;
  12. },
  13. args: [],
  14. source: "initialize\x0a\x09self runTestSuite",
  15. messageSends: ["runTestSuite"],
  16. referencedClasses: []
  17. }),
  18. smalltalk.NodeTestRunner.klass);
  19. smalltalk.addMethod(
  20. "_runTestSuite",
  21. smalltalk.method({
  22. selector: "runTestSuite",
  23. category: 'not yet classified',
  24. fn: function () {
  25. var self = this;
  26. var $1, $2;
  27. var result;
  28. result = smalltalk.send(smalltalk.TestResult || TestResult, "_new", []);
  29. smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.TestCase || TestCase, "_allSubclasses", []), "_select_", [function (each) {return smalltalk.send(smalltalk.send(each, "_isAbstract", []), "_not", []);}]), "_do_", [function (each) {return smalltalk.send(smalltalk.send(each, "_buildSuite", []), "_do_", [function (suite) {return smalltalk.send(suite, "_runCaseFor_", [result]);}]);}]);
  30. smalltalk.send(console, "_log_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_runs", []), "_asString", []), "__comma", [" tests run, "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_size", []), "_asString", [])]), "__comma", [" failures, "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_size", []), "_asString", [])]), "__comma", [" errors."])]);
  31. $1 = smalltalk.send(smalltalk.send(result, "_failures", []), "_isEmpty", []);
  32. if (!smalltalk.assert($1)) {
  33. smalltalk.send(self, "_throw_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_first", []), "_class", []), "_name", []), "__comma", [" >> "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_failures", []), "_first", []), "_selector", [])]), "__comma", [" is failing!"])]);
  34. }
  35. $2 = smalltalk.send(smalltalk.send(result, "_errors", []), "_isEmpty", []);
  36. if (!smalltalk.assert($2)) {
  37. smalltalk.send(self, "_throw_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_first", []), "_class", []), "_name", []), "__comma", [" >> "]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send(result, "_errors", []), "_first", []), "_selector", [])]), "__comma", [" has errors!"])]);
  38. }
  39. return self;
  40. },
  41. args: [],
  42. source: "runTestSuite\x0a\x09| result |\x0a\x09result := TestResult new.\x0a\x0a\x09((TestCase allSubclasses\x0a\x09\x09select: [ :each | each isAbstract not ])\x0a\x09\x09do: [ :each | each buildSuite do: [ :suite | suite runCaseFor: result ] ]).\x0a\x0a\x09console log: result runs asString, ' tests run, ', result failures size asString, ' failures, ', result errors size asString, ' errors.'.\x0a\x0a\x09result failures isEmpty ifFalse: [ \x0a\x09\x09self throw: result failures first class name, ' >> ', result failures first selector, ' is failing!' ].\x0a\x09result errors isEmpty ifFalse: [\x0a\x09\x09self throw: result errors first class name, ' >> ', result errors first selector, ' has errors!' ].",
  43. messageSends: ["new", "do:", "runCaseFor:", "buildSuite", "select:", "not", "isAbstract", "allSubclasses", "log:", ",", "asString", "size", "errors", "failures", "runs", "ifFalse:", "throw:", "selector", "first", "name", "class", "isEmpty"],
  44. referencedClasses: ["TestResult", "TestCase"]
  45. }),
  46. smalltalk.NodeTestRunner.klass);