SUnit.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector'], 'SUnit');
  2. smalltalk.addMethod(
  3. unescape('_setTestSelector_'),
  4. smalltalk.method({
  5. selector: unescape('setTestSelector%3A'),
  6. category: 'accessing',
  7. fn: function (aSelector){
  8. var self=this;
  9. self['@testSelector']=aSelector;
  10. return self;},
  11. args: ["aSelector"],
  12. source: unescape('setTestSelector%3A%20aSelector%0A%09testSelector%20%3A%3D%20aSelector'),
  13. messageSends: [],
  14. referencedClasses: []
  15. }),
  16. smalltalk.TestCase);
  17. smalltalk.addMethod(
  18. unescape('_selector'),
  19. smalltalk.method({
  20. selector: unescape('selector'),
  21. category: 'accessing',
  22. fn: function (){
  23. var self=this;
  24. return self['@testSelector'];
  25. return self;},
  26. args: [],
  27. source: unescape('selector%0A%09%5EtestSelector'),
  28. messageSends: [],
  29. referencedClasses: []
  30. }),
  31. smalltalk.TestCase);
  32. smalltalk.addMethod(
  33. unescape('_signalFailure_'),
  34. smalltalk.method({
  35. selector: unescape('signalFailure%3A'),
  36. category: 'private',
  37. fn: function (aString){
  38. var self=this;
  39. (function($rec){smalltalk.send($rec, "_messageText_", [aString]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.TestFailure || TestFailure), "_new", []));
  40. return self;},
  41. args: ["aString"],
  42. source: unescape('signalFailure%3A%20aString%0A%09TestFailure%20new%0A%09%09messageText%3A%20aString%3B%0A%09%09signal'),
  43. messageSends: ["messageText:", "signal", "new"],
  44. referencedClasses: []
  45. }),
  46. smalltalk.TestCase);
  47. smalltalk.addMethod(
  48. unescape('_setUp'),
  49. smalltalk.method({
  50. selector: unescape('setUp'),
  51. category: 'running',
  52. fn: function (){
  53. var self=this;
  54. return self;},
  55. args: [],
  56. source: unescape('setUp'),
  57. messageSends: [],
  58. referencedClasses: []
  59. }),
  60. smalltalk.TestCase);
  61. smalltalk.addMethod(
  62. unescape('_tearDown'),
  63. smalltalk.method({
  64. selector: unescape('tearDown'),
  65. category: 'running',
  66. fn: function (){
  67. var self=this;
  68. return self;},
  69. args: [],
  70. source: unescape('tearDown'),
  71. messageSends: [],
  72. referencedClasses: []
  73. }),
  74. smalltalk.TestCase);
  75. smalltalk.addMethod(
  76. unescape('_runCaseFor_'),
  77. smalltalk.method({
  78. selector: unescape('runCaseFor%3A'),
  79. category: 'running',
  80. fn: function (aTestResult){
  81. var self=this;
  82. smalltalk.send(self, "_setUp", []);
  83. smalltalk.send(aTestResult, "_increaseRuns", []);
  84. smalltalk.send(self, "_performTestFor_", [aTestResult]);
  85. smalltalk.send(self, "_tearDown", []);
  86. return self;},
  87. args: ["aTestResult"],
  88. source: unescape('runCaseFor%3A%20aTestResult%0A%09self%20setUp.%0A%09aTestResult%20increaseRuns.%0A%09self%20performTestFor%3A%20aTestResult.%0A%09self%20tearDown'),
  89. messageSends: ["setUp", "increaseRuns", "performTestFor:", "tearDown"],
  90. referencedClasses: []
  91. }),
  92. smalltalk.TestCase);
  93. smalltalk.addMethod(
  94. unescape('_performTestFor_'),
  95. smalltalk.method({
  96. selector: unescape('performTestFor%3A'),
  97. category: 'running',
  98. fn: function (aResult){
  99. var self=this;
  100. 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]);})]);
  101. return self;},
  102. args: ["aResult"],
  103. source: unescape('performTestFor%3A%20aResult%0A%09%5B%5Bself%20perform%3A%20self%20selector%5D%0A%09%09on%3A%20TestFailure%20do%3A%20%5B%3Aex%20%7C%20aResult%20addFailure%3A%20self%5D%5D%0A%09%09on%3A%20Error%20do%3A%20%5B%3Aex%20%7C%20aResult%20addError%3A%20self%5D'),
  104. messageSends: ["on:do:", "perform:", "selector", "addFailure:", "addError:"],
  105. referencedClasses: [smalltalk.Error]
  106. }),
  107. smalltalk.TestCase);
  108. smalltalk.addMethod(
  109. unescape('_assert_'),
  110. smalltalk.method({
  111. selector: unescape('assert%3A'),
  112. category: 'testing',
  113. fn: function (aBoolean){
  114. var self=this;
  115. smalltalk.send(self, "_assert_description_", [aBoolean, "Assertion failed"]);
  116. return self;},
  117. args: ["aBoolean"],
  118. source: unescape('assert%3A%20aBoolean%0A%09self%20assert%3A%20aBoolean%20description%3A%20%27Assertion%20failed%27'),
  119. messageSends: ["assert:description:"],
  120. referencedClasses: []
  121. }),
  122. smalltalk.TestCase);
  123. smalltalk.addMethod(
  124. unescape('_deny_'),
  125. smalltalk.method({
  126. selector: unescape('deny%3A'),
  127. category: 'testing',
  128. fn: function (aBoolean){
  129. var self=this;
  130. smalltalk.send(self, "_assert_", [smalltalk.send(aBoolean, "_not", [])]);
  131. return self;},
  132. args: ["aBoolean"],
  133. source: unescape('deny%3A%20aBoolean%0A%09self%20assert%3A%20aBoolean%20not'),
  134. messageSends: ["assert:", "not"],
  135. referencedClasses: []
  136. }),
  137. smalltalk.TestCase);
  138. smalltalk.addMethod(
  139. unescape('_assert_equals_'),
  140. smalltalk.method({
  141. selector: unescape('assert%3Aequals%3A'),
  142. category: 'testing',
  143. fn: function (expected, actual){
  144. var self=this;
  145. 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", [])])]);
  146. return self;},
  147. args: ["expected", "actual"],
  148. source: unescape('assert%3A%20expected%20equals%3A%20actual%0A%09%5E%20self%20assert%3A%20%28expected%20%3D%20actual%29%20description%3A%20%27Expected%3A%20%27%2C%20expected%20asString%2C%20%27%20but%20was%3A%20%27%2C%20actual%20asString'),
  149. messageSends: ["assert:description:", unescape("%3D"), unescape("%2C"), "asString"],
  150. referencedClasses: []
  151. }),
  152. smalltalk.TestCase);
  153. smalltalk.addMethod(
  154. unescape('_assert_description_'),
  155. smalltalk.method({
  156. selector: unescape('assert%3Adescription%3A'),
  157. category: 'testing',
  158. fn: function (aBoolean, aString){
  159. var self=this;
  160. (($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]);})]);
  161. return self;},
  162. args: ["aBoolean", "aString"],
  163. source: unescape('assert%3A%20aBoolean%20description%3A%20aString%0A%09aBoolean%20ifFalse%3A%20%5Bself%20signalFailure%3A%20aString%5D'),
  164. messageSends: ["ifFalse:", "signalFailure:"],
  165. referencedClasses: []
  166. }),
  167. smalltalk.TestCase);
  168. smalltalk.addMethod(
  169. unescape('_testSelectors'),
  170. smalltalk.method({
  171. selector: unescape('testSelectors'),
  172. category: 'accessing',
  173. fn: function (){
  174. var self=this;
  175. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_methodDictionary", []), "_keys", []), "_select_", [(function(each){return smalltalk.send(each, "_match_", [unescape("%5Etest")]);})]);
  176. return self;},
  177. args: [],
  178. source: unescape('testSelectors%0A%09%5Eself%20methodDictionary%20keys%20select%3A%20%5B%3Aeach%20%7C%20each%20match%3A%20%27%5Etest%27%5D'),
  179. messageSends: ["select:", "keys", "methodDictionary", "match:"],
  180. referencedClasses: []
  181. }),
  182. smalltalk.TestCase.klass);
  183. smalltalk.addMethod(
  184. unescape('_selector_'),
  185. smalltalk.method({
  186. selector: unescape('selector%3A'),
  187. category: 'accessing',
  188. fn: function (aSelector){
  189. var self=this;
  190. return (function($rec){smalltalk.send($rec, "_setTestSelector_", [aSelector]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  191. return self;},
  192. args: ["aSelector"],
  193. source: unescape('selector%3A%20aSelector%0A%09%5Eself%20new%0A%09%09setTestSelector%3A%20aSelector%3B%0A%09%09yourself'),
  194. messageSends: ["setTestSelector:", "yourself", "new"],
  195. referencedClasses: []
  196. }),
  197. smalltalk.TestCase.klass);
  198. smalltalk.addMethod(
  199. unescape('_lookupHierarchyRoot'),
  200. smalltalk.method({
  201. selector: unescape('lookupHierarchyRoot'),
  202. category: 'accessing',
  203. fn: function (){
  204. var self=this;
  205. return (smalltalk.TestCase || TestCase);
  206. return self;},
  207. args: [],
  208. source: unescape('lookupHierarchyRoot%0A%09%5ETestCase'),
  209. messageSends: [],
  210. referencedClasses: [smalltalk.TestCase]
  211. }),
  212. smalltalk.TestCase.klass);
  213. smalltalk.addMethod(
  214. unescape('_allTestSelectors'),
  215. smalltalk.method({
  216. selector: unescape('allTestSelectors'),
  217. category: 'accessing',
  218. fn: function (){
  219. var self=this;
  220. var selectors=nil;
  221. selectors=smalltalk.send(self, "_testSelectors", []);
  222. (($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", [])]);})]);
  223. return selectors;
  224. return self;},
  225. args: [],
  226. source: unescape('allTestSelectors%0A%09%7C%20selectors%20%7C%0A%09selectors%20%3A%3D%20self%20testSelectors.%0A%09self%20shouldInheritSelectors%20ifTrue%3A%20%5B%0A%09%09selectors%20addAll%3A%20self%20superclass%20allTestSelectors%5D.%0A%09%5Eselectors'),
  227. messageSends: ["testSelectors", "ifTrue:", "shouldInheritSelectors", "addAll:", "allTestSelectors", "superclass"],
  228. referencedClasses: []
  229. }),
  230. smalltalk.TestCase.klass);
  231. smalltalk.addMethod(
  232. unescape('_buildSuite'),
  233. smalltalk.method({
  234. selector: unescape('buildSuite'),
  235. category: 'accessing',
  236. fn: function (){
  237. var self=this;
  238. return smalltalk.send(smalltalk.send(self, "_allTestSelectors", []), "_collect_", [(function(each){return smalltalk.send(self, "_selector_", [each]);})]);
  239. return self;},
  240. args: [],
  241. source: unescape('buildSuite%0A%09%5Eself%20allTestSelectors%20collect%3A%20%5B%3Aeach%20%7C%20self%20selector%3A%20each%5D'),
  242. messageSends: ["collect:", "allTestSelectors", "selector:"],
  243. referencedClasses: []
  244. }),
  245. smalltalk.TestCase.klass);
  246. smalltalk.addMethod(
  247. unescape('_shouldInheritSelectors'),
  248. smalltalk.method({
  249. selector: unescape('shouldInheritSelectors'),
  250. category: 'testing',
  251. fn: function (){
  252. var self=this;
  253. return smalltalk.send(self, "_~_eq", [smalltalk.send(self, "_lookupHierarchyRoot", [])]);
  254. return self;},
  255. args: [],
  256. source: unescape('shouldInheritSelectors%0A%09%5Eself%20%7E%3D%20self%20lookupHierarchyRoot'),
  257. messageSends: [unescape("%7E%3D"), "lookupHierarchyRoot"],
  258. referencedClasses: []
  259. }),
  260. smalltalk.TestCase.klass);
  261. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  262. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  263. smalltalk.addMethod(
  264. unescape('_timestamp'),
  265. smalltalk.method({
  266. selector: unescape('timestamp'),
  267. category: 'accessing',
  268. fn: function (){
  269. var self=this;
  270. return self['@timestamp'];
  271. return self;},
  272. args: [],
  273. source: unescape('timestamp%0A%09%5Etimestamp'),
  274. messageSends: [],
  275. referencedClasses: []
  276. }),
  277. smalltalk.TestResult);
  278. smalltalk.addMethod(
  279. unescape('_errors'),
  280. smalltalk.method({
  281. selector: unescape('errors'),
  282. category: 'accessing',
  283. fn: function (){
  284. var self=this;
  285. return self['@errors'];
  286. return self;},
  287. args: [],
  288. source: unescape('errors%0A%09%5Eerrors'),
  289. messageSends: [],
  290. referencedClasses: []
  291. }),
  292. smalltalk.TestResult);
  293. smalltalk.addMethod(
  294. unescape('_failures'),
  295. smalltalk.method({
  296. selector: unescape('failures'),
  297. category: 'accessing',
  298. fn: function (){
  299. var self=this;
  300. return self['@failures'];
  301. return self;},
  302. args: [],
  303. source: unescape('failures%0A%09%5Efailures'),
  304. messageSends: [],
  305. referencedClasses: []
  306. }),
  307. smalltalk.TestResult);
  308. smalltalk.addMethod(
  309. unescape('_total'),
  310. smalltalk.method({
  311. selector: unescape('total'),
  312. category: 'accessing',
  313. fn: function (){
  314. var self=this;
  315. return self['@total'];
  316. return self;},
  317. args: [],
  318. source: unescape('total%0A%09%5Etotal'),
  319. messageSends: [],
  320. referencedClasses: []
  321. }),
  322. smalltalk.TestResult);
  323. smalltalk.addMethod(
  324. unescape('_total_'),
  325. smalltalk.method({
  326. selector: unescape('total%3A'),
  327. category: 'accessing',
  328. fn: function (aNumber){
  329. var self=this;
  330. self['@total']=aNumber;
  331. return self;},
  332. args: ["aNumber"],
  333. source: unescape('total%3A%20aNumber%0A%09total%20%3A%3D%20aNumber'),
  334. messageSends: [],
  335. referencedClasses: []
  336. }),
  337. smalltalk.TestResult);
  338. smalltalk.addMethod(
  339. unescape('_addError_'),
  340. smalltalk.method({
  341. selector: unescape('addError%3A'),
  342. category: 'accessing',
  343. fn: function (anError){
  344. var self=this;
  345. smalltalk.send(smalltalk.send(self, "_errors", []), "_add_", [anError]);
  346. return self;},
  347. args: ["anError"],
  348. source: unescape('addError%3A%20anError%0A%09self%20errors%20add%3A%20anError'),
  349. messageSends: ["add:", "errors"],
  350. referencedClasses: []
  351. }),
  352. smalltalk.TestResult);
  353. smalltalk.addMethod(
  354. unescape('_addFailure_'),
  355. smalltalk.method({
  356. selector: unescape('addFailure%3A'),
  357. category: 'accessing',
  358. fn: function (aFailure){
  359. var self=this;
  360. smalltalk.send(smalltalk.send(self, "_failures", []), "_add_", [aFailure]);
  361. return self;},
  362. args: ["aFailure"],
  363. source: unescape('addFailure%3A%20aFailure%0A%09self%20failures%20add%3A%20aFailure'),
  364. messageSends: ["add:", "failures"],
  365. referencedClasses: []
  366. }),
  367. smalltalk.TestResult);
  368. smalltalk.addMethod(
  369. unescape('_runs'),
  370. smalltalk.method({
  371. selector: unescape('runs'),
  372. category: 'accessing',
  373. fn: function (){
  374. var self=this;
  375. return self['@runs'];
  376. return self;},
  377. args: [],
  378. source: unescape('runs%0A%09%5Eruns'),
  379. messageSends: [],
  380. referencedClasses: []
  381. }),
  382. smalltalk.TestResult);
  383. smalltalk.addMethod(
  384. unescape('_increaseRuns'),
  385. smalltalk.method({
  386. selector: unescape('increaseRuns'),
  387. category: 'accessing',
  388. fn: function (){
  389. var self=this;
  390. self['@runs']=(($receiver = self['@runs']).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]);
  391. return self;},
  392. args: [],
  393. source: unescape('increaseRuns%0A%09runs%20%3A%3D%20runs%20+%201'),
  394. messageSends: [unescape("+")],
  395. referencedClasses: []
  396. }),
  397. smalltalk.TestResult);
  398. smalltalk.addMethod(
  399. unescape('_status'),
  400. smalltalk.method({
  401. selector: unescape('status'),
  402. category: 'accessing',
  403. fn: function (){
  404. var self=this;
  405. 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";})]);
  406. return self;},
  407. args: [],
  408. source: unescape('status%0A%09%5Eself%20errors%20isEmpty%20%0A%09%09ifTrue%3A%20%5B%0A%09%09%09self%20failures%20isEmpty%20%0A%09%09%09%09ifTrue%3A%20%5B%27success%27%5D%0A%09%09%09%09ifFalse%3A%20%5B%27failure%27%5D%5D%0A%09%09ifFalse%3A%20%5B%27error%27%5D'),
  409. messageSends: ["ifTrue:ifFalse:", "isEmpty", "errors", "failures"],
  410. referencedClasses: []
  411. }),
  412. smalltalk.TestResult);
  413. smalltalk.addMethod(
  414. unescape('_initialize'),
  415. smalltalk.method({
  416. selector: unescape('initialize'),
  417. category: 'initialization',
  418. fn: function (){
  419. var self=this;
  420. smalltalk.send(self, "_initialize", [], smalltalk.Object);
  421. self['@timestamp']=smalltalk.send((smalltalk.Date || Date), "_now", []);
  422. self['@runs']=(0);
  423. self['@errors']=smalltalk.send((smalltalk.Array || Array), "_new", []);
  424. self['@failures']=smalltalk.send((smalltalk.Array || Array), "_new", []);
  425. self['@total']=(0);
  426. return self;},
  427. args: [],
  428. source: unescape('initialize%0A%09super%20initialize.%0A%09timestamp%20%3A%3D%20Date%20now.%0A%09runs%20%3A%3D%200.%0A%09errors%20%3A%3D%20Array%20new.%0A%09failures%20%3A%3D%20Array%20new.%0A%09total%20%3A%3D%200'),
  429. messageSends: ["initialize", "now", "new"],
  430. referencedClasses: [smalltalk.Date,smalltalk.Array]
  431. }),
  432. smalltalk.TestResult);