2
0

SUnit.deploy.js 8.5 KB

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