1
0

SUnit.deploy.js 8.9 KB

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