2
0

SUnit.deploy.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  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. _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. 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. _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. 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=_st(self)._assert_description_(_st(actual).__eq(expected),_st(_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. _st(self)._errorIfNotAsync_("#async");
  71. c=self["@context"];
  72. $1=(function(){
  73. return smalltalk.withContext(function($ctx2) {
  74. $2=_st(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. _st(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=_st(self)._isAsync();
  111. if(! smalltalk.assert($1)){
  112. _st(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. _st(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. _st(self)._perform_(_st(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. _st(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. _st(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. _st(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(_st(self)._async_((function(){
  275. return smalltalk.withContext(function($ctx2) {
  276. return _st(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=_st(self)._testSelectors();
  290. $1=_st(self)._shouldInheritSelectors();
  291. if(smalltalk.assert($1)){
  292. _st(selectors)._addAll_(_st(_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(_st(self)._allTestSelectors())._collect_((function(each){
  307. return smalltalk.withContext(function($ctx2) {
  308. return _st(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: "isAbstract",
  317. fn: function (){
  318. var self=this;
  319. return smalltalk.withContext(function($ctx1) {
  320. var $1;
  321. $1=_st(_st(self)._name()).__eq("TestCase");
  322. return $1;
  323. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.TestCase.klass)})},
  324. messageSends: ["=", "name"]}),
  325. smalltalk.TestCase.klass);
  326. smalltalk.addMethod(
  327. smalltalk.method({
  328. selector: "lookupHierarchyRoot",
  329. fn: function (){
  330. var self=this;
  331. function $TestCase(){return smalltalk.TestCase||(typeof TestCase=="undefined"?nil:TestCase)}
  332. return smalltalk.withContext(function($ctx1) {
  333. var $1;
  334. $1=$TestCase();
  335. return $1;
  336. }, function($ctx1) {$ctx1.fill(self,"lookupHierarchyRoot",{},smalltalk.TestCase.klass)})},
  337. messageSends: []}),
  338. smalltalk.TestCase.klass);
  339. smalltalk.addMethod(
  340. smalltalk.method({
  341. selector: "selector:",
  342. fn: function (aSelector){
  343. var self=this;
  344. return smalltalk.withContext(function($ctx1) {
  345. var $2,$3,$1;
  346. $2=_st(self)._new();
  347. _st($2)._setTestSelector_(aSelector);
  348. $3=_st($2)._yourself();
  349. $1=$3;
  350. return $1;
  351. }, function($ctx1) {$ctx1.fill(self,"selector:",{aSelector:aSelector},smalltalk.TestCase.klass)})},
  352. messageSends: ["setTestSelector:", "new", "yourself"]}),
  353. smalltalk.TestCase.klass);
  354. smalltalk.addMethod(
  355. smalltalk.method({
  356. selector: "shouldInheritSelectors",
  357. fn: function (){
  358. var self=this;
  359. return smalltalk.withContext(function($ctx1) {
  360. var $1;
  361. $1=_st(self).__tild_eq(_st(self)._lookupHierarchyRoot());
  362. return $1;
  363. }, function($ctx1) {$ctx1.fill(self,"shouldInheritSelectors",{},smalltalk.TestCase.klass)})},
  364. messageSends: ["~=", "lookupHierarchyRoot"]}),
  365. smalltalk.TestCase.klass);
  366. smalltalk.addMethod(
  367. smalltalk.method({
  368. selector: "testSelectors",
  369. fn: function (){
  370. var self=this;
  371. return smalltalk.withContext(function($ctx1) {
  372. var $1;
  373. $1=_st(_st(_st(self)._methodDictionary())._keys())._select_((function(each){
  374. return smalltalk.withContext(function($ctx2) {
  375. return _st(each)._match_("^test");
  376. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  377. return $1;
  378. }, function($ctx1) {$ctx1.fill(self,"testSelectors",{},smalltalk.TestCase.klass)})},
  379. messageSends: ["select:", "match:", "keys", "methodDictionary"]}),
  380. smalltalk.TestCase.klass);
  381. smalltalk.addClass('TestContext', smalltalk.Object, ['testCase'], 'SUnit');
  382. smalltalk.addMethod(
  383. smalltalk.method({
  384. selector: "execute:",
  385. fn: function (aBlock){
  386. var self=this;
  387. var failed;
  388. return smalltalk.withContext(function($ctx1) {
  389. var $1,$2;
  390. _st(self["@testCase"])._context_(self);
  391. _st((function(){
  392. return smalltalk.withContext(function($ctx2) {
  393. failed=true;
  394. failed;
  395. _st(aBlock)._value();
  396. failed=false;
  397. return failed;
  398. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  399. return smalltalk.withContext(function($ctx2) {
  400. _st(self["@testCase"])._context_(nil);
  401. $1=_st(failed)._and_((function(){
  402. return smalltalk.withContext(function($ctx3) {
  403. return _st(self["@testCase"])._isAsync();
  404. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  405. if(smalltalk.assert($1)){
  406. _st(self["@testCase"])._finished();
  407. };
  408. $2=_st(self["@testCase"])._isAsync();
  409. if(! smalltalk.assert($2)){
  410. return _st(self["@testCase"])._tearDown();
  411. };
  412. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  413. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock,failed:failed},smalltalk.TestContext)})},
  414. messageSends: ["context:", "ensure:", "ifTrue:", "finished", "and:", "isAsync", "ifFalse:", "tearDown", "value"]}),
  415. smalltalk.TestContext);
  416. smalltalk.addMethod(
  417. smalltalk.method({
  418. selector: "start",
  419. fn: function (){
  420. var self=this;
  421. return smalltalk.withContext(function($ctx1) {
  422. _st(self)._execute_((function(){
  423. return smalltalk.withContext(function($ctx2) {
  424. _st(self["@testCase"])._setUp();
  425. return _st(self["@testCase"])._performTest();
  426. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  427. return self}, function($ctx1) {$ctx1.fill(self,"start",{},smalltalk.TestContext)})},
  428. messageSends: ["execute:", "setUp", "performTest"]}),
  429. smalltalk.TestContext);
  430. smalltalk.addMethod(
  431. smalltalk.method({
  432. selector: "testCase:",
  433. fn: function (aTestCase){
  434. var self=this;
  435. return smalltalk.withContext(function($ctx1) {
  436. self["@testCase"]=aTestCase;
  437. return self}, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase},smalltalk.TestContext)})},
  438. messageSends: []}),
  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. var $2,$3,$1;
  447. $2=_st(self)._new();
  448. _st($2)._testCase_(aTestCase);
  449. $3=_st($2)._yourself();
  450. $1=$3;
  451. return $1;
  452. }, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase},smalltalk.TestContext.klass)})},
  453. messageSends: ["testCase:", "new", "yourself"]}),
  454. smalltalk.TestContext.klass);
  455. smalltalk.addClass('ReportingTestContext', smalltalk.TestContext, ['finished', 'result'], 'SUnit');
  456. smalltalk.addMethod(
  457. smalltalk.method({
  458. selector: "execute:",
  459. fn: function (aBlock){
  460. var self=this;
  461. return smalltalk.withContext(function($ctx1) {
  462. var $1;
  463. _st((function(){
  464. return smalltalk.withContext(function($ctx2) {
  465. return _st(self)._withErrorReporting_((function(){
  466. return smalltalk.withContext(function($ctx3) {
  467. return smalltalk.TestContext.fn.prototype._execute_.apply(_st(self), [aBlock]);
  468. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  469. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  470. return smalltalk.withContext(function($ctx2) {
  471. $1=_st(self["@testCase"])._isAsync();
  472. if(! smalltalk.assert($1)){
  473. _st(self["@result"])._increaseRuns();
  474. return _st(self["@finished"])._value();
  475. };
  476. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  477. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock},smalltalk.ReportingTestContext)})},
  478. messageSends: ["ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "withErrorReporting:", "execute:"]}),
  479. smalltalk.ReportingTestContext);
  480. smalltalk.addMethod(
  481. smalltalk.method({
  482. selector: "finished:",
  483. fn: function (aBlock){
  484. var self=this;
  485. return smalltalk.withContext(function($ctx1) {
  486. self["@finished"]=aBlock;
  487. return self}, function($ctx1) {$ctx1.fill(self,"finished:",{aBlock:aBlock},smalltalk.ReportingTestContext)})},
  488. messageSends: []}),
  489. smalltalk.ReportingTestContext);
  490. smalltalk.addMethod(
  491. smalltalk.method({
  492. selector: "result:",
  493. fn: function (aTestResult){
  494. var self=this;
  495. return smalltalk.withContext(function($ctx1) {
  496. self["@result"]=aTestResult;
  497. return self}, function($ctx1) {$ctx1.fill(self,"result:",{aTestResult:aTestResult},smalltalk.ReportingTestContext)})},
  498. messageSends: []}),
  499. smalltalk.ReportingTestContext);
  500. smalltalk.addMethod(
  501. smalltalk.method({
  502. selector: "withErrorReporting:",
  503. fn: function (aBlock){
  504. var self=this;
  505. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  506. function $TestFailure(){return smalltalk.TestFailure||(typeof TestFailure=="undefined"?nil:TestFailure)}
  507. return smalltalk.withContext(function($ctx1) {
  508. _st((function(){
  509. return smalltalk.withContext(function($ctx2) {
  510. return _st(aBlock)._on_do_($TestFailure(),(function(ex){
  511. return smalltalk.withContext(function($ctx3) {
  512. return _st(self["@result"])._addFailure_(self["@testCase"]);
  513. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  514. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(ex){
  515. return smalltalk.withContext(function($ctx2) {
  516. return _st(self["@result"])._addError_(self["@testCase"]);
  517. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  518. return self}, function($ctx1) {$ctx1.fill(self,"withErrorReporting:",{aBlock:aBlock},smalltalk.ReportingTestContext)})},
  519. messageSends: ["on:do:", "addError:", "addFailure:"]}),
  520. smalltalk.ReportingTestContext);
  521. smalltalk.addMethod(
  522. smalltalk.method({
  523. selector: "testCase:result:finished:",
  524. fn: function (aTestCase,aTestResult,aBlock){
  525. var self=this;
  526. return smalltalk.withContext(function($ctx1) {
  527. var $2,$3,$1;
  528. $2=smalltalk.TestContext.klass.fn.prototype._testCase_.apply(_st(self), [aTestCase]);
  529. _st($2)._result_(aTestResult);
  530. _st($2)._finished_(aBlock);
  531. $3=_st($2)._yourself();
  532. $1=$3;
  533. return $1;
  534. }, function($ctx1) {$ctx1.fill(self,"testCase:result:finished:",{aTestCase:aTestCase,aTestResult:aTestResult,aBlock:aBlock},smalltalk.ReportingTestContext.klass)})},
  535. messageSends: ["result:", "testCase:", "finished:", "yourself"]}),
  536. smalltalk.ReportingTestContext.klass);
  537. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  538. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  539. smalltalk.addMethod(
  540. smalltalk.method({
  541. selector: "addError:",
  542. fn: function (anError){
  543. var self=this;
  544. return smalltalk.withContext(function($ctx1) {
  545. _st(_st(self)._errors())._add_(anError);
  546. return self}, function($ctx1) {$ctx1.fill(self,"addError:",{anError:anError},smalltalk.TestResult)})},
  547. messageSends: ["add:", "errors"]}),
  548. smalltalk.TestResult);
  549. smalltalk.addMethod(
  550. smalltalk.method({
  551. selector: "addFailure:",
  552. fn: function (aFailure){
  553. var self=this;
  554. return smalltalk.withContext(function($ctx1) {
  555. _st(_st(self)._failures())._add_(aFailure);
  556. return self}, function($ctx1) {$ctx1.fill(self,"addFailure:",{aFailure:aFailure},smalltalk.TestResult)})},
  557. messageSends: ["add:", "failures"]}),
  558. smalltalk.TestResult);
  559. smalltalk.addMethod(
  560. smalltalk.method({
  561. selector: "errors",
  562. fn: function (){
  563. var self=this;
  564. return smalltalk.withContext(function($ctx1) {
  565. var $1;
  566. $1=self["@errors"];
  567. return $1;
  568. }, function($ctx1) {$ctx1.fill(self,"errors",{},smalltalk.TestResult)})},
  569. messageSends: []}),
  570. smalltalk.TestResult);
  571. smalltalk.addMethod(
  572. smalltalk.method({
  573. selector: "failures",
  574. fn: function (){
  575. var self=this;
  576. return smalltalk.withContext(function($ctx1) {
  577. var $1;
  578. $1=self["@failures"];
  579. return $1;
  580. }, function($ctx1) {$ctx1.fill(self,"failures",{},smalltalk.TestResult)})},
  581. messageSends: []}),
  582. smalltalk.TestResult);
  583. smalltalk.addMethod(
  584. smalltalk.method({
  585. selector: "increaseRuns",
  586. fn: function (){
  587. var self=this;
  588. return smalltalk.withContext(function($ctx1) {
  589. self["@runs"]=_st(self["@runs"]).__plus((1));
  590. return self}, function($ctx1) {$ctx1.fill(self,"increaseRuns",{},smalltalk.TestResult)})},
  591. messageSends: ["+"]}),
  592. smalltalk.TestResult);
  593. smalltalk.addMethod(
  594. smalltalk.method({
  595. selector: "initialize",
  596. fn: function (){
  597. var self=this;
  598. function $Date(){return smalltalk.Date||(typeof Date=="undefined"?nil:Date)}
  599. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  600. return smalltalk.withContext(function($ctx1) {
  601. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  602. self["@timestamp"]=_st($Date())._now();
  603. self["@runs"]=(0);
  604. self["@errors"]=_st($Array())._new();
  605. self["@failures"]=_st($Array())._new();
  606. self["@total"]=(0);
  607. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TestResult)})},
  608. messageSends: ["initialize", "now", "new"]}),
  609. smalltalk.TestResult);
  610. smalltalk.addMethod(
  611. smalltalk.method({
  612. selector: "nextRunDo:",
  613. fn: function (aBlock){
  614. var self=this;
  615. return smalltalk.withContext(function($ctx1) {
  616. var $2,$1;
  617. $2=_st(_st(self)._runs()).__eq_eq(_st(self)._total());
  618. if(! smalltalk.assert($2)){
  619. $1=_st(aBlock)._value_(_st(_st(self)._runs()).__plus((1)));
  620. };
  621. return $1;
  622. }, function($ctx1) {$ctx1.fill(self,"nextRunDo:",{aBlock:aBlock},smalltalk.TestResult)})},
  623. messageSends: ["ifFalse:", "value:", "+", "runs", "==", "total"]}),
  624. smalltalk.TestResult);
  625. smalltalk.addMethod(
  626. smalltalk.method({
  627. selector: "runCase:",
  628. fn: function (aTestCase){
  629. var self=this;
  630. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  631. function $TestFailure(){return smalltalk.TestFailure||(typeof TestFailure=="undefined"?nil:TestFailure)}
  632. return smalltalk.withContext(function($ctx1) {
  633. _st((function(){
  634. return smalltalk.withContext(function($ctx2) {
  635. return _st((function(){
  636. return smalltalk.withContext(function($ctx3) {
  637. _st(self)._increaseRuns();
  638. return _st(aTestCase)._runCase();
  639. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_($TestFailure(),(function(ex){
  640. return smalltalk.withContext(function($ctx3) {
  641. return _st(self)._addFailure_(aTestCase);
  642. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  643. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(ex){
  644. return smalltalk.withContext(function($ctx2) {
  645. return _st(self)._addError_(aTestCase);
  646. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  647. return self}, function($ctx1) {$ctx1.fill(self,"runCase:",{aTestCase:aTestCase},smalltalk.TestResult)})},
  648. messageSends: ["on:do:", "addError:", "addFailure:", "increaseRuns", "runCase"]}),
  649. smalltalk.TestResult);
  650. smalltalk.addMethod(
  651. smalltalk.method({
  652. selector: "runs",
  653. fn: function (){
  654. var self=this;
  655. return smalltalk.withContext(function($ctx1) {
  656. var $1;
  657. $1=self["@runs"];
  658. return $1;
  659. }, function($ctx1) {$ctx1.fill(self,"runs",{},smalltalk.TestResult)})},
  660. messageSends: []}),
  661. smalltalk.TestResult);
  662. smalltalk.addMethod(
  663. smalltalk.method({
  664. selector: "status",
  665. fn: function (){
  666. var self=this;
  667. return smalltalk.withContext(function($ctx1) {
  668. var $2,$3,$1;
  669. $2=_st(_st(self)._errors())._isEmpty();
  670. if(smalltalk.assert($2)){
  671. $3=_st(_st(self)._failures())._isEmpty();
  672. if(smalltalk.assert($3)){
  673. $1="success";
  674. } else {
  675. $1="failure";
  676. };
  677. } else {
  678. $1="error";
  679. };
  680. return $1;
  681. }, function($ctx1) {$ctx1.fill(self,"status",{},smalltalk.TestResult)})},
  682. messageSends: ["ifTrue:ifFalse:", "isEmpty", "failures", "errors"]}),
  683. smalltalk.TestResult);
  684. smalltalk.addMethod(
  685. smalltalk.method({
  686. selector: "timestamp",
  687. fn: function (){
  688. var self=this;
  689. return smalltalk.withContext(function($ctx1) {
  690. var $1;
  691. $1=self["@timestamp"];
  692. return $1;
  693. }, function($ctx1) {$ctx1.fill(self,"timestamp",{},smalltalk.TestResult)})},
  694. messageSends: []}),
  695. smalltalk.TestResult);
  696. smalltalk.addMethod(
  697. smalltalk.method({
  698. selector: "total",
  699. fn: function (){
  700. var self=this;
  701. return smalltalk.withContext(function($ctx1) {
  702. var $1;
  703. $1=self["@total"];
  704. return $1;
  705. }, function($ctx1) {$ctx1.fill(self,"total",{},smalltalk.TestResult)})},
  706. messageSends: []}),
  707. smalltalk.TestResult);
  708. smalltalk.addMethod(
  709. smalltalk.method({
  710. selector: "total:",
  711. fn: function (aNumber){
  712. var self=this;
  713. return smalltalk.withContext(function($ctx1) {
  714. self["@total"]=aNumber;
  715. return self}, function($ctx1) {$ctx1.fill(self,"total:",{aNumber:aNumber},smalltalk.TestResult)})},
  716. messageSends: []}),
  717. smalltalk.TestResult);
  718. smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer', 'runNextTest'], 'SUnit');
  719. smalltalk.addMethod(
  720. smalltalk.method({
  721. selector: "announcer",
  722. fn: function (){
  723. var self=this;
  724. return smalltalk.withContext(function($ctx1) {
  725. var $1;
  726. $1=self["@announcer"];
  727. return $1;
  728. }, function($ctx1) {$ctx1.fill(self,"announcer",{},smalltalk.TestSuiteRunner)})},
  729. messageSends: []}),
  730. smalltalk.TestSuiteRunner);
  731. smalltalk.addMethod(
  732. smalltalk.method({
  733. selector: "contextOf:",
  734. fn: function (anInteger){
  735. var self=this;
  736. function $ReportingTestContext(){return smalltalk.ReportingTestContext||(typeof ReportingTestContext=="undefined"?nil:ReportingTestContext)}
  737. return smalltalk.withContext(function($ctx1) {
  738. var $1;
  739. $1=_st($ReportingTestContext())._testCase_result_finished_(_st(self["@suite"])._at_(anInteger),self["@result"],(function(){
  740. return smalltalk.withContext(function($ctx2) {
  741. return _st(self)._resume();
  742. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  743. return $1;
  744. }, function($ctx1) {$ctx1.fill(self,"contextOf:",{anInteger:anInteger},smalltalk.TestSuiteRunner)})},
  745. messageSends: ["testCase:result:finished:", "at:", "resume"]}),
  746. smalltalk.TestSuiteRunner);
  747. smalltalk.addMethod(
  748. smalltalk.method({
  749. selector: "initialize",
  750. fn: function (){
  751. var self=this;
  752. function $Announcer(){return smalltalk.Announcer||(typeof Announcer=="undefined"?nil:Announcer)}
  753. function $TestResult(){return smalltalk.TestResult||(typeof TestResult=="undefined"?nil:TestResult)}
  754. return smalltalk.withContext(function($ctx1) {
  755. var $1;
  756. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  757. self["@announcer"]=_st($Announcer())._new();
  758. self["@result"]=_st($TestResult())._new();
  759. self["@runNextTest"]=(function(){
  760. var runs;
  761. return smalltalk.withContext(function($ctx2) {
  762. runs=_st(self["@result"])._runs();
  763. runs;
  764. $1=_st(runs).__lt(_st(self["@result"])._total());
  765. if(smalltalk.assert($1)){
  766. return _st(_st(self)._contextOf_(_st(runs).__plus((1))))._start();
  767. };
  768. }, function($ctx2) {$ctx2.fillBlock({runs:runs},$ctx1)})});
  769. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TestSuiteRunner)})},
  770. messageSends: ["initialize", "new", "runs", "ifTrue:", "start", "contextOf:", "+", "<", "total"]}),
  771. smalltalk.TestSuiteRunner);
  772. smalltalk.addMethod(
  773. smalltalk.method({
  774. selector: "result",
  775. fn: function (){
  776. var self=this;
  777. return smalltalk.withContext(function($ctx1) {
  778. var $1;
  779. $1=self["@result"];
  780. return $1;
  781. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.TestSuiteRunner)})},
  782. messageSends: []}),
  783. smalltalk.TestSuiteRunner);
  784. smalltalk.addMethod(
  785. smalltalk.method({
  786. selector: "resume",
  787. fn: function (){
  788. var self=this;
  789. function $ResultAnnouncement(){return smalltalk.ResultAnnouncement||(typeof ResultAnnouncement=="undefined"?nil:ResultAnnouncement)}
  790. return smalltalk.withContext(function($ctx1) {
  791. _st(self["@runNextTest"])._fork();
  792. _st(self["@announcer"])._announce_(_st(_st($ResultAnnouncement())._new())._result_(self["@result"]));
  793. return self}, function($ctx1) {$ctx1.fill(self,"resume",{},smalltalk.TestSuiteRunner)})},
  794. messageSends: ["fork", "announce:", "result:", "new"]}),
  795. smalltalk.TestSuiteRunner);
  796. smalltalk.addMethod(
  797. smalltalk.method({
  798. selector: "run",
  799. fn: function (){
  800. var self=this;
  801. return smalltalk.withContext(function($ctx1) {
  802. _st(self["@result"])._total_(_st(self["@suite"])._size());
  803. _st(self)._resume();
  804. return self}, function($ctx1) {$ctx1.fill(self,"run",{},smalltalk.TestSuiteRunner)})},
  805. messageSends: ["total:", "size", "resume"]}),
  806. smalltalk.TestSuiteRunner);
  807. smalltalk.addMethod(
  808. smalltalk.method({
  809. selector: "suite:",
  810. fn: function (aCollection){
  811. var self=this;
  812. return smalltalk.withContext(function($ctx1) {
  813. self["@suite"]=aCollection;
  814. return self}, function($ctx1) {$ctx1.fill(self,"suite:",{aCollection:aCollection},smalltalk.TestSuiteRunner)})},
  815. messageSends: []}),
  816. smalltalk.TestSuiteRunner);
  817. smalltalk.addMethod(
  818. smalltalk.method({
  819. selector: "new",
  820. fn: function (){
  821. var self=this;
  822. return smalltalk.withContext(function($ctx1) {
  823. _st(self)._shouldNotImplement();
  824. return self}, function($ctx1) {$ctx1.fill(self,"new",{},smalltalk.TestSuiteRunner.klass)})},
  825. messageSends: ["shouldNotImplement"]}),
  826. smalltalk.TestSuiteRunner.klass);
  827. smalltalk.addMethod(
  828. smalltalk.method({
  829. selector: "on:",
  830. fn: function (aCollection){
  831. var self=this;
  832. return smalltalk.withContext(function($ctx1) {
  833. var $1;
  834. $1=_st(smalltalk.Object.klass.fn.prototype._new.apply(_st(self), []))._suite_(aCollection);
  835. return $1;
  836. }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection},smalltalk.TestSuiteRunner.klass)})},
  837. messageSends: ["suite:", "new"]}),
  838. smalltalk.TestSuiteRunner.klass);