1
0

SUnit.deploy.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  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. messageSends: []}),
  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. messageSends: []}),
  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. messageSends: ["assert:description:"]}),
  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. messageSends: ["ifFalse:", "signalFailure:"]}),
  49. smalltalk.TestCase);
  50. smalltalk.addMethod(
  51. "_assert_equals_",
  52. smalltalk.method({
  53. selector: "assert:equals:",
  54. fn: function (actual,expected){
  55. var self=this;
  56. return smalltalk.withContext(function($ctx1) { var $1;
  57. $1=_st(self)._assert_description_(_st(actual).__eq(expected),_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:",{actual:actual,expected:expected}, smalltalk.TestCase)})},
  60. messageSends: ["assert:description:", "=", ",", "asString"]}),
  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. messageSends: ["errorIfNotAsync:", "ifTrue:", "execute:", "isAsync"]}),
  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. messageSends: []}),
  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. messageSends: ["assert:", "not"]}),
  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. messageSends: ["ifFalse:", "error:", ",", "isAsync"]}),
  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. messageSends: ["errorIfNotAsync:"]}),
  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. messageSends: ["notNil"]}),
  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. messageSends: ["perform:", "selector"]}),
  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. messageSends: ["start", "testCase:"]}),
  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. messageSends: []}),
  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. messageSends: []}),
  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. messageSends: []}),
  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. messageSends: ["assert:", "value"]}),
  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. messageSends: ["assert:", "on:do:", "value"]}),
  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. messageSends: ["assert:", "on:do:", "value"]}),
  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. messageSends: ["messageText:", "new", "signal"]}),
  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. messageSends: []}),
  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. messageSends: ["ifNotNil:", "clearTimeout", "valueWithTimeout:", "async:", "assert:description:"]}),
  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. messageSends: ["testSelectors", "ifTrue:", "addAll:", "allTestSelectors", "superclass", "shouldInheritSelectors"]}),
  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. messageSends: ["collect:", "selector:", "allTestSelectors"]}),
  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. messageSends: ["=", "name"]}),
  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. messageSends: []}),
  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. messageSends: ["setTestSelector:", "new", "yourself"]}),
  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. messageSends: ["~=", "lookupHierarchyRoot"]}),
  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. messageSends: ["select:", "match:", "keys", "methodDictionary"]}),
  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,$2;
  379. _st(self["@testCase"])._context_(self);
  380. _st((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)})}))._ensure_((function(){
  387. return smalltalk.withContext(function($ctx2) { _st(self["@testCase"])._context_(nil);
  388. $1=_st(failed)._and_((function(){
  389. return smalltalk.withContext(function($ctx3) { return _st(self["@testCase"])._isAsync();
  390. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  391. if(smalltalk.assert($1)){
  392. _st(self["@testCase"])._finished();
  393. };
  394. $2=_st(self["@testCase"])._isAsync();
  395. if(! smalltalk.assert($2)){
  396. return _st(self["@testCase"])._tearDown();
  397. };
  398. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  399. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock,failed:failed}, smalltalk.TestContext)})},
  400. messageSends: ["context:", "ensure:", "ifTrue:", "finished", "and:", "isAsync", "ifFalse:", "tearDown", "value"]}),
  401. smalltalk.TestContext);
  402. smalltalk.addMethod(
  403. "_start",
  404. smalltalk.method({
  405. selector: "start",
  406. fn: function (){
  407. var self=this;
  408. return smalltalk.withContext(function($ctx1) { _st(self)._execute_((function(){
  409. return smalltalk.withContext(function($ctx2) { _st(self["@testCase"])._setUp();
  410. return _st(self["@testCase"])._performTest();
  411. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  412. return self}, function($ctx1) {$ctx1.fill(self,"start",{}, smalltalk.TestContext)})},
  413. messageSends: ["execute:", "setUp", "performTest"]}),
  414. smalltalk.TestContext);
  415. smalltalk.addMethod(
  416. "_testCase_",
  417. smalltalk.method({
  418. selector: "testCase:",
  419. fn: function (aTestCase){
  420. var self=this;
  421. return smalltalk.withContext(function($ctx1) { self["@testCase"]=aTestCase;
  422. return self}, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase}, smalltalk.TestContext)})},
  423. messageSends: []}),
  424. smalltalk.TestContext);
  425. smalltalk.addMethod(
  426. "_testCase_",
  427. smalltalk.method({
  428. selector: "testCase:",
  429. fn: function (aTestCase){
  430. var self=this;
  431. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  432. $2=_st(self)._new();
  433. _st($2)._testCase_(aTestCase);
  434. $3=_st($2)._yourself();
  435. $1=$3;
  436. return $1;
  437. }, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase}, smalltalk.TestContext.klass)})},
  438. messageSends: ["testCase:", "new", "yourself"]}),
  439. smalltalk.TestContext.klass);
  440. smalltalk.addClass('ReportingTestContext', smalltalk.TestContext, ['finished', 'result'], 'SUnit');
  441. smalltalk.addMethod(
  442. "_execute_",
  443. smalltalk.method({
  444. selector: "execute:",
  445. fn: function (aBlock){
  446. var self=this;
  447. return smalltalk.withContext(function($ctx1) { var $1;
  448. _st((function(){
  449. return smalltalk.withContext(function($ctx2) { return _st(self)._withErrorReporting_((function(){
  450. return smalltalk.withContext(function($ctx3) { return smalltalk.TestContext.fn.prototype._execute_.apply(_st(self), [aBlock]);
  451. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  452. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  453. return smalltalk.withContext(function($ctx2) { $1=_st(self["@testCase"])._isAsync();
  454. if(! smalltalk.assert($1)){
  455. _st(self["@result"])._increaseRuns();
  456. return _st(self["@finished"])._value();
  457. };
  458. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  459. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
  460. messageSends: ["ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "withErrorReporting:", "execute:"]}),
  461. smalltalk.ReportingTestContext);
  462. smalltalk.addMethod(
  463. "_finished_",
  464. smalltalk.method({
  465. selector: "finished:",
  466. fn: function (aBlock){
  467. var self=this;
  468. return smalltalk.withContext(function($ctx1) { self["@finished"]=aBlock;
  469. return self}, function($ctx1) {$ctx1.fill(self,"finished:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
  470. messageSends: []}),
  471. smalltalk.ReportingTestContext);
  472. smalltalk.addMethod(
  473. "_result_",
  474. smalltalk.method({
  475. selector: "result:",
  476. fn: function (aTestResult){
  477. var self=this;
  478. return smalltalk.withContext(function($ctx1) { self["@result"]=aTestResult;
  479. return self}, function($ctx1) {$ctx1.fill(self,"result:",{aTestResult:aTestResult}, smalltalk.ReportingTestContext)})},
  480. messageSends: []}),
  481. smalltalk.ReportingTestContext);
  482. smalltalk.addMethod(
  483. "_withErrorReporting_",
  484. smalltalk.method({
  485. selector: "withErrorReporting:",
  486. fn: function (aBlock){
  487. var self=this;
  488. return smalltalk.withContext(function($ctx1) { _st((function(){
  489. return smalltalk.withContext(function($ctx2) { return _st(aBlock)._on_do_((smalltalk.TestFailure || TestFailure),(function(ex){
  490. return smalltalk.withContext(function($ctx3) { return _st(self["@result"])._addFailure_(self["@testCase"]);
  491. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  492. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
  493. return smalltalk.withContext(function($ctx2) { return _st(self["@result"])._addError_(self["@testCase"]);
  494. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  495. return self}, function($ctx1) {$ctx1.fill(self,"withErrorReporting:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
  496. messageSends: ["on:do:", "addError:", "addFailure:"]}),
  497. smalltalk.ReportingTestContext);
  498. smalltalk.addMethod(
  499. "_testCase_result_finished_",
  500. smalltalk.method({
  501. selector: "testCase:result:finished:",
  502. fn: function (aTestCase,aTestResult,aBlock){
  503. var self=this;
  504. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  505. $2=smalltalk.TestContext.klass.fn.prototype._testCase_.apply(_st(self), [aTestCase]);
  506. _st($2)._result_(aTestResult);
  507. _st($2)._finished_(aBlock);
  508. $3=_st($2)._yourself();
  509. $1=$3;
  510. return $1;
  511. }, function($ctx1) {$ctx1.fill(self,"testCase:result:finished:",{aTestCase:aTestCase,aTestResult:aTestResult,aBlock:aBlock}, smalltalk.ReportingTestContext.klass)})},
  512. messageSends: ["result:", "testCase:", "finished:", "yourself"]}),
  513. smalltalk.ReportingTestContext.klass);
  514. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  515. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  516. smalltalk.addMethod(
  517. "_addError_",
  518. smalltalk.method({
  519. selector: "addError:",
  520. fn: function (anError){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) { _st(_st(self)._errors())._add_(anError);
  523. return self}, function($ctx1) {$ctx1.fill(self,"addError:",{anError:anError}, smalltalk.TestResult)})},
  524. messageSends: ["add:", "errors"]}),
  525. smalltalk.TestResult);
  526. smalltalk.addMethod(
  527. "_addFailure_",
  528. smalltalk.method({
  529. selector: "addFailure:",
  530. fn: function (aFailure){
  531. var self=this;
  532. return smalltalk.withContext(function($ctx1) { _st(_st(self)._failures())._add_(aFailure);
  533. return self}, function($ctx1) {$ctx1.fill(self,"addFailure:",{aFailure:aFailure}, smalltalk.TestResult)})},
  534. messageSends: ["add:", "failures"]}),
  535. smalltalk.TestResult);
  536. smalltalk.addMethod(
  537. "_errors",
  538. smalltalk.method({
  539. selector: "errors",
  540. fn: function (){
  541. var self=this;
  542. return smalltalk.withContext(function($ctx1) { var $1;
  543. $1=self["@errors"];
  544. return $1;
  545. }, function($ctx1) {$ctx1.fill(self,"errors",{}, smalltalk.TestResult)})},
  546. messageSends: []}),
  547. smalltalk.TestResult);
  548. smalltalk.addMethod(
  549. "_failures",
  550. smalltalk.method({
  551. selector: "failures",
  552. fn: function (){
  553. var self=this;
  554. return smalltalk.withContext(function($ctx1) { var $1;
  555. $1=self["@failures"];
  556. return $1;
  557. }, function($ctx1) {$ctx1.fill(self,"failures",{}, smalltalk.TestResult)})},
  558. messageSends: []}),
  559. smalltalk.TestResult);
  560. smalltalk.addMethod(
  561. "_increaseRuns",
  562. smalltalk.method({
  563. selector: "increaseRuns",
  564. fn: function (){
  565. var self=this;
  566. return smalltalk.withContext(function($ctx1) { self["@runs"]=_st(self["@runs"]).__plus((1));
  567. return self}, function($ctx1) {$ctx1.fill(self,"increaseRuns",{}, smalltalk.TestResult)})},
  568. messageSends: ["+"]}),
  569. smalltalk.TestResult);
  570. smalltalk.addMethod(
  571. "_initialize",
  572. smalltalk.method({
  573. selector: "initialize",
  574. fn: function (){
  575. var self=this;
  576. return smalltalk.withContext(function($ctx1) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  577. self["@timestamp"]=_st((smalltalk.Date || Date))._now();
  578. self["@runs"]=(0);
  579. self["@errors"]=_st((smalltalk.Array || Array))._new();
  580. self["@failures"]=_st((smalltalk.Array || Array))._new();
  581. self["@total"]=(0);
  582. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TestResult)})},
  583. messageSends: ["initialize", "now", "new"]}),
  584. smalltalk.TestResult);
  585. smalltalk.addMethod(
  586. "_nextRunDo_",
  587. smalltalk.method({
  588. selector: "nextRunDo:",
  589. fn: function (aBlock){
  590. var self=this;
  591. return smalltalk.withContext(function($ctx1) { var $2,$1;
  592. $2=_st(_st(self)._runs()).__eq_eq(_st(self)._total());
  593. if(! smalltalk.assert($2)){
  594. $1=_st(aBlock)._value_(_st(_st(self)._runs()).__plus((1)));
  595. };
  596. return $1;
  597. }, function($ctx1) {$ctx1.fill(self,"nextRunDo:",{aBlock:aBlock}, smalltalk.TestResult)})},
  598. messageSends: ["ifFalse:", "value:", "+", "runs", "==", "total"]}),
  599. smalltalk.TestResult);
  600. smalltalk.addMethod(
  601. "_runCase_",
  602. smalltalk.method({
  603. selector: "runCase:",
  604. fn: function (aTestCase){
  605. var self=this;
  606. return smalltalk.withContext(function($ctx1) { _st((function(){
  607. return smalltalk.withContext(function($ctx2) { return _st((function(){
  608. return smalltalk.withContext(function($ctx3) { _st(self)._increaseRuns();
  609. return _st(aTestCase)._runCase();
  610. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_((smalltalk.TestFailure || TestFailure),(function(ex){
  611. return smalltalk.withContext(function($ctx3) { return _st(self)._addFailure_(aTestCase);
  612. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  613. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
  614. return smalltalk.withContext(function($ctx2) { return _st(self)._addError_(aTestCase);
  615. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  616. return self}, function($ctx1) {$ctx1.fill(self,"runCase:",{aTestCase:aTestCase}, smalltalk.TestResult)})},
  617. messageSends: ["on:do:", "addError:", "addFailure:", "increaseRuns", "runCase"]}),
  618. smalltalk.TestResult);
  619. smalltalk.addMethod(
  620. "_runs",
  621. smalltalk.method({
  622. selector: "runs",
  623. fn: function (){
  624. var self=this;
  625. return smalltalk.withContext(function($ctx1) { var $1;
  626. $1=self["@runs"];
  627. return $1;
  628. }, function($ctx1) {$ctx1.fill(self,"runs",{}, smalltalk.TestResult)})},
  629. messageSends: []}),
  630. smalltalk.TestResult);
  631. smalltalk.addMethod(
  632. "_status",
  633. smalltalk.method({
  634. selector: "status",
  635. fn: function (){
  636. var self=this;
  637. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  638. $2=_st(_st(self)._errors())._isEmpty();
  639. if(smalltalk.assert($2)){
  640. $3=_st(_st(self)._failures())._isEmpty();
  641. if(smalltalk.assert($3)){
  642. $1="success";
  643. } else {
  644. $1="failure";
  645. };
  646. } else {
  647. $1="error";
  648. };
  649. return $1;
  650. }, function($ctx1) {$ctx1.fill(self,"status",{}, smalltalk.TestResult)})},
  651. messageSends: ["ifTrue:ifFalse:", "isEmpty", "failures", "errors"]}),
  652. smalltalk.TestResult);
  653. smalltalk.addMethod(
  654. "_timestamp",
  655. smalltalk.method({
  656. selector: "timestamp",
  657. fn: function (){
  658. var self=this;
  659. return smalltalk.withContext(function($ctx1) { var $1;
  660. $1=self["@timestamp"];
  661. return $1;
  662. }, function($ctx1) {$ctx1.fill(self,"timestamp",{}, smalltalk.TestResult)})},
  663. messageSends: []}),
  664. smalltalk.TestResult);
  665. smalltalk.addMethod(
  666. "_total",
  667. smalltalk.method({
  668. selector: "total",
  669. fn: function (){
  670. var self=this;
  671. return smalltalk.withContext(function($ctx1) { var $1;
  672. $1=self["@total"];
  673. return $1;
  674. }, function($ctx1) {$ctx1.fill(self,"total",{}, smalltalk.TestResult)})},
  675. messageSends: []}),
  676. smalltalk.TestResult);
  677. smalltalk.addMethod(
  678. "_total_",
  679. smalltalk.method({
  680. selector: "total:",
  681. fn: function (aNumber){
  682. var self=this;
  683. return smalltalk.withContext(function($ctx1) { self["@total"]=aNumber;
  684. return self}, function($ctx1) {$ctx1.fill(self,"total:",{aNumber:aNumber}, smalltalk.TestResult)})},
  685. messageSends: []}),
  686. smalltalk.TestResult);
  687. smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer', 'runNextTest'], 'SUnit');
  688. smalltalk.addMethod(
  689. "_announcer",
  690. smalltalk.method({
  691. selector: "announcer",
  692. fn: function (){
  693. var self=this;
  694. return smalltalk.withContext(function($ctx1) { var $1;
  695. $1=self["@announcer"];
  696. return $1;
  697. }, function($ctx1) {$ctx1.fill(self,"announcer",{}, smalltalk.TestSuiteRunner)})},
  698. messageSends: []}),
  699. smalltalk.TestSuiteRunner);
  700. smalltalk.addMethod(
  701. "_contextOf_",
  702. smalltalk.method({
  703. selector: "contextOf:",
  704. fn: function (anInteger){
  705. var self=this;
  706. return smalltalk.withContext(function($ctx1) { var $1;
  707. $1=_st((smalltalk.ReportingTestContext || ReportingTestContext))._testCase_result_finished_(_st(self["@suite"])._at_(anInteger),self["@result"],(function(){
  708. return smalltalk.withContext(function($ctx2) { return _st(self)._resume();
  709. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  710. return $1;
  711. }, function($ctx1) {$ctx1.fill(self,"contextOf:",{anInteger:anInteger}, smalltalk.TestSuiteRunner)})},
  712. messageSends: ["testCase:result:finished:", "at:", "resume"]}),
  713. smalltalk.TestSuiteRunner);
  714. smalltalk.addMethod(
  715. "_initialize",
  716. smalltalk.method({
  717. selector: "initialize",
  718. fn: function (){
  719. var self=this;
  720. return smalltalk.withContext(function($ctx1) { var $1;
  721. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  722. self["@announcer"]=_st((smalltalk.Announcer || Announcer))._new();
  723. self["@result"]=_st((smalltalk.TestResult || TestResult))._new();
  724. self["@runNextTest"]=(function(){
  725. var runs;
  726. return smalltalk.withContext(function($ctx2) { runs=_st(self["@result"])._runs();
  727. runs;
  728. $1=_st(runs).__lt(_st(self["@result"])._total());
  729. if(smalltalk.assert($1)){
  730. return _st(_st(self)._contextOf_(_st(runs).__plus((1))))._start();
  731. };
  732. }, function($ctx2) {$ctx2.fillBlock({runs:runs},$ctx1)})});
  733. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TestSuiteRunner)})},
  734. messageSends: ["initialize", "new", "runs", "ifTrue:", "start", "contextOf:", "+", "<", "total"]}),
  735. smalltalk.TestSuiteRunner);
  736. smalltalk.addMethod(
  737. "_result",
  738. smalltalk.method({
  739. selector: "result",
  740. fn: function (){
  741. var self=this;
  742. return smalltalk.withContext(function($ctx1) { var $1;
  743. $1=self["@result"];
  744. return $1;
  745. }, function($ctx1) {$ctx1.fill(self,"result",{}, smalltalk.TestSuiteRunner)})},
  746. messageSends: []}),
  747. smalltalk.TestSuiteRunner);
  748. smalltalk.addMethod(
  749. "_resume",
  750. smalltalk.method({
  751. selector: "resume",
  752. fn: function (){
  753. var self=this;
  754. return smalltalk.withContext(function($ctx1) { _st(self["@runNextTest"])._fork();
  755. _st(self["@announcer"])._announce_(_st(_st((smalltalk.ResultAnnouncement || ResultAnnouncement))._new())._result_(self["@result"]));
  756. return self}, function($ctx1) {$ctx1.fill(self,"resume",{}, smalltalk.TestSuiteRunner)})},
  757. messageSends: ["fork", "announce:", "result:", "new"]}),
  758. smalltalk.TestSuiteRunner);
  759. smalltalk.addMethod(
  760. "_run",
  761. smalltalk.method({
  762. selector: "run",
  763. fn: function (){
  764. var self=this;
  765. return smalltalk.withContext(function($ctx1) { _st(self["@result"])._total_(_st(self["@suite"])._size());
  766. _st(self)._resume();
  767. return self}, function($ctx1) {$ctx1.fill(self,"run",{}, smalltalk.TestSuiteRunner)})},
  768. messageSends: ["total:", "size", "resume"]}),
  769. smalltalk.TestSuiteRunner);
  770. smalltalk.addMethod(
  771. "_suite_",
  772. smalltalk.method({
  773. selector: "suite:",
  774. fn: function (aCollection){
  775. var self=this;
  776. return smalltalk.withContext(function($ctx1) { self["@suite"]=aCollection;
  777. return self}, function($ctx1) {$ctx1.fill(self,"suite:",{aCollection:aCollection}, smalltalk.TestSuiteRunner)})},
  778. messageSends: []}),
  779. smalltalk.TestSuiteRunner);
  780. smalltalk.addMethod(
  781. "_new",
  782. smalltalk.method({
  783. selector: "new",
  784. fn: function (){
  785. var self=this;
  786. return smalltalk.withContext(function($ctx1) { _st(self)._shouldNotImplement();
  787. return self}, function($ctx1) {$ctx1.fill(self,"new",{}, smalltalk.TestSuiteRunner.klass)})},
  788. messageSends: ["shouldNotImplement"]}),
  789. smalltalk.TestSuiteRunner.klass);
  790. smalltalk.addMethod(
  791. "_on_",
  792. smalltalk.method({
  793. selector: "on:",
  794. fn: function (aCollection){
  795. var self=this;
  796. return smalltalk.withContext(function($ctx1) { var $1;
  797. $1=_st(smalltalk.Object.klass.fn.prototype._new.apply(_st(self), []))._suite_(aCollection);
  798. return $1;
  799. }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection}, smalltalk.TestSuiteRunner.klass)})},
  800. messageSends: ["suite:", "new"]}),
  801. smalltalk.TestSuiteRunner.klass);