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