2
0

SUnit.deploy.js 30 KB

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