2
0

SUnit.deploy.js 29 KB

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