SUnit-Tests.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. define(["amber/boot", "amber_core/SUnit"], function($boot){"use strict";
  2. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  3. var $core=$boot.api,nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  4. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  5. $core.addPackage('SUnit-Tests');
  6. $core.packages["SUnit-Tests"].innerEval = function (expr) { return eval(expr); };
  7. $core.packages["SUnit-Tests"].transport = {"type":"amd","amdNamespace":"amber_core"};
  8. $core.addClass('ExampleSetTest', $globals.TestCase, ['empty', 'full'], 'SUnit-Tests');
  9. //>>excludeStart("ide", pragmas.excludeIdeData);
  10. $globals.ExampleSetTest.comment="ExampleSetTest is taken from Pharo 1.4.\x0a\x0aTHe purpose of this class is to demonstrate a simple use case of the test framework.";
  11. //>>excludeEnd("ide");
  12. $core.addMethod(
  13. $core.method({
  14. selector: "setUp",
  15. protocol: 'running',
  16. fn: function (){
  17. var self=this;
  18. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  19. return $core.withContext(function($ctx1) {
  20. //>>excludeEnd("ctx");
  21. self["@empty"]=$recv($globals.Set)._new();
  22. self["@full"]=$recv($globals.Set)._with_with_((5),"abc");
  23. return self;
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. }, function($ctx1) {$ctx1.fill(self,"setUp",{},$globals.ExampleSetTest)});
  26. //>>excludeEnd("ctx");
  27. },
  28. //>>excludeStart("ide", pragmas.excludeIdeData);
  29. args: [],
  30. source: "setUp\x0a\x09empty := Set new.\x0a\x09full := Set with: 5 with: #abc",
  31. referencedClasses: ["Set"],
  32. //>>excludeEnd("ide");
  33. messageSends: ["new", "with:with:"]
  34. }),
  35. $globals.ExampleSetTest);
  36. $core.addMethod(
  37. $core.method({
  38. selector: "testAdd",
  39. protocol: 'tests',
  40. fn: function (){
  41. var self=this;
  42. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  43. return $core.withContext(function($ctx1) {
  44. //>>excludeEnd("ctx");
  45. $recv(self["@empty"])._add_((5));
  46. self._assert_($recv(self["@empty"])._includes_((5)));
  47. return self;
  48. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  49. }, function($ctx1) {$ctx1.fill(self,"testAdd",{},$globals.ExampleSetTest)});
  50. //>>excludeEnd("ctx");
  51. },
  52. //>>excludeStart("ide", pragmas.excludeIdeData);
  53. args: [],
  54. source: "testAdd\x0a\x09empty add: 5.\x0a\x09self assert: (empty includes: 5)",
  55. referencedClasses: [],
  56. //>>excludeEnd("ide");
  57. messageSends: ["add:", "assert:", "includes:"]
  58. }),
  59. $globals.ExampleSetTest);
  60. $core.addMethod(
  61. $core.method({
  62. selector: "testGrow",
  63. protocol: 'tests',
  64. fn: function (){
  65. var self=this;
  66. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  67. return $core.withContext(function($ctx1) {
  68. //>>excludeEnd("ctx");
  69. $recv(self["@empty"])._addAll_((1)._to_((100)));
  70. self._assert_equals_($recv(self["@empty"])._size(),(100));
  71. return self;
  72. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  73. }, function($ctx1) {$ctx1.fill(self,"testGrow",{},$globals.ExampleSetTest)});
  74. //>>excludeEnd("ctx");
  75. },
  76. //>>excludeStart("ide", pragmas.excludeIdeData);
  77. args: [],
  78. source: "testGrow\x0a\x09empty addAll: (1 to: 100).\x0a\x09self assert: empty size equals: 100",
  79. referencedClasses: [],
  80. //>>excludeEnd("ide");
  81. messageSends: ["addAll:", "to:", "assert:equals:", "size"]
  82. }),
  83. $globals.ExampleSetTest);
  84. $core.addMethod(
  85. $core.method({
  86. selector: "testIllegal",
  87. protocol: 'tests',
  88. fn: function (){
  89. var self=this;
  90. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  91. return $core.withContext(function($ctx1) {
  92. //>>excludeEnd("ctx");
  93. self._should_raise_((function(){
  94. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  95. return $core.withContext(function($ctx2) {
  96. //>>excludeEnd("ctx");
  97. return $recv(self["@empty"])._at_((5));
  98. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  99. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  100. //>>excludeEnd("ctx");
  101. }),$globals.Error);
  102. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  103. $ctx1.sendIdx["should:raise:"]=1;
  104. //>>excludeEnd("ctx");
  105. self._should_raise_((function(){
  106. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  107. return $core.withContext(function($ctx2) {
  108. //>>excludeEnd("ctx");
  109. return $recv(self["@empty"])._at_put_((5),"abc");
  110. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  111. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  112. //>>excludeEnd("ctx");
  113. }),$globals.Error);
  114. return self;
  115. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  116. }, function($ctx1) {$ctx1.fill(self,"testIllegal",{},$globals.ExampleSetTest)});
  117. //>>excludeEnd("ctx");
  118. },
  119. //>>excludeStart("ide", pragmas.excludeIdeData);
  120. args: [],
  121. source: "testIllegal\x0a\x09self\x0a\x09\x09should: [ empty at: 5 ]\x0a\x09\x09raise: Error.\x0a\x09self\x0a\x09\x09should: [ empty at: 5 put: #abc ]\x0a\x09\x09raise: Error",
  122. referencedClasses: ["Error"],
  123. //>>excludeEnd("ide");
  124. messageSends: ["should:raise:", "at:", "at:put:"]
  125. }),
  126. $globals.ExampleSetTest);
  127. $core.addMethod(
  128. $core.method({
  129. selector: "testIncludes",
  130. protocol: 'tests',
  131. fn: function (){
  132. var self=this;
  133. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  134. return $core.withContext(function($ctx1) {
  135. //>>excludeEnd("ctx");
  136. var $1;
  137. $1=$recv(self["@full"])._includes_((5));
  138. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  139. $ctx1.sendIdx["includes:"]=1;
  140. //>>excludeEnd("ctx");
  141. self._assert_($1);
  142. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  143. $ctx1.sendIdx["assert:"]=1;
  144. //>>excludeEnd("ctx");
  145. self._assert_($recv(self["@full"])._includes_("abc"));
  146. return self;
  147. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  148. }, function($ctx1) {$ctx1.fill(self,"testIncludes",{},$globals.ExampleSetTest)});
  149. //>>excludeEnd("ctx");
  150. },
  151. //>>excludeStart("ide", pragmas.excludeIdeData);
  152. args: [],
  153. source: "testIncludes\x0a\x09self assert: (full includes: 5).\x0a\x09self assert: (full includes: #abc)",
  154. referencedClasses: [],
  155. //>>excludeEnd("ide");
  156. messageSends: ["assert:", "includes:"]
  157. }),
  158. $globals.ExampleSetTest);
  159. $core.addMethod(
  160. $core.method({
  161. selector: "testOccurrences",
  162. protocol: 'tests',
  163. fn: function (){
  164. var self=this;
  165. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  166. return $core.withContext(function($ctx1) {
  167. //>>excludeEnd("ctx");
  168. var $1,$2;
  169. $1=$recv(self["@empty"])._occurrencesOf_((0));
  170. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  171. $ctx1.sendIdx["occurrencesOf:"]=1;
  172. //>>excludeEnd("ctx");
  173. self._assert_equals_($1,(0));
  174. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  175. $ctx1.sendIdx["assert:equals:"]=1;
  176. //>>excludeEnd("ctx");
  177. $2=$recv(self["@full"])._occurrencesOf_((5));
  178. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  179. $ctx1.sendIdx["occurrencesOf:"]=2;
  180. //>>excludeEnd("ctx");
  181. self._assert_equals_($2,(1));
  182. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  183. $ctx1.sendIdx["assert:equals:"]=2;
  184. //>>excludeEnd("ctx");
  185. $recv(self["@full"])._add_((5));
  186. self._assert_equals_($recv(self["@full"])._occurrencesOf_((5)),(1));
  187. return self;
  188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  189. }, function($ctx1) {$ctx1.fill(self,"testOccurrences",{},$globals.ExampleSetTest)});
  190. //>>excludeEnd("ctx");
  191. },
  192. //>>excludeStart("ide", pragmas.excludeIdeData);
  193. args: [],
  194. source: "testOccurrences\x0a\x09self assert: (empty occurrencesOf: 0) equals: 0.\x0a\x09self assert: (full occurrencesOf: 5) equals: 1.\x0a\x09full add: 5.\x0a\x09self assert: (full occurrencesOf: 5) equals: 1",
  195. referencedClasses: [],
  196. //>>excludeEnd("ide");
  197. messageSends: ["assert:equals:", "occurrencesOf:", "add:"]
  198. }),
  199. $globals.ExampleSetTest);
  200. $core.addMethod(
  201. $core.method({
  202. selector: "testRemove",
  203. protocol: 'tests',
  204. fn: function (){
  205. var self=this;
  206. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  207. return $core.withContext(function($ctx1) {
  208. //>>excludeEnd("ctx");
  209. var $1;
  210. $recv(self["@full"])._remove_((5));
  211. $1=$recv(self["@full"])._includes_("abc");
  212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  213. $ctx1.sendIdx["includes:"]=1;
  214. //>>excludeEnd("ctx");
  215. self._assert_($1);
  216. self._deny_($recv(self["@full"])._includes_((5)));
  217. return self;
  218. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  219. }, function($ctx1) {$ctx1.fill(self,"testRemove",{},$globals.ExampleSetTest)});
  220. //>>excludeEnd("ctx");
  221. },
  222. //>>excludeStart("ide", pragmas.excludeIdeData);
  223. args: [],
  224. source: "testRemove\x0a\x09full remove: 5.\x0a\x09self assert: (full includes: #abc).\x0a\x09self deny: (full includes: 5)",
  225. referencedClasses: [],
  226. //>>excludeEnd("ide");
  227. messageSends: ["remove:", "assert:", "includes:", "deny:"]
  228. }),
  229. $globals.ExampleSetTest);
  230. $core.addClass('SUnitAsyncTest', $globals.TestCase, ['flag'], 'SUnit-Tests');
  231. $core.addMethod(
  232. $core.method({
  233. selector: "fakeError",
  234. protocol: 'helpers',
  235. fn: function (){
  236. var self=this;
  237. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  238. return $core.withContext(function($ctx1) {
  239. //>>excludeEnd("ctx");
  240. self["@flag"]="bad";
  241. self._timeout_((30));
  242. self["@flag"]=$recv(self._async_((function(){
  243. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  244. return $core.withContext(function($ctx2) {
  245. //>>excludeEnd("ctx");
  246. self["@flag"]="ok";
  247. self["@flag"];
  248. return self._error_("Intentional");
  249. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  250. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  251. //>>excludeEnd("ctx");
  252. })))._valueWithTimeout_((20));
  253. return self;
  254. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  255. }, function($ctx1) {$ctx1.fill(self,"fakeError",{},$globals.SUnitAsyncTest)});
  256. //>>excludeEnd("ctx");
  257. },
  258. //>>excludeStart("ide", pragmas.excludeIdeData);
  259. args: [],
  260. source: "fakeError\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ flag := 'ok'. self error: 'Intentional' ]) valueWithTimeout: 20",
  261. referencedClasses: [],
  262. //>>excludeEnd("ide");
  263. messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"]
  264. }),
  265. $globals.SUnitAsyncTest);
  266. $core.addMethod(
  267. $core.method({
  268. selector: "fakeErrorFailingInTearDown",
  269. protocol: 'helpers',
  270. fn: function (){
  271. var self=this;
  272. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  273. return $core.withContext(function($ctx1) {
  274. //>>excludeEnd("ctx");
  275. self["@flag"]="bad";
  276. self._timeout_((30));
  277. self["@flag"]=$recv(self._async_((function(){
  278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  279. return $core.withContext(function($ctx2) {
  280. //>>excludeEnd("ctx");
  281. return self._error_("Intentional");
  282. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  283. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  284. //>>excludeEnd("ctx");
  285. })))._valueWithTimeout_((20));
  286. return self;
  287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  288. }, function($ctx1) {$ctx1.fill(self,"fakeErrorFailingInTearDown",{},$globals.SUnitAsyncTest)});
  289. //>>excludeEnd("ctx");
  290. },
  291. //>>excludeStart("ide", pragmas.excludeIdeData);
  292. args: [],
  293. source: "fakeErrorFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ self error: 'Intentional' ]) valueWithTimeout: 20",
  294. referencedClasses: [],
  295. //>>excludeEnd("ide");
  296. messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"]
  297. }),
  298. $globals.SUnitAsyncTest);
  299. $core.addMethod(
  300. $core.method({
  301. selector: "fakeFailure",
  302. protocol: 'helpers',
  303. fn: function (){
  304. var self=this;
  305. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  306. return $core.withContext(function($ctx1) {
  307. //>>excludeEnd("ctx");
  308. self["@flag"]="bad";
  309. self._timeout_((30));
  310. self["@flag"]=$recv(self._async_((function(){
  311. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  312. return $core.withContext(function($ctx2) {
  313. //>>excludeEnd("ctx");
  314. self["@flag"]="ok";
  315. self["@flag"];
  316. return self._assert_(false);
  317. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  318. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  319. //>>excludeEnd("ctx");
  320. })))._valueWithTimeout_((20));
  321. return self;
  322. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  323. }, function($ctx1) {$ctx1.fill(self,"fakeFailure",{},$globals.SUnitAsyncTest)});
  324. //>>excludeEnd("ctx");
  325. },
  326. //>>excludeStart("ide", pragmas.excludeIdeData);
  327. args: [],
  328. source: "fakeFailure\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ flag := 'ok'. self assert: false ]) valueWithTimeout: 20",
  329. referencedClasses: [],
  330. //>>excludeEnd("ide");
  331. messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:"]
  332. }),
  333. $globals.SUnitAsyncTest);
  334. $core.addMethod(
  335. $core.method({
  336. selector: "fakeMultipleTimeoutFailing",
  337. protocol: 'helpers',
  338. fn: function (){
  339. var self=this;
  340. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  341. return $core.withContext(function($ctx1) {
  342. //>>excludeEnd("ctx");
  343. var $1;
  344. self._timeout_((100));
  345. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  346. $ctx1.sendIdx["timeout:"]=1;
  347. //>>excludeEnd("ctx");
  348. $1=self._async_((function(){
  349. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  350. return $core.withContext(function($ctx2) {
  351. //>>excludeEnd("ctx");
  352. self._timeout_((20));
  353. return $recv(self._async_((function(){
  354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  355. return $core.withContext(function($ctx3) {
  356. //>>excludeEnd("ctx");
  357. return self._finished();
  358. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  359. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  360. //>>excludeEnd("ctx");
  361. })))._valueWithTimeout_((30));
  362. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  363. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  364. //>>excludeEnd("ctx");
  365. }));
  366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  367. $ctx1.sendIdx["async:"]=1;
  368. //>>excludeEnd("ctx");
  369. $recv($1)._valueWithTimeout_((20));
  370. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  371. $ctx1.sendIdx["valueWithTimeout:"]=1;
  372. //>>excludeEnd("ctx");
  373. return self;
  374. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  375. }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutFailing",{},$globals.SUnitAsyncTest)});
  376. //>>excludeEnd("ctx");
  377. },
  378. //>>excludeStart("ide", pragmas.excludeIdeData);
  379. args: [],
  380. source: "fakeMultipleTimeoutFailing\x0a\x09self timeout: 100.\x0a\x09(self async: [ \x0a\x09\x09self timeout: 20.\x0a\x09\x09(self async: [ self finished ]) valueWithTimeout: 30\x0a\x09]) valueWithTimeout: 20",
  381. referencedClasses: [],
  382. //>>excludeEnd("ide");
  383. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
  384. }),
  385. $globals.SUnitAsyncTest);
  386. $core.addMethod(
  387. $core.method({
  388. selector: "fakeMultipleTimeoutPassing",
  389. protocol: 'helpers',
  390. fn: function (){
  391. var self=this;
  392. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  393. return $core.withContext(function($ctx1) {
  394. //>>excludeEnd("ctx");
  395. var $1;
  396. self._timeout_((20));
  397. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  398. $ctx1.sendIdx["timeout:"]=1;
  399. //>>excludeEnd("ctx");
  400. $1=self._async_((function(){
  401. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  402. return $core.withContext(function($ctx2) {
  403. //>>excludeEnd("ctx");
  404. self._timeout_((40));
  405. return $recv(self._async_((function(){
  406. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  407. return $core.withContext(function($ctx3) {
  408. //>>excludeEnd("ctx");
  409. return self._finished();
  410. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  411. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  412. //>>excludeEnd("ctx");
  413. })))._valueWithTimeout_((20));
  414. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  415. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  416. //>>excludeEnd("ctx");
  417. }));
  418. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  419. $ctx1.sendIdx["async:"]=1;
  420. //>>excludeEnd("ctx");
  421. $recv($1)._valueWithTimeout_((10));
  422. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  423. $ctx1.sendIdx["valueWithTimeout:"]=1;
  424. //>>excludeEnd("ctx");
  425. return self;
  426. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  427. }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutPassing",{},$globals.SUnitAsyncTest)});
  428. //>>excludeEnd("ctx");
  429. },
  430. //>>excludeStart("ide", pragmas.excludeIdeData);
  431. args: [],
  432. source: "fakeMultipleTimeoutPassing\x0a\x09self timeout: 20.\x0a\x09(self async: [\x0a\x09\x09self timeout: 40.\x0a\x09\x09(self async: [ self finished ]) valueWithTimeout: 20\x0a\x09]) valueWithTimeout: 10",
  433. referencedClasses: [],
  434. //>>excludeEnd("ide");
  435. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
  436. }),
  437. $globals.SUnitAsyncTest);
  438. $core.addMethod(
  439. $core.method({
  440. selector: "fakeTimeout",
  441. protocol: 'helpers',
  442. fn: function (){
  443. var self=this;
  444. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  445. return $core.withContext(function($ctx1) {
  446. //>>excludeEnd("ctx");
  447. self._timeout_((10));
  448. $recv(self._async_((function(){
  449. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  450. return $core.withContext(function($ctx2) {
  451. //>>excludeEnd("ctx");
  452. return self._finished();
  453. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  454. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  455. //>>excludeEnd("ctx");
  456. })))._valueWithTimeout_((20));
  457. return self;
  458. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  459. }, function($ctx1) {$ctx1.fill(self,"fakeTimeout",{},$globals.SUnitAsyncTest)});
  460. //>>excludeEnd("ctx");
  461. },
  462. //>>excludeStart("ide", pragmas.excludeIdeData);
  463. args: [],
  464. source: "fakeTimeout\x0a\x09self timeout: 10.\x0a\x09(self async: [ self finished ]) valueWithTimeout: 20",
  465. referencedClasses: [],
  466. //>>excludeEnd("ide");
  467. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
  468. }),
  469. $globals.SUnitAsyncTest);
  470. $core.addMethod(
  471. $core.method({
  472. selector: "selectorSetOf:",
  473. protocol: 'private',
  474. fn: function (aCollection){
  475. var self=this;
  476. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  477. return $core.withContext(function($ctx1) {
  478. //>>excludeEnd("ctx");
  479. return $recv($recv(aCollection)._collect_((function(each){
  480. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  481. return $core.withContext(function($ctx2) {
  482. //>>excludeEnd("ctx");
  483. return $recv(each)._selector();
  484. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  485. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  486. //>>excludeEnd("ctx");
  487. })))._asSet();
  488. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  489. }, function($ctx1) {$ctx1.fill(self,"selectorSetOf:",{aCollection:aCollection},$globals.SUnitAsyncTest)});
  490. //>>excludeEnd("ctx");
  491. },
  492. //>>excludeStart("ide", pragmas.excludeIdeData);
  493. args: ["aCollection"],
  494. source: "selectorSetOf: aCollection\x0a\x09^ (aCollection collect: [ :each | each selector ]) asSet",
  495. referencedClasses: [],
  496. //>>excludeEnd("ide");
  497. messageSends: ["asSet", "collect:", "selector"]
  498. }),
  499. $globals.SUnitAsyncTest);
  500. $core.addMethod(
  501. $core.method({
  502. selector: "setUp",
  503. protocol: 'running',
  504. fn: function (){
  505. var self=this;
  506. self["@flag"]="ok";
  507. return self;
  508. },
  509. //>>excludeStart("ide", pragmas.excludeIdeData);
  510. args: [],
  511. source: "setUp\x0a\x09flag := 'ok'",
  512. referencedClasses: [],
  513. //>>excludeEnd("ide");
  514. messageSends: []
  515. }),
  516. $globals.SUnitAsyncTest);
  517. $core.addMethod(
  518. $core.method({
  519. selector: "tearDown",
  520. protocol: 'running',
  521. fn: function (){
  522. var self=this;
  523. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  524. return $core.withContext(function($ctx1) {
  525. //>>excludeEnd("ctx");
  526. self._assert_equals_("ok",self["@flag"]);
  527. return self;
  528. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  529. }, function($ctx1) {$ctx1.fill(self,"tearDown",{},$globals.SUnitAsyncTest)});
  530. //>>excludeEnd("ctx");
  531. },
  532. //>>excludeStart("ide", pragmas.excludeIdeData);
  533. args: [],
  534. source: "tearDown\x0a\x09self assert: 'ok' equals: flag",
  535. referencedClasses: [],
  536. //>>excludeEnd("ide");
  537. messageSends: ["assert:equals:"]
  538. }),
  539. $globals.SUnitAsyncTest);
  540. $core.addMethod(
  541. $core.method({
  542. selector: "testAsyncErrorsAndFailures",
  543. protocol: 'tests',
  544. fn: function (){
  545. var self=this;
  546. var suite,runner,result,assertBlock;
  547. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  548. return $core.withContext(function($ctx1) {
  549. //>>excludeEnd("ctx");
  550. var $1,$2,$3,$4;
  551. suite=["fakeError", "fakeErrorFailingInTearDown", "fakeFailure", "testPass"]._collect_((function(each){
  552. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  553. return $core.withContext(function($ctx2) {
  554. //>>excludeEnd("ctx");
  555. return $recv(self._class())._selector_(each);
  556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  557. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  558. //>>excludeEnd("ctx");
  559. }));
  560. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  561. self._timeout_((200));
  562. result=$recv(runner)._result();
  563. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  564. $ctx1.sendIdx["result"]=1;
  565. //>>excludeEnd("ctx");
  566. assertBlock=self._async_((function(){
  567. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  568. return $core.withContext(function($ctx2) {
  569. //>>excludeEnd("ctx");
  570. $1=self._selectorSetOf_($recv(result)._errors());
  571. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  572. $ctx2.sendIdx["selectorSetOf:"]=1;
  573. //>>excludeEnd("ctx");
  574. $2=["fakeError"]._asSet();
  575. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  576. $ctx2.sendIdx["asSet"]=1;
  577. //>>excludeEnd("ctx");
  578. self._assert_equals_($1,$2);
  579. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  580. $ctx2.sendIdx["assert:equals:"]=1;
  581. //>>excludeEnd("ctx");
  582. self._assert_equals_(self._selectorSetOf_($recv(result)._failures()),["fakeErrorFailingInTearDown", "fakeFailure"]._asSet());
  583. return self._finished();
  584. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  585. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  586. //>>excludeEnd("ctx");
  587. }));
  588. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  589. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  590. return $core.withContext(function($ctx2) {
  591. //>>excludeEnd("ctx");
  592. $3=$recv($recv(ann)._result()).__eq_eq(result);
  593. if($core.assert($3)){
  594. $4=$recv($recv(result)._runs()).__eq($recv(result)._total());
  595. return $recv($4)._ifTrue_(assertBlock);
  596. }
  597. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  598. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
  599. //>>excludeEnd("ctx");
  600. }));
  601. $recv(runner)._run();
  602. return self;
  603. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  604. }, function($ctx1) {$ctx1.fill(self,"testAsyncErrorsAndFailures",{suite:suite,runner:runner,result:result,assertBlock:assertBlock},$globals.SUnitAsyncTest)});
  605. //>>excludeEnd("ctx");
  606. },
  607. //>>excludeStart("ide", pragmas.excludeIdeData);
  608. args: [],
  609. source: "testAsyncErrorsAndFailures\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeError' 'fakeErrorFailingInTearDown' 'fakeFailure' 'testPass') collect: [ :each | self class selector: each ].\x0a\x09runner := TestSuiteRunner on: suite.\x0a\x09self timeout: 200.\x0a\x09result := runner result.\x0a\x09assertBlock := self async: [\x0a\x09\x09self assert: (self selectorSetOf: result errors) equals: #('fakeError') asSet.\x0a\x09\x09self assert: (self selectorSetOf: result failures) equals: #('fakeErrorFailingInTearDown' 'fakeFailure') asSet.\x0a\x09\x09self finished\x0a\x09].\x0a\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09ann result == result ifTrue: [ result runs = result total ifTrue: assertBlock ] ].\x0a\x09runner run",
  610. referencedClasses: ["TestSuiteRunner", "ResultAnnouncement"],
  611. //>>excludeEnd("ide");
  612. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "finished", "on:do:", "announcer", "ifTrue:", "==", "=", "runs", "total", "run"]
  613. }),
  614. $globals.SUnitAsyncTest);
  615. $core.addMethod(
  616. $core.method({
  617. selector: "testAsyncNeedsTimeout",
  618. protocol: 'tests',
  619. fn: function (){
  620. var self=this;
  621. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  622. return $core.withContext(function($ctx1) {
  623. //>>excludeEnd("ctx");
  624. self._should_raise_((function(){
  625. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  626. return $core.withContext(function($ctx2) {
  627. //>>excludeEnd("ctx");
  628. return self._async_((function(){
  629. }));
  630. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  631. $ctx2.sendIdx["async:"]=1;
  632. //>>excludeEnd("ctx");
  633. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  634. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  635. //>>excludeEnd("ctx");
  636. }),$globals.Error);
  637. self._timeout_((0));
  638. self._shouldnt_raise_((function(){
  639. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  640. return $core.withContext(function($ctx2) {
  641. //>>excludeEnd("ctx");
  642. return self._async_((function(){
  643. }));
  644. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  645. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  646. //>>excludeEnd("ctx");
  647. }),$globals.Error);
  648. self._finished();
  649. return self;
  650. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  651. }, function($ctx1) {$ctx1.fill(self,"testAsyncNeedsTimeout",{},$globals.SUnitAsyncTest)});
  652. //>>excludeEnd("ctx");
  653. },
  654. //>>excludeStart("ide", pragmas.excludeIdeData);
  655. args: [],
  656. source: "testAsyncNeedsTimeout\x0a\x09self should: [ self async: [ ] ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self async: [ ] ] raise: Error.\x0a\x09self finished",
  657. referencedClasses: ["Error"],
  658. //>>excludeEnd("ide");
  659. messageSends: ["should:raise:", "async:", "timeout:", "shouldnt:raise:", "finished"]
  660. }),
  661. $globals.SUnitAsyncTest);
  662. $core.addMethod(
  663. $core.method({
  664. selector: "testFinishedNeedsTimeout",
  665. protocol: 'tests',
  666. fn: function (){
  667. var self=this;
  668. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  669. return $core.withContext(function($ctx1) {
  670. //>>excludeEnd("ctx");
  671. self._should_raise_((function(){
  672. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  673. return $core.withContext(function($ctx2) {
  674. //>>excludeEnd("ctx");
  675. return self._finished();
  676. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  677. $ctx2.sendIdx["finished"]=1;
  678. //>>excludeEnd("ctx");
  679. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  680. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  681. //>>excludeEnd("ctx");
  682. }),$globals.Error);
  683. self._timeout_((0));
  684. self._shouldnt_raise_((function(){
  685. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  686. return $core.withContext(function($ctx2) {
  687. //>>excludeEnd("ctx");
  688. return self._finished();
  689. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  690. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  691. //>>excludeEnd("ctx");
  692. }),$globals.Error);
  693. return self;
  694. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  695. }, function($ctx1) {$ctx1.fill(self,"testFinishedNeedsTimeout",{},$globals.SUnitAsyncTest)});
  696. //>>excludeEnd("ctx");
  697. },
  698. //>>excludeStart("ide", pragmas.excludeIdeData);
  699. args: [],
  700. source: "testFinishedNeedsTimeout\x0a\x09self should: [ self finished ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self finished ] raise: Error.",
  701. referencedClasses: ["Error"],
  702. //>>excludeEnd("ide");
  703. messageSends: ["should:raise:", "finished", "timeout:", "shouldnt:raise:"]
  704. }),
  705. $globals.SUnitAsyncTest);
  706. $core.addMethod(
  707. $core.method({
  708. selector: "testIsAsyncReturnsCorrectValues",
  709. protocol: 'tests',
  710. fn: function (){
  711. var self=this;
  712. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  713. return $core.withContext(function($ctx1) {
  714. //>>excludeEnd("ctx");
  715. var $1,$2;
  716. $1=self._isAsync();
  717. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  718. $ctx1.sendIdx["isAsync"]=1;
  719. //>>excludeEnd("ctx");
  720. self._deny_($1);
  721. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  722. $ctx1.sendIdx["deny:"]=1;
  723. //>>excludeEnd("ctx");
  724. self._timeout_((0));
  725. $2=self._isAsync();
  726. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  727. $ctx1.sendIdx["isAsync"]=2;
  728. //>>excludeEnd("ctx");
  729. self._assert_($2);
  730. self._finished();
  731. self._deny_(self._isAsync());
  732. return self;
  733. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  734. }, function($ctx1) {$ctx1.fill(self,"testIsAsyncReturnsCorrectValues",{},$globals.SUnitAsyncTest)});
  735. //>>excludeEnd("ctx");
  736. },
  737. //>>excludeStart("ide", pragmas.excludeIdeData);
  738. args: [],
  739. source: "testIsAsyncReturnsCorrectValues\x0a\x09self deny: self isAsync.\x0a\x09self timeout: 0.\x0a\x09self assert: self isAsync.\x0a\x09self finished.\x0a\x09self deny: self isAsync",
  740. referencedClasses: [],
  741. //>>excludeEnd("ide");
  742. messageSends: ["deny:", "isAsync", "timeout:", "assert:", "finished"]
  743. }),
  744. $globals.SUnitAsyncTest);
  745. $core.addMethod(
  746. $core.method({
  747. selector: "testPass",
  748. protocol: 'tests',
  749. fn: function (){
  750. var self=this;
  751. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  752. return $core.withContext(function($ctx1) {
  753. //>>excludeEnd("ctx");
  754. self["@flag"]="bad";
  755. self._timeout_((10));
  756. self["@flag"]=$recv(self._async_((function(){
  757. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  758. return $core.withContext(function($ctx2) {
  759. //>>excludeEnd("ctx");
  760. self._assert_(true);
  761. self._finished();
  762. self["@flag"]="ok";
  763. return self["@flag"];
  764. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  765. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  766. //>>excludeEnd("ctx");
  767. })))._valueWithTimeout_((5));
  768. return self;
  769. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  770. }, function($ctx1) {$ctx1.fill(self,"testPass",{},$globals.SUnitAsyncTest)});
  771. //>>excludeEnd("ctx");
  772. },
  773. //>>excludeStart("ide", pragmas.excludeIdeData);
  774. args: [],
  775. source: "testPass\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5",
  776. referencedClasses: [],
  777. //>>excludeEnd("ide");
  778. messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:", "finished"]
  779. }),
  780. $globals.SUnitAsyncTest);
  781. $core.addMethod(
  782. $core.method({
  783. selector: "testTimeouts",
  784. protocol: 'tests',
  785. fn: function (){
  786. var self=this;
  787. var suite,runner,result,assertBlock;
  788. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  789. return $core.withContext(function($ctx1) {
  790. //>>excludeEnd("ctx");
  791. var $1,$2,$3;
  792. suite=["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"]._collect_((function(each){
  793. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  794. return $core.withContext(function($ctx2) {
  795. //>>excludeEnd("ctx");
  796. return $recv(self._class())._selector_(each);
  797. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  798. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  799. //>>excludeEnd("ctx");
  800. }));
  801. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  802. self._timeout_((200));
  803. result=$recv(runner)._result();
  804. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  805. $ctx1.sendIdx["result"]=1;
  806. //>>excludeEnd("ctx");
  807. assertBlock=self._async_((function(){
  808. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  809. return $core.withContext(function($ctx2) {
  810. //>>excludeEnd("ctx");
  811. $1=self._selectorSetOf_($recv(result)._errors());
  812. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  813. $ctx2.sendIdx["selectorSetOf:"]=1;
  814. //>>excludeEnd("ctx");
  815. self._assert_equals_($1,$recv($globals.Set)._new());
  816. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  817. $ctx2.sendIdx["assert:equals:"]=1;
  818. //>>excludeEnd("ctx");
  819. self._assert_equals_(self._selectorSetOf_($recv(result)._failures()),["fakeMultipleTimeoutFailing", "fakeTimeout"]._asSet());
  820. return self._finished();
  821. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  822. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  823. //>>excludeEnd("ctx");
  824. }));
  825. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  826. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  827. return $core.withContext(function($ctx2) {
  828. //>>excludeEnd("ctx");
  829. $2=$recv($recv(ann)._result()).__eq_eq(result);
  830. if($core.assert($2)){
  831. $3=$recv($recv(result)._runs()).__eq($recv(result)._total());
  832. return $recv($3)._ifTrue_(assertBlock);
  833. }
  834. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  835. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
  836. //>>excludeEnd("ctx");
  837. }));
  838. $recv(runner)._run();
  839. return self;
  840. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  841. }, function($ctx1) {$ctx1.fill(self,"testTimeouts",{suite:suite,runner:runner,result:result,assertBlock:assertBlock},$globals.SUnitAsyncTest)});
  842. //>>excludeEnd("ctx");
  843. },
  844. //>>excludeStart("ide", pragmas.excludeIdeData);
  845. args: [],
  846. source: "testTimeouts\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #('fakeTimeout' 'fakeMultipleTimeoutFailing' 'fakeMultipleTimeoutPassing' 'testPass') collect: [ :each | self class selector: each ].\x0a\x09runner := TestSuiteRunner on: suite.\x0a\x09self timeout: 200.\x0a\x09result := runner result.\x0a\x09assertBlock := self async: [\x0a\x09\x09self assert: (self selectorSetOf: result errors) equals: Set new.\x0a\x09\x09self assert: (self selectorSetOf: result failures) equals: #('fakeMultipleTimeoutFailing' 'fakeTimeout') asSet.\x0a\x09\x09self finished\x0a\x09].\x0a\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09ann result == result ifTrue: [ result runs = result total ifTrue: assertBlock ] ].\x0a\x09runner run",
  847. referencedClasses: ["TestSuiteRunner", "Set", "ResultAnnouncement"],
  848. //>>excludeEnd("ide");
  849. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "new", "failures", "asSet", "finished", "on:do:", "announcer", "ifTrue:", "==", "=", "runs", "total", "run"]
  850. }),
  851. $globals.SUnitAsyncTest);
  852. $core.addMethod(
  853. $core.method({
  854. selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
  855. protocol: 'tests',
  856. fn: function (){
  857. var self=this;
  858. var x;
  859. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  860. return $core.withContext(function($ctx1) {
  861. //>>excludeEnd("ctx");
  862. var $1;
  863. self["@flag"]="bad";
  864. self._timeout_((10));
  865. x=(0);
  866. $1=self._async_((function(){
  867. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  868. return $core.withContext(function($ctx2) {
  869. //>>excludeEnd("ctx");
  870. self._finished();
  871. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  872. $ctx2.sendIdx["finished"]=1;
  873. //>>excludeEnd("ctx");
  874. self["@flag"]="ok";
  875. self["@flag"];
  876. x=$recv(x).__plus((1));
  877. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  878. $ctx2.sendIdx["+"]=1;
  879. //>>excludeEnd("ctx");
  880. x;
  881. return self._assert_equals_(x,(1));
  882. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  883. $ctx2.sendIdx["assert:equals:"]=1;
  884. //>>excludeEnd("ctx");
  885. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  886. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  887. //>>excludeEnd("ctx");
  888. }));
  889. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  890. $ctx1.sendIdx["async:"]=1;
  891. //>>excludeEnd("ctx");
  892. self["@flag"]=$recv($1)._valueWithTimeout_((0));
  893. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  894. $ctx1.sendIdx["valueWithTimeout:"]=1;
  895. //>>excludeEnd("ctx");
  896. self["@flag"]=$recv(self._async_((function(){
  897. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  898. return $core.withContext(function($ctx2) {
  899. //>>excludeEnd("ctx");
  900. self._finished();
  901. self["@flag"]="ok";
  902. self["@flag"];
  903. x=$recv(x).__plus((1));
  904. x;
  905. return self._assert_equals_(x,(1));
  906. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  907. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  908. //>>excludeEnd("ctx");
  909. })))._valueWithTimeout_((0));
  910. return self;
  911. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  912. }, function($ctx1) {$ctx1.fill(self,"testTwoAsyncPassesWithFinishedOnlyOneIsRun",{x:x},$globals.SUnitAsyncTest)});
  913. //>>excludeEnd("ctx");
  914. },
  915. //>>excludeStart("ide", pragmas.excludeIdeData);
  916. args: [],
  917. source: "testTwoAsyncPassesWithFinishedOnlyOneIsRun\x0a\x09| x |\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09x := 0.\x0a\x09flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: x equals: 1 ]) valueWithTimeout: 0.\x0a\x09flag := (self async: [ self finished. flag := 'ok'. x := x+1. self assert: x equals: 1 ]) valueWithTimeout: 0.",
  918. referencedClasses: [],
  919. //>>excludeEnd("ide");
  920. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished", "+", "assert:equals:"]
  921. }),
  922. $globals.SUnitAsyncTest);
  923. });