SUnit.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. smalltalk.addPackage('SUnit', {});
  2. smalltalk.addClass('ResultAnnouncement', smalltalk.Object, ['result'], 'SUnit');
  3. smalltalk.addMethod(
  4. "_result",
  5. smalltalk.method({
  6. selector: "result",
  7. category: 'accessing',
  8. fn: function (){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx) { return self["@result"];
  11. }, self, "result", [], smalltalk.ResultAnnouncement)},
  12. args: [],
  13. source: "result\x0a\x09^result",
  14. messageSends: [],
  15. referencedClasses: []
  16. }),
  17. smalltalk.ResultAnnouncement);
  18. smalltalk.addMethod(
  19. "_result_",
  20. smalltalk.method({
  21. selector: "result:",
  22. category: 'accessing',
  23. fn: function (aTestResult){
  24. var self=this;
  25. return smalltalk.withContext(function($ctx) { self["@result"]=aTestResult;
  26. return self}, self, "result:", [aTestResult], smalltalk.ResultAnnouncement)},
  27. args: ["aTestResult"],
  28. source: "result: aTestResult\x0a\x09result := aTestResult",
  29. messageSends: [],
  30. referencedClasses: []
  31. }),
  32. smalltalk.ResultAnnouncement);
  33. smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector'], 'SUnit');
  34. smalltalk.addMethod(
  35. "_assert_",
  36. smalltalk.method({
  37. selector: "assert:",
  38. category: 'testing',
  39. fn: function (aBoolean){
  40. var self=this;
  41. return smalltalk.withContext(function($ctx) { _st(self)._assert_description_(aBoolean,"Assertion failed");
  42. return self}, self, "assert:", [aBoolean], smalltalk.TestCase)},
  43. args: ["aBoolean"],
  44. source: "assert: aBoolean\x0a\x09self assert: aBoolean description: 'Assertion failed'",
  45. messageSends: ["assert:description:"],
  46. referencedClasses: []
  47. }),
  48. smalltalk.TestCase);
  49. smalltalk.addMethod(
  50. "_assert_description_",
  51. smalltalk.method({
  52. selector: "assert:description:",
  53. category: 'testing',
  54. fn: function (aBoolean,aString){
  55. var self=this;
  56. return smalltalk.withContext(function($ctx) { if(! smalltalk.assert(aBoolean)){
  57. _st(self)._signalFailure_(aString);
  58. };
  59. return self}, self, "assert:description:", [aBoolean,aString], smalltalk.TestCase)},
  60. args: ["aBoolean", "aString"],
  61. source: "assert: aBoolean description: aString\x0a\x09aBoolean ifFalse: [self signalFailure: aString]",
  62. messageSends: ["ifFalse:", "signalFailure:"],
  63. referencedClasses: []
  64. }),
  65. smalltalk.TestCase);
  66. smalltalk.addMethod(
  67. "_assert_equals_",
  68. smalltalk.method({
  69. selector: "assert:equals:",
  70. category: 'testing',
  71. fn: function (expected,actual){
  72. var self=this;
  73. return smalltalk.withContext(function($ctx) { var $1;
  74. $1=_st(self)._assert_description_(_st(expected).__eq(actual),_st(_st(_st("Expected: ").__comma(_st(expected)._asString())).__comma(" but was: ")).__comma(_st(actual)._asString()));
  75. return $1;
  76. }, self, "assert:equals:", [expected,actual], smalltalk.TestCase)},
  77. args: ["expected", "actual"],
  78. source: "assert: expected equals: actual\x0a\x09^ self assert: (expected = actual) description: 'Expected: ', expected asString, ' but was: ', actual asString",
  79. messageSends: ["assert:description:", "=", ",", "asString"],
  80. referencedClasses: []
  81. }),
  82. smalltalk.TestCase);
  83. smalltalk.addMethod(
  84. "_deny_",
  85. smalltalk.method({
  86. selector: "deny:",
  87. category: 'testing',
  88. fn: function (aBoolean){
  89. var self=this;
  90. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(aBoolean)._not());
  91. return self}, self, "deny:", [aBoolean], smalltalk.TestCase)},
  92. args: ["aBoolean"],
  93. source: "deny: aBoolean\x0a\x09self assert: aBoolean not",
  94. messageSends: ["assert:", "not"],
  95. referencedClasses: []
  96. }),
  97. smalltalk.TestCase);
  98. smalltalk.addMethod(
  99. "_performTest",
  100. smalltalk.method({
  101. selector: "performTest",
  102. category: 'running',
  103. fn: function (){
  104. var self=this;
  105. return smalltalk.withContext(function($ctx) { _st(self)._perform_(_st(self)._selector());
  106. return self}, self, "performTest", [], smalltalk.TestCase)},
  107. args: [],
  108. source: "performTest\x0a\x09self perform: self selector\x0a",
  109. messageSends: ["perform:", "selector"],
  110. referencedClasses: []
  111. }),
  112. smalltalk.TestCase);
  113. smalltalk.addMethod(
  114. "_runCase",
  115. smalltalk.method({
  116. selector: "runCase",
  117. category: 'running',
  118. fn: function (){
  119. var self=this;
  120. return smalltalk.withContext(function($ctx) { _st((function(){
  121. _st(self)._setUp();
  122. return _st(self)._performTest();
  123. }))._ensure_((function(){
  124. return _st(self)._tearDown();
  125. }));
  126. return self}, self, "runCase", [], smalltalk.TestCase)},
  127. args: [],
  128. source: "runCase\x0a\x09[\x09self setUp.\x0a\x09\x09self performTest ] ensure: [\x0a\x09\x09self tearDown.\x0a\x09\x09\x22self cleanUpInstanceVariables\x22 ]\x0a",
  129. messageSends: ["ensure:", "tearDown", "setUp", "performTest"],
  130. referencedClasses: []
  131. }),
  132. smalltalk.TestCase);
  133. smalltalk.addMethod(
  134. "_selector",
  135. smalltalk.method({
  136. selector: "selector",
  137. category: 'accessing',
  138. fn: function (){
  139. var self=this;
  140. return smalltalk.withContext(function($ctx) { return self["@testSelector"];
  141. }, self, "selector", [], smalltalk.TestCase)},
  142. args: [],
  143. source: "selector\x0a\x09^testSelector",
  144. messageSends: [],
  145. referencedClasses: []
  146. }),
  147. smalltalk.TestCase);
  148. smalltalk.addMethod(
  149. "_setTestSelector_",
  150. smalltalk.method({
  151. selector: "setTestSelector:",
  152. category: 'accessing',
  153. fn: function (aSelector){
  154. var self=this;
  155. return smalltalk.withContext(function($ctx) { self["@testSelector"]=aSelector;
  156. return self}, self, "setTestSelector:", [aSelector], smalltalk.TestCase)},
  157. args: ["aSelector"],
  158. source: "setTestSelector: aSelector\x0a\x09testSelector := aSelector",
  159. messageSends: [],
  160. referencedClasses: []
  161. }),
  162. smalltalk.TestCase);
  163. smalltalk.addMethod(
  164. "_setUp",
  165. smalltalk.method({
  166. selector: "setUp",
  167. category: 'running',
  168. fn: function (){
  169. var self=this;
  170. return smalltalk.withContext(function($ctx) { return self}, self, "setUp", [], smalltalk.TestCase)},
  171. args: [],
  172. source: "setUp",
  173. messageSends: [],
  174. referencedClasses: []
  175. }),
  176. smalltalk.TestCase);
  177. smalltalk.addMethod(
  178. "_should_",
  179. smalltalk.method({
  180. selector: "should:",
  181. category: 'testing',
  182. fn: function (aBlock){
  183. var self=this;
  184. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(aBlock)._value());
  185. return self}, self, "should:", [aBlock], smalltalk.TestCase)},
  186. args: ["aBlock"],
  187. source: "should: aBlock\x0a\x09self assert: aBlock value",
  188. messageSends: ["assert:", "value"],
  189. referencedClasses: []
  190. }),
  191. smalltalk.TestCase);
  192. smalltalk.addMethod(
  193. "_should_raise_",
  194. smalltalk.method({
  195. selector: "should:raise:",
  196. category: 'testing',
  197. fn: function (aBlock,anExceptionClass){
  198. var self=this;
  199. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st((function(){
  200. _st(aBlock)._value();
  201. return false;
  202. }))._on_do_(anExceptionClass,(function(ex){
  203. return true;
  204. })));
  205. return self}, self, "should:raise:", [aBlock,anExceptionClass], smalltalk.TestCase)},
  206. args: ["aBlock", "anExceptionClass"],
  207. source: "should: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. false] \x0a\x09\x09on: anExceptionClass \x0a\x09\x09do: [:ex | true])",
  208. messageSends: ["assert:", "on:do:", "value"],
  209. referencedClasses: []
  210. }),
  211. smalltalk.TestCase);
  212. smalltalk.addMethod(
  213. "_shouldnt_raise_",
  214. smalltalk.method({
  215. selector: "shouldnt:raise:",
  216. category: 'testing',
  217. fn: function (aBlock,anExceptionClass){
  218. var self=this;
  219. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st((function(){
  220. _st(aBlock)._value();
  221. return true;
  222. }))._on_do_(anExceptionClass,(function(ex){
  223. return false;
  224. })));
  225. return self}, self, "shouldnt:raise:", [aBlock,anExceptionClass], smalltalk.TestCase)},
  226. args: ["aBlock", "anExceptionClass"],
  227. source: "shouldnt: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. true] \x0a\x09\x09on: anExceptionClass \x0a\x09\x09do: [:ex | false])",
  228. messageSends: ["assert:", "on:do:", "value"],
  229. referencedClasses: []
  230. }),
  231. smalltalk.TestCase);
  232. smalltalk.addMethod(
  233. "_signalFailure_",
  234. smalltalk.method({
  235. selector: "signalFailure:",
  236. category: 'private',
  237. fn: function (aString){
  238. var self=this;
  239. return smalltalk.withContext(function($ctx) { var $1,$2;
  240. $1=_st((smalltalk.TestFailure || TestFailure))._new();
  241. _st($1)._messageText_(aString);
  242. $2=_st($1)._signal();
  243. return self}, self, "signalFailure:", [aString], smalltalk.TestCase)},
  244. args: ["aString"],
  245. source: "signalFailure: aString\x0a\x09TestFailure new\x0a\x09\x09messageText: aString;\x0a\x09\x09signal",
  246. messageSends: ["messageText:", "new", "signal"],
  247. referencedClasses: ["TestFailure"]
  248. }),
  249. smalltalk.TestCase);
  250. smalltalk.addMethod(
  251. "_tearDown",
  252. smalltalk.method({
  253. selector: "tearDown",
  254. category: 'running',
  255. fn: function (){
  256. var self=this;
  257. return smalltalk.withContext(function($ctx) { return self}, self, "tearDown", [], smalltalk.TestCase)},
  258. args: [],
  259. source: "tearDown",
  260. messageSends: [],
  261. referencedClasses: []
  262. }),
  263. smalltalk.TestCase);
  264. smalltalk.addMethod(
  265. "_allTestSelectors",
  266. smalltalk.method({
  267. selector: "allTestSelectors",
  268. category: 'accessing',
  269. fn: function (){
  270. var self=this;
  271. return smalltalk.withContext(function($ctx) { var $1;
  272. var selectors;
  273. selectors=_st(self)._testSelectors();
  274. $1=_st(self)._shouldInheritSelectors();
  275. if(smalltalk.assert($1)){
  276. _st(selectors)._addAll_(_st(_st(self)._superclass())._allTestSelectors());
  277. };
  278. return selectors;
  279. }, self, "allTestSelectors", [], smalltalk.TestCase.klass)},
  280. args: [],
  281. source: "allTestSelectors\x0a\x09| selectors |\x0a\x09selectors := self testSelectors.\x0a\x09self shouldInheritSelectors ifTrue: [\x0a\x09\x09selectors addAll: self superclass allTestSelectors].\x0a\x09^selectors",
  282. messageSends: ["testSelectors", "ifTrue:", "addAll:", "allTestSelectors", "superclass", "shouldInheritSelectors"],
  283. referencedClasses: []
  284. }),
  285. smalltalk.TestCase.klass);
  286. smalltalk.addMethod(
  287. "_buildSuite",
  288. smalltalk.method({
  289. selector: "buildSuite",
  290. category: 'accessing',
  291. fn: function (){
  292. var self=this;
  293. return smalltalk.withContext(function($ctx) { var $1;
  294. $1=_st(_st(self)._allTestSelectors())._collect_((function(each){
  295. return _st(self)._selector_(each);
  296. }));
  297. return $1;
  298. }, self, "buildSuite", [], smalltalk.TestCase.klass)},
  299. args: [],
  300. source: "buildSuite\x0a\x09^self allTestSelectors collect: [:each | self selector: each]",
  301. messageSends: ["collect:", "selector:", "allTestSelectors"],
  302. referencedClasses: []
  303. }),
  304. smalltalk.TestCase.klass);
  305. smalltalk.addMethod(
  306. "_isAbstract",
  307. smalltalk.method({
  308. selector: "isAbstract",
  309. category: 'testing',
  310. fn: function (){
  311. var self=this;
  312. return smalltalk.withContext(function($ctx) { var $1;
  313. $1=_st(_st(self)._name()).__eq("TestCase");
  314. return $1;
  315. }, self, "isAbstract", [], smalltalk.TestCase.klass)},
  316. args: [],
  317. source: "isAbstract\x0a\x09^ self name = 'TestCase'",
  318. messageSends: ["=", "name"],
  319. referencedClasses: []
  320. }),
  321. smalltalk.TestCase.klass);
  322. smalltalk.addMethod(
  323. "_lookupHierarchyRoot",
  324. smalltalk.method({
  325. selector: "lookupHierarchyRoot",
  326. category: 'accessing',
  327. fn: function (){
  328. var self=this;
  329. return smalltalk.withContext(function($ctx) { return (smalltalk.TestCase || TestCase);
  330. }, self, "lookupHierarchyRoot", [], smalltalk.TestCase.klass)},
  331. args: [],
  332. source: "lookupHierarchyRoot\x0a\x09^TestCase",
  333. messageSends: [],
  334. referencedClasses: ["TestCase"]
  335. }),
  336. smalltalk.TestCase.klass);
  337. smalltalk.addMethod(
  338. "_selector_",
  339. smalltalk.method({
  340. selector: "selector:",
  341. category: 'accessing',
  342. fn: function (aSelector){
  343. var self=this;
  344. return smalltalk.withContext(function($ctx) { var $2,$3,$1;
  345. $2=_st(self)._new();
  346. _st($2)._setTestSelector_(aSelector);
  347. $3=_st($2)._yourself();
  348. $1=$3;
  349. return $1;
  350. }, self, "selector:", [aSelector], smalltalk.TestCase.klass)},
  351. args: ["aSelector"],
  352. source: "selector: aSelector\x0a\x09^self new\x0a\x09\x09setTestSelector: aSelector;\x0a\x09\x09yourself",
  353. messageSends: ["setTestSelector:", "new", "yourself"],
  354. referencedClasses: []
  355. }),
  356. smalltalk.TestCase.klass);
  357. smalltalk.addMethod(
  358. "_shouldInheritSelectors",
  359. smalltalk.method({
  360. selector: "shouldInheritSelectors",
  361. category: 'testing',
  362. fn: function (){
  363. var self=this;
  364. return smalltalk.withContext(function($ctx) { var $1;
  365. $1=_st(self).__tild_eq(_st(self)._lookupHierarchyRoot());
  366. return $1;
  367. }, self, "shouldInheritSelectors", [], smalltalk.TestCase.klass)},
  368. args: [],
  369. source: "shouldInheritSelectors\x0a\x09^self ~= self lookupHierarchyRoot",
  370. messageSends: ["~=", "lookupHierarchyRoot"],
  371. referencedClasses: []
  372. }),
  373. smalltalk.TestCase.klass);
  374. smalltalk.addMethod(
  375. "_testSelectors",
  376. smalltalk.method({
  377. selector: "testSelectors",
  378. category: 'accessing',
  379. fn: function (){
  380. var self=this;
  381. return smalltalk.withContext(function($ctx) { var $1;
  382. $1=_st(_st(_st(self)._methodDictionary())._keys())._select_((function(each){
  383. return _st(each)._match_("^test");
  384. }));
  385. return $1;
  386. }, self, "testSelectors", [], smalltalk.TestCase.klass)},
  387. args: [],
  388. source: "testSelectors\x0a\x09^self methodDictionary keys select: [:each | each match: '^test']",
  389. messageSends: ["select:", "match:", "keys", "methodDictionary"],
  390. referencedClasses: []
  391. }),
  392. smalltalk.TestCase.klass);
  393. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  394. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  395. smalltalk.addMethod(
  396. "_addError_",
  397. smalltalk.method({
  398. selector: "addError:",
  399. category: 'accessing',
  400. fn: function (anError){
  401. var self=this;
  402. return smalltalk.withContext(function($ctx) { _st(_st(self)._errors())._add_(anError);
  403. return self}, self, "addError:", [anError], smalltalk.TestResult)},
  404. args: ["anError"],
  405. source: "addError: anError\x0a\x09self errors add: anError",
  406. messageSends: ["add:", "errors"],
  407. referencedClasses: []
  408. }),
  409. smalltalk.TestResult);
  410. smalltalk.addMethod(
  411. "_addFailure_",
  412. smalltalk.method({
  413. selector: "addFailure:",
  414. category: 'accessing',
  415. fn: function (aFailure){
  416. var self=this;
  417. return smalltalk.withContext(function($ctx) { _st(_st(self)._failures())._add_(aFailure);
  418. return self}, self, "addFailure:", [aFailure], smalltalk.TestResult)},
  419. args: ["aFailure"],
  420. source: "addFailure: aFailure\x0a\x09self failures add: aFailure",
  421. messageSends: ["add:", "failures"],
  422. referencedClasses: []
  423. }),
  424. smalltalk.TestResult);
  425. smalltalk.addMethod(
  426. "_errors",
  427. smalltalk.method({
  428. selector: "errors",
  429. category: 'accessing',
  430. fn: function (){
  431. var self=this;
  432. return smalltalk.withContext(function($ctx) { return self["@errors"];
  433. }, self, "errors", [], smalltalk.TestResult)},
  434. args: [],
  435. source: "errors\x0a\x09^errors",
  436. messageSends: [],
  437. referencedClasses: []
  438. }),
  439. smalltalk.TestResult);
  440. smalltalk.addMethod(
  441. "_failures",
  442. smalltalk.method({
  443. selector: "failures",
  444. category: 'accessing',
  445. fn: function (){
  446. var self=this;
  447. return smalltalk.withContext(function($ctx) { return self["@failures"];
  448. }, self, "failures", [], smalltalk.TestResult)},
  449. args: [],
  450. source: "failures\x0a\x09^failures",
  451. messageSends: [],
  452. referencedClasses: []
  453. }),
  454. smalltalk.TestResult);
  455. smalltalk.addMethod(
  456. "_increaseRuns",
  457. smalltalk.method({
  458. selector: "increaseRuns",
  459. category: 'accessing',
  460. fn: function (){
  461. var self=this;
  462. return smalltalk.withContext(function($ctx) { self["@runs"]=_st(self["@runs"]).__plus((1));
  463. return self}, self, "increaseRuns", [], smalltalk.TestResult)},
  464. args: [],
  465. source: "increaseRuns\x0a\x09runs := runs + 1",
  466. messageSends: ["+"],
  467. referencedClasses: []
  468. }),
  469. smalltalk.TestResult);
  470. smalltalk.addMethod(
  471. "_initialize",
  472. smalltalk.method({
  473. selector: "initialize",
  474. category: 'initialization',
  475. fn: function (){
  476. var self=this;
  477. return smalltalk.withContext(function($ctx) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  478. self["@timestamp"]=_st((smalltalk.Date || Date))._now();
  479. self["@runs"]=(0);
  480. self["@errors"]=_st((smalltalk.Array || Array))._new();
  481. self["@failures"]=_st((smalltalk.Array || Array))._new();
  482. self["@total"]=(0);
  483. return self}, self, "initialize", [], smalltalk.TestResult)},
  484. args: [],
  485. source: "initialize\x0a\x09super initialize.\x0a\x09timestamp := Date now.\x0a\x09runs := 0.\x0a\x09errors := Array new.\x0a\x09failures := Array new.\x0a\x09total := 0",
  486. messageSends: ["initialize", "now", "new"],
  487. referencedClasses: ["Date", "Array"]
  488. }),
  489. smalltalk.TestResult);
  490. smalltalk.addMethod(
  491. "_nextRunDo_",
  492. smalltalk.method({
  493. selector: "nextRunDo:",
  494. category: 'running',
  495. fn: function (aBlock){
  496. var self=this;
  497. return smalltalk.withContext(function($ctx) { var $2,$1;
  498. $2=_st(_st(self)._runs()).__eq_eq(_st(self)._total());
  499. if(! smalltalk.assert($2)){
  500. $1=_st(aBlock)._value_(_st(_st(self)._runs()).__plus((1)));
  501. };
  502. return $1;
  503. }, self, "nextRunDo:", [aBlock], smalltalk.TestResult)},
  504. args: ["aBlock"],
  505. source: "nextRunDo: aBlock\x0a\x22Runs aBlock with index of next run\x0aor does nothing if no more runs\x22\x0a^self runs == self total\x0a\x09ifFalse: [ aBlock value: self runs + 1 ]",
  506. messageSends: ["ifFalse:", "value:", "+", "runs", "==", "total"],
  507. referencedClasses: []
  508. }),
  509. smalltalk.TestResult);
  510. smalltalk.addMethod(
  511. "_runCase_",
  512. smalltalk.method({
  513. selector: "runCase:",
  514. category: 'running',
  515. fn: function (aTestCase){
  516. var self=this;
  517. return smalltalk.withContext(function($ctx) { _st((function(){
  518. return _st((function(){
  519. _st(self)._increaseRuns();
  520. return _st(aTestCase)._runCase();
  521. }))._on_do_((smalltalk.TestFailure || TestFailure),(function(ex){
  522. return _st(self)._addFailure_(aTestCase);
  523. }));
  524. }))._on_do_((smalltalk.Error || Error),(function(ex){
  525. return _st(self)._addError_(aTestCase);
  526. }));
  527. return self}, self, "runCase:", [aTestCase], smalltalk.TestResult)},
  528. args: ["aTestCase"],
  529. source: "runCase: aTestCase\x0a\x09[[\x09self increaseRuns.\x0a \x09aTestCase runCase]\x0a\x09on: TestFailure do: [:ex | self addFailure: aTestCase]]\x0a\x09on: Error do: [:ex | self addError: aTestCase]\x0a",
  530. messageSends: ["on:do:", "addError:", "addFailure:", "increaseRuns", "runCase"],
  531. referencedClasses: ["Error", "TestFailure"]
  532. }),
  533. smalltalk.TestResult);
  534. smalltalk.addMethod(
  535. "_runs",
  536. smalltalk.method({
  537. selector: "runs",
  538. category: 'accessing',
  539. fn: function (){
  540. var self=this;
  541. return smalltalk.withContext(function($ctx) { return self["@runs"];
  542. }, self, "runs", [], smalltalk.TestResult)},
  543. args: [],
  544. source: "runs\x0a\x09^runs",
  545. messageSends: [],
  546. referencedClasses: []
  547. }),
  548. smalltalk.TestResult);
  549. smalltalk.addMethod(
  550. "_status",
  551. smalltalk.method({
  552. selector: "status",
  553. category: 'accessing',
  554. fn: function (){
  555. var self=this;
  556. return smalltalk.withContext(function($ctx) { var $2,$3,$1;
  557. $2=_st(_st(self)._errors())._isEmpty();
  558. if(smalltalk.assert($2)){
  559. $3=_st(_st(self)._failures())._isEmpty();
  560. if(smalltalk.assert($3)){
  561. $1="success";
  562. } else {
  563. $1="failure";
  564. };
  565. } else {
  566. $1="error";
  567. };
  568. return $1;
  569. }, self, "status", [], smalltalk.TestResult)},
  570. args: [],
  571. source: "status\x0a\x09^self errors isEmpty \x0a\x09\x09ifTrue: [\x0a\x09\x09\x09self failures isEmpty \x0a\x09\x09\x09\x09ifTrue: ['success']\x0a\x09\x09\x09\x09ifFalse: ['failure']]\x0a\x09\x09ifFalse: ['error']",
  572. messageSends: ["ifTrue:ifFalse:", "isEmpty", "failures", "errors"],
  573. referencedClasses: []
  574. }),
  575. smalltalk.TestResult);
  576. smalltalk.addMethod(
  577. "_timestamp",
  578. smalltalk.method({
  579. selector: "timestamp",
  580. category: 'accessing',
  581. fn: function (){
  582. var self=this;
  583. return smalltalk.withContext(function($ctx) { return self["@timestamp"];
  584. }, self, "timestamp", [], smalltalk.TestResult)},
  585. args: [],
  586. source: "timestamp\x0a\x09^timestamp",
  587. messageSends: [],
  588. referencedClasses: []
  589. }),
  590. smalltalk.TestResult);
  591. smalltalk.addMethod(
  592. "_total",
  593. smalltalk.method({
  594. selector: "total",
  595. category: 'accessing',
  596. fn: function (){
  597. var self=this;
  598. return smalltalk.withContext(function($ctx) { return self["@total"];
  599. }, self, "total", [], smalltalk.TestResult)},
  600. args: [],
  601. source: "total\x0a\x09^total",
  602. messageSends: [],
  603. referencedClasses: []
  604. }),
  605. smalltalk.TestResult);
  606. smalltalk.addMethod(
  607. "_total_",
  608. smalltalk.method({
  609. selector: "total:",
  610. category: 'accessing',
  611. fn: function (aNumber){
  612. var self=this;
  613. return smalltalk.withContext(function($ctx) { self["@total"]=aNumber;
  614. return self}, self, "total:", [aNumber], smalltalk.TestResult)},
  615. args: ["aNumber"],
  616. source: "total: aNumber\x0a\x09total := aNumber",
  617. messageSends: [],
  618. referencedClasses: []
  619. }),
  620. smalltalk.TestResult);
  621. smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer'], 'SUnit');
  622. smalltalk.addMethod(
  623. "_announcer",
  624. smalltalk.method({
  625. selector: "announcer",
  626. category: 'accessing',
  627. fn: function (){
  628. var self=this;
  629. return smalltalk.withContext(function($ctx) { return self["@announcer"];
  630. }, self, "announcer", [], smalltalk.TestSuiteRunner)},
  631. args: [],
  632. source: "announcer\x0a\x09^announcer",
  633. messageSends: [],
  634. referencedClasses: []
  635. }),
  636. smalltalk.TestSuiteRunner);
  637. smalltalk.addMethod(
  638. "_initialize",
  639. smalltalk.method({
  640. selector: "initialize",
  641. category: 'initialization',
  642. fn: function (){
  643. var self=this;
  644. return smalltalk.withContext(function($ctx) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  645. self["@announcer"]=_st((smalltalk.Announcer || Announcer))._new();
  646. self["@result"]=_st((smalltalk.TestResult || TestResult))._new();
  647. return self}, self, "initialize", [], smalltalk.TestSuiteRunner)},
  648. args: [],
  649. source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new.\x0a result := TestResult new",
  650. messageSends: ["initialize", "new"],
  651. referencedClasses: ["Announcer", "TestResult"]
  652. }),
  653. smalltalk.TestSuiteRunner);
  654. smalltalk.addMethod(
  655. "_result",
  656. smalltalk.method({
  657. selector: "result",
  658. category: 'accessing',
  659. fn: function (){
  660. var self=this;
  661. return smalltalk.withContext(function($ctx) { return self["@result"];
  662. }, self, "result", [], smalltalk.TestSuiteRunner)},
  663. args: [],
  664. source: "result\x0a\x09^result",
  665. messageSends: [],
  666. referencedClasses: []
  667. }),
  668. smalltalk.TestSuiteRunner);
  669. smalltalk.addMethod(
  670. "_run",
  671. smalltalk.method({
  672. selector: "run",
  673. category: 'actions',
  674. fn: function (){
  675. var self=this;
  676. return smalltalk.withContext(function($ctx) { var worker;
  677. _st(self["@result"])._total_(_st(self["@suite"])._size());
  678. _st(self["@announcer"])._announce_(_st(_st((smalltalk.ResultAnnouncement || ResultAnnouncement))._new())._result_(self["@result"]));
  679. worker=(function(){
  680. return _st(self["@result"])._nextRunDo_((function(index){
  681. return _st((function(){
  682. return _st(self["@result"])._runCase_(_st(self["@suite"])._at_(index));
  683. }))._ensure_((function(){
  684. _st(worker)._valueWithTimeout_((0));
  685. return _st(self["@announcer"])._announce_(_st(_st((smalltalk.ResultAnnouncement || ResultAnnouncement))._new())._result_(self["@result"]));
  686. }));
  687. }));
  688. });
  689. _st(_st(_st(self["@suite"])._size())._min_((25)))._timesRepeat_((function(){
  690. return _st(worker)._valueWithTimeout_((0));
  691. }));
  692. return self}, self, "run", [], smalltalk.TestSuiteRunner)},
  693. args: [],
  694. source: "run\x0a\x09| worker |\x0a\x09result total: suite size.\x0a announcer announce: (ResultAnnouncement new result: result).\x0a worker := [ result nextRunDo: [ :index |\x0a\x09\x09[ result runCase: (suite at: index) ]\x0a\x09\x09ensure: [ worker valueWithTimeout: 0.\x0a \x09announcer announce: (ResultAnnouncement new result: result) ]]].\x0a\x09(suite size min: 25) timesRepeat: [ worker valueWithTimeout: 0 ]",
  695. messageSends: ["total:", "size", "announce:", "result:", "new", "nextRunDo:", "ensure:", "valueWithTimeout:", "runCase:", "at:", "timesRepeat:", "min:"],
  696. referencedClasses: ["ResultAnnouncement"]
  697. }),
  698. smalltalk.TestSuiteRunner);
  699. smalltalk.addMethod(
  700. "_suite_",
  701. smalltalk.method({
  702. selector: "suite:",
  703. category: 'accessing',
  704. fn: function (aCollection){
  705. var self=this;
  706. return smalltalk.withContext(function($ctx) { self["@suite"]=aCollection;
  707. return self}, self, "suite:", [aCollection], smalltalk.TestSuiteRunner)},
  708. args: ["aCollection"],
  709. source: "suite: aCollection\x0a\x09suite := aCollection",
  710. messageSends: [],
  711. referencedClasses: []
  712. }),
  713. smalltalk.TestSuiteRunner);
  714. smalltalk.addMethod(
  715. "_new",
  716. smalltalk.method({
  717. selector: "new",
  718. category: 'instance creation',
  719. fn: function (){
  720. var self=this;
  721. return smalltalk.withContext(function($ctx) { _st(self)._shouldNotImplement();
  722. return self}, self, "new", [], smalltalk.TestSuiteRunner.klass)},
  723. args: [],
  724. source: "new\x0a\x09self shouldNotImplement",
  725. messageSends: ["shouldNotImplement"],
  726. referencedClasses: []
  727. }),
  728. smalltalk.TestSuiteRunner.klass);
  729. smalltalk.addMethod(
  730. "_on_",
  731. smalltalk.method({
  732. selector: "on:",
  733. category: 'instance creation',
  734. fn: function (aCollection){
  735. var self=this;
  736. return smalltalk.withContext(function($ctx) { var $1;
  737. $1=_st(smalltalk.Object.klass.fn.prototype._new.apply(_st(self), []))._suite_(aCollection);
  738. return $1;
  739. }, self, "on:", [aCollection], smalltalk.TestSuiteRunner.klass)},
  740. args: ["aCollection"],
  741. source: "on: aCollection\x0a\x09^super new suite: aCollection",
  742. messageSends: ["suite:", "new"],
  743. referencedClasses: []
  744. }),
  745. smalltalk.TestSuiteRunner.klass);