SUnit.deploy.js 18 KB

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