2
0

SUnit.deploy.js 30 KB

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