2
0

SUnit.deploy.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. smalltalk.addPackage('SUnit', {});
  2. smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector'], 'SUnit');
  3. smalltalk.addMethod(
  4. unescape('_assert_'),
  5. smalltalk.method({
  6. selector: unescape('assert%3A'),
  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. unescape('_assert_description_'),
  15. smalltalk.method({
  16. selector: unescape('assert%3Adescription%3A'),
  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. unescape('_assert_equals_'),
  25. smalltalk.method({
  26. selector: unescape('assert%3Aequals%3A'),
  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. unescape('_deny_'),
  35. smalltalk.method({
  36. selector: unescape('deny%3A'),
  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. unescape('_performTestFor_'),
  45. smalltalk.method({
  46. selector: unescape('performTestFor%3A'),
  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. unescape('_runCaseFor_'),
  55. smalltalk.method({
  56. selector: unescape('runCaseFor%3A'),
  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. unescape('_selector'),
  68. smalltalk.method({
  69. selector: unescape('selector'),
  70. fn: function (){
  71. var self=this;
  72. return self['@testSelector'];
  73. return self;}
  74. }),
  75. smalltalk.TestCase);
  76. smalltalk.addMethod(
  77. unescape('_setTestSelector_'),
  78. smalltalk.method({
  79. selector: unescape('setTestSelector%3A'),
  80. fn: function (aSelector){
  81. var self=this;
  82. (self['@testSelector']=aSelector);
  83. return self;}
  84. }),
  85. smalltalk.TestCase);
  86. smalltalk.addMethod(
  87. unescape('_setUp'),
  88. smalltalk.method({
  89. selector: unescape('setUp'),
  90. fn: function (){
  91. var self=this;
  92. return self;}
  93. }),
  94. smalltalk.TestCase);
  95. smalltalk.addMethod(
  96. unescape('_should_'),
  97. smalltalk.method({
  98. selector: unescape('should%3A'),
  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. unescape('_should_raise_'),
  107. smalltalk.method({
  108. selector: unescape('should%3Araise%3A'),
  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. unescape('_signalFailure_'),
  117. smalltalk.method({
  118. selector: unescape('signalFailure%3A'),
  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. unescape('_tearDown'),
  127. smalltalk.method({
  128. selector: unescape('tearDown'),
  129. fn: function (){
  130. var self=this;
  131. return self;}
  132. }),
  133. smalltalk.TestCase);
  134. smalltalk.addMethod(
  135. unescape('_allTestSelectors'),
  136. smalltalk.method({
  137. selector: unescape('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. unescape('_buildSuite'),
  149. smalltalk.method({
  150. selector: unescape('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. unescape('_lookupHierarchyRoot'),
  159. smalltalk.method({
  160. selector: unescape('lookupHierarchyRoot'),
  161. fn: function (){
  162. var self=this;
  163. return (smalltalk.TestCase || TestCase);
  164. return self;}
  165. }),
  166. smalltalk.TestCase.klass);
  167. smalltalk.addMethod(
  168. unescape('_selector_'),
  169. smalltalk.method({
  170. selector: unescape('selector%3A'),
  171. fn: function (aSelector){
  172. var self=this;
  173. return (function($rec){smalltalk.send($rec, "_setTestSelector_", [aSelector]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  174. return self;}
  175. }),
  176. smalltalk.TestCase.klass);
  177. smalltalk.addMethod(
  178. unescape('_shouldInheritSelectors'),
  179. smalltalk.method({
  180. selector: unescape('shouldInheritSelectors'),
  181. fn: function (){
  182. var self=this;
  183. return smalltalk.send(self, "_~_eq", [smalltalk.send(self, "_lookupHierarchyRoot", [])]);
  184. return self;}
  185. }),
  186. smalltalk.TestCase.klass);
  187. smalltalk.addMethod(
  188. unescape('_testSelectors'),
  189. smalltalk.method({
  190. selector: unescape('testSelectors'),
  191. fn: function (){
  192. var self=this;
  193. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_keys", []), "_select_", [(function(each){return smalltalk.send(each, "_match_", [unescape("%5Etest")]);})]);
  194. return self;}
  195. }),
  196. smalltalk.TestCase.klass);
  197. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  198. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  199. smalltalk.addMethod(
  200. unescape('_addError_'),
  201. smalltalk.method({
  202. selector: unescape('addError%3A'),
  203. fn: function (anError){
  204. var self=this;
  205. smalltalk.send(smalltalk.send(self, "_errors", []), "_add_", [anError]);
  206. return self;}
  207. }),
  208. smalltalk.TestResult);
  209. smalltalk.addMethod(
  210. unescape('_addFailure_'),
  211. smalltalk.method({
  212. selector: unescape('addFailure%3A'),
  213. fn: function (aFailure){
  214. var self=this;
  215. smalltalk.send(smalltalk.send(self, "_failures", []), "_add_", [aFailure]);
  216. return self;}
  217. }),
  218. smalltalk.TestResult);
  219. smalltalk.addMethod(
  220. unescape('_errors'),
  221. smalltalk.method({
  222. selector: unescape('errors'),
  223. fn: function (){
  224. var self=this;
  225. return self['@errors'];
  226. return self;}
  227. }),
  228. smalltalk.TestResult);
  229. smalltalk.addMethod(
  230. unescape('_failures'),
  231. smalltalk.method({
  232. selector: unescape('failures'),
  233. fn: function (){
  234. var self=this;
  235. return self['@failures'];
  236. return self;}
  237. }),
  238. smalltalk.TestResult);
  239. smalltalk.addMethod(
  240. unescape('_increaseRuns'),
  241. smalltalk.method({
  242. selector: unescape('increaseRuns'),
  243. fn: function (){
  244. var self=this;
  245. (self['@runs']=((($receiver = self['@runs']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));
  246. return self;}
  247. }),
  248. smalltalk.TestResult);
  249. smalltalk.addMethod(
  250. unescape('_initialize'),
  251. smalltalk.method({
  252. selector: unescape('initialize'),
  253. fn: function (){
  254. var self=this;
  255. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  256. (self['@timestamp']=smalltalk.send((smalltalk.Date || Date), "_now", []));
  257. (self['@runs']=(0));
  258. (self['@errors']=smalltalk.send((smalltalk.Array || Array), "_new", []));
  259. (self['@failures']=smalltalk.send((smalltalk.Array || Array), "_new", []));
  260. (self['@total']=(0));
  261. return self;}
  262. }),
  263. smalltalk.TestResult);
  264. smalltalk.addMethod(
  265. unescape('_runs'),
  266. smalltalk.method({
  267. selector: unescape('runs'),
  268. fn: function (){
  269. var self=this;
  270. return self['@runs'];
  271. return self;}
  272. }),
  273. smalltalk.TestResult);
  274. smalltalk.addMethod(
  275. unescape('_status'),
  276. smalltalk.method({
  277. selector: unescape('status'),
  278. fn: function (){
  279. var self=this;
  280. 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";})]));
  281. return self;}
  282. }),
  283. smalltalk.TestResult);
  284. smalltalk.addMethod(
  285. unescape('_timestamp'),
  286. smalltalk.method({
  287. selector: unescape('timestamp'),
  288. fn: function (){
  289. var self=this;
  290. return self['@timestamp'];
  291. return self;}
  292. }),
  293. smalltalk.TestResult);
  294. smalltalk.addMethod(
  295. unescape('_total'),
  296. smalltalk.method({
  297. selector: unescape('total'),
  298. fn: function (){
  299. var self=this;
  300. return self['@total'];
  301. return self;}
  302. }),
  303. smalltalk.TestResult);
  304. smalltalk.addMethod(
  305. unescape('_total_'),
  306. smalltalk.method({
  307. selector: unescape('total%3A'),
  308. fn: function (aNumber){
  309. var self=this;
  310. (self['@total']=aNumber);
  311. return self;}
  312. }),
  313. smalltalk.TestResult);