SUnit.js 20 KB

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