SUnit.deploy.js 30 KB

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