2
0

SUnit.deploy.js 8.9 KB

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