1
0

SUnit.deploy.js 17 KB

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