SUnit.deploy.js 30 KB

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