2
0

SUnit.deploy.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. smalltalk.addPackage('SUnit', {});
  2. smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector'], 'SUnit');
  3. smalltalk.addMethod(
  4. "_assert_",
  5. smalltalk.method({
  6. selector: "assert:",
  7. fn: function (aBoolean) {
  8. var self=this;
  9. smalltalk.send(self, "_assert_description_", [aBoolean, "Assertion failed"]);
  10. return self;}
  11. }),
  12. smalltalk.TestCase);
  13. smalltalk.addMethod(
  14. "_assert_description_",
  15. smalltalk.method({
  16. selector: "assert:description:",
  17. fn: function (aBoolean, aString) {
  18. var self=this;
  19. ((($receiver = aBoolean).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self, "_signalFailure_", [aString]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self, "_signalFailure_", [aString]);})]));
  20. return self;}
  21. }),
  22. smalltalk.TestCase);
  23. smalltalk.addMethod(
  24. "_assert_equals_",
  25. smalltalk.method({
  26. selector: "assert:equals:",
  27. fn: function (expected, actual) {
  28. var self=this;
  29. return smalltalk.send(self, "_assert_description_", [smalltalk.send(expected, "__eq", [actual]), smalltalk.send(smalltalk.send(smalltalk.send("Expected: ", "__comma", [smalltalk.send(expected, "_asString", [])]), "__comma", [" but was: "]), "__comma", [smalltalk.send(actual, "_asString", [])])]);
  30. return self;}
  31. }),
  32. smalltalk.TestCase);
  33. smalltalk.addMethod(
  34. "_deny_",
  35. smalltalk.method({
  36. selector: "deny:",
  37. fn: function (aBoolean) {
  38. var self=this;
  39. smalltalk.send(self, "_assert_", [smalltalk.send(aBoolean, "_not", [])]);
  40. return self;}
  41. }),
  42. smalltalk.TestCase);
  43. smalltalk.addMethod(
  44. "_performTestFor_",
  45. smalltalk.method({
  46. selector: "performTestFor:",
  47. fn: function (aResult) {
  48. var self=this;
  49. smalltalk.send((function(){return smalltalk.send((function(){return smalltalk.send(self, "_perform_", [smalltalk.send(self, "_selector", [])]);}), "_on_do_", [(smalltalk.TestFailure || TestFailure), (function(ex){return smalltalk.send(aResult, "_addFailure_", [self]);})]);}), "_on_do_", [(smalltalk.Error || Error), (function(ex){return smalltalk.send(aResult, "_addError_", [self]);})]);
  50. return self;}
  51. }),
  52. smalltalk.TestCase);
  53. smalltalk.addMethod(
  54. "_runCaseFor_",
  55. smalltalk.method({
  56. selector: "runCaseFor:",
  57. fn: function (aTestResult) {
  58. var self=this;
  59. smalltalk.send(self, "_setUp", []);
  60. smalltalk.send(aTestResult, "_increaseRuns", []);
  61. smalltalk.send(self, "_performTestFor_", [aTestResult]);
  62. smalltalk.send(self, "_tearDown", []);
  63. return self;}
  64. }),
  65. smalltalk.TestCase);
  66. smalltalk.addMethod(
  67. "_selector",
  68. smalltalk.method({
  69. selector: "selector",
  70. fn: function () {
  71. var self=this;
  72. return self['@testSelector'];
  73. return self;}
  74. }),
  75. smalltalk.TestCase);
  76. smalltalk.addMethod(
  77. "_setTestSelector_",
  78. smalltalk.method({
  79. selector: "setTestSelector:",
  80. fn: function (aSelector) {
  81. var self=this;
  82. (self['@testSelector']=aSelector);
  83. return self;}
  84. }),
  85. smalltalk.TestCase);
  86. smalltalk.addMethod(
  87. "_setUp",
  88. smalltalk.method({
  89. selector: "setUp",
  90. fn: function () {
  91. var self=this;
  92. return self;}
  93. }),
  94. smalltalk.TestCase);
  95. smalltalk.addMethod(
  96. "_should_",
  97. smalltalk.method({
  98. selector: "should:",
  99. fn: function (aBlock) {
  100. var self=this;
  101. smalltalk.send(self, "_assert_", [smalltalk.send(aBlock, "_value", [])]);
  102. return self;}
  103. }),
  104. smalltalk.TestCase);
  105. smalltalk.addMethod(
  106. "_should_raise_",
  107. smalltalk.method({
  108. selector: "should:raise:",
  109. fn: function (aBlock, anExceptionClass) {
  110. var self=this;
  111. smalltalk.send(self, "_assert_", [smalltalk.send((function(){smalltalk.send(aBlock, "_value", []);return false;}), "_on_do_", [anExceptionClass, (function(ex){return true;})])]);
  112. return self;}
  113. }),
  114. smalltalk.TestCase);
  115. smalltalk.addMethod(
  116. "_signalFailure_",
  117. smalltalk.method({
  118. selector: "signalFailure:",
  119. fn: function (aString) {
  120. var self=this;
  121. (function($rec){smalltalk.send($rec, "_messageText_", [aString]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.TestFailure || TestFailure), "_new", []));
  122. return self;}
  123. }),
  124. smalltalk.TestCase);
  125. smalltalk.addMethod(
  126. "_tearDown",
  127. smalltalk.method({
  128. selector: "tearDown",
  129. fn: function () {
  130. var self=this;
  131. return self;}
  132. }),
  133. smalltalk.TestCase);
  134. smalltalk.addMethod(
  135. "_allTestSelectors",
  136. smalltalk.method({
  137. selector: "allTestSelectors",
  138. fn: function () {
  139. var self=this;
  140. var selectors=nil;
  141. (selectors=smalltalk.send(self, "_testSelectors", []));
  142. ((($receiver = smalltalk.send(self, "_shouldInheritSelectors", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(selectors, "_addAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_allTestSelectors", [])]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(selectors, "_addAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_allTestSelectors", [])]);})]));
  143. return selectors;
  144. return self;}
  145. }),
  146. smalltalk.TestCase.klass);
  147. smalltalk.addMethod(
  148. "_buildSuite",
  149. smalltalk.method({
  150. selector: "buildSuite",
  151. fn: function () {
  152. var self=this;
  153. return smalltalk.send(smalltalk.send(self, "_allTestSelectors", []), "_collect_", [(function(each){return smalltalk.send(self, "_selector_", [each]);})]);
  154. return self;}
  155. }),
  156. smalltalk.TestCase.klass);
  157. smalltalk.addMethod(
  158. "_isAbstract",
  159. smalltalk.method({
  160. selector: "isAbstract",
  161. fn: function () {
  162. var self=this;
  163. return smalltalk.send(smalltalk.send(self, "_name", []), "__eq", ["TestCase"]);
  164. return self;}
  165. }),
  166. smalltalk.TestCase.klass);
  167. smalltalk.addMethod(
  168. "_lookupHierarchyRoot",
  169. smalltalk.method({
  170. selector: "lookupHierarchyRoot",
  171. fn: function () {
  172. var self=this;
  173. return (smalltalk.TestCase || TestCase);
  174. return self;}
  175. }),
  176. smalltalk.TestCase.klass);
  177. smalltalk.addMethod(
  178. "_selector_",
  179. smalltalk.method({
  180. selector: "selector:",
  181. fn: function (aSelector) {
  182. var self=this;
  183. return (function($rec){smalltalk.send($rec, "_setTestSelector_", [aSelector]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  184. return self;}
  185. }),
  186. smalltalk.TestCase.klass);
  187. smalltalk.addMethod(
  188. "_shouldInheritSelectors",
  189. smalltalk.method({
  190. selector: "shouldInheritSelectors",
  191. fn: function () {
  192. var self=this;
  193. return smalltalk.send(self, "_~_eq", [smalltalk.send(self, "_lookupHierarchyRoot", [])]);
  194. return self;}
  195. }),
  196. smalltalk.TestCase.klass);
  197. smalltalk.addMethod(
  198. "_testSelectors",
  199. smalltalk.method({
  200. selector: "testSelectors",
  201. fn: function () {
  202. var self=this;
  203. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_keys", []), "_select_", [(function(each){return smalltalk.send(each, "_match_", ["^test"]);})]);
  204. return self;}
  205. }),
  206. smalltalk.TestCase.klass);
  207. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  208. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  209. smalltalk.addMethod(
  210. "_addError_",
  211. smalltalk.method({
  212. selector: "addError:",
  213. fn: function (anError) {
  214. var self=this;
  215. smalltalk.send(smalltalk.send(self, "_errors", []), "_add_", [anError]);
  216. return self;}
  217. }),
  218. smalltalk.TestResult);
  219. smalltalk.addMethod(
  220. "_addFailure_",
  221. smalltalk.method({
  222. selector: "addFailure:",
  223. fn: function (aFailure) {
  224. var self=this;
  225. smalltalk.send(smalltalk.send(self, "_failures", []), "_add_", [aFailure]);
  226. return self;}
  227. }),
  228. smalltalk.TestResult);
  229. smalltalk.addMethod(
  230. "_errors",
  231. smalltalk.method({
  232. selector: "errors",
  233. fn: function () {
  234. var self=this;
  235. return self['@errors'];
  236. return self;}
  237. }),
  238. smalltalk.TestResult);
  239. smalltalk.addMethod(
  240. "_failures",
  241. smalltalk.method({
  242. selector: "failures",
  243. fn: function () {
  244. var self=this;
  245. return self['@failures'];
  246. return self;}
  247. }),
  248. smalltalk.TestResult);
  249. smalltalk.addMethod(
  250. "_increaseRuns",
  251. smalltalk.method({
  252. selector: "increaseRuns",
  253. fn: function () {
  254. var self=this;
  255. (self['@runs']=((($receiver = self['@runs']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));
  256. return self;}
  257. }),
  258. smalltalk.TestResult);
  259. smalltalk.addMethod(
  260. "_initialize",
  261. smalltalk.method({
  262. selector: "initialize",
  263. fn: function () {
  264. var self=this;
  265. smalltalk.send(self, "_initialize", [], smalltalk.TestResult.superclass || nil);
  266. (self['@timestamp']=smalltalk.send((smalltalk.Date || Date), "_now", []));
  267. (self['@runs']=(0));
  268. (self['@errors']=smalltalk.send((smalltalk.Array || Array), "_new", []));
  269. (self['@failures']=smalltalk.send((smalltalk.Array || Array), "_new", []));
  270. (self['@total']=(0));
  271. return self;}
  272. }),
  273. smalltalk.TestResult);
  274. smalltalk.addMethod(
  275. "_runs",
  276. smalltalk.method({
  277. selector: "runs",
  278. fn: function () {
  279. var self=this;
  280. return self['@runs'];
  281. return self;}
  282. }),
  283. smalltalk.TestResult);
  284. smalltalk.addMethod(
  285. "_status",
  286. smalltalk.method({
  287. selector: "status",
  288. fn: function () {
  289. var self=this;
  290. return ((($receiver = smalltalk.send(smalltalk.send(self, "_errors", []), "_isEmpty", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return ((($receiver = smalltalk.send(smalltalk.send(self, "_failures", []), "_isEmpty", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "success";})() : (function(){return "failure";})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return "success";}), (function(){return "failure";})]));})() : (function(){return "error";})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return ((($receiver = smalltalk.send(smalltalk.send(self, "_failures", []), "_isEmpty", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "success";})() : (function(){return "failure";})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return "success";}), (function(){return "failure";})]));}), (function(){return "error";})]));
  291. return self;}
  292. }),
  293. smalltalk.TestResult);
  294. smalltalk.addMethod(
  295. "_timestamp",
  296. smalltalk.method({
  297. selector: "timestamp",
  298. fn: function () {
  299. var self=this;
  300. return self['@timestamp'];
  301. return self;}
  302. }),
  303. smalltalk.TestResult);
  304. smalltalk.addMethod(
  305. "_total",
  306. smalltalk.method({
  307. selector: "total",
  308. fn: function () {
  309. var self=this;
  310. return self['@total'];
  311. return self;}
  312. }),
  313. smalltalk.TestResult);
  314. smalltalk.addMethod(
  315. "_total_",
  316. smalltalk.method({
  317. selector: "total:",
  318. fn: function (aNumber) {
  319. var self=this;
  320. (self['@total']=aNumber);
  321. return self;}
  322. }),
  323. smalltalk.TestResult);