SUnit.deploy.js 27 KB

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