SUnit-Tests.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962
  1. define("amber_core/SUnit-Tests", ["amber/boot", "amber_core/SUnit"], function($boot){
  2. var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var smalltalk=$core,_st=$recv,globals=$globals;
  4. $core.addPackage('SUnit-Tests');
  5. $core.packages["SUnit-Tests"].transport = {"type":"amd","amdNamespace":"amber_core"};
  6. $core.addClass('ExampleSetTest', $globals.TestCase, ['empty', 'full'], 'SUnit-Tests');
  7. //>>excludeStart("ide", pragmas.excludeIdeData);
  8. $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.";
  9. //>>excludeEnd("ide");
  10. $core.addMethod(
  11. $core.method({
  12. selector: "setUp",
  13. protocol: 'running',
  14. fn: function (){
  15. var self=this;
  16. function $Set(){return $globals.Set||(typeof Set=="undefined"?nil:Set)}
  17. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  18. return $core.withContext(function($ctx1) {
  19. //>>excludeEnd("ctx");
  20. self["@empty"]=$recv($Set())._new();
  21. self["@full"]=$recv($Set())._with_with_((5),"abc");
  22. return self;
  23. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  24. }, function($ctx1) {$ctx1.fill(self,"setUp",{},$globals.ExampleSetTest)});
  25. //>>excludeEnd("ctx");
  26. },
  27. //>>excludeStart("ide", pragmas.excludeIdeData);
  28. args: [],
  29. source: "setUp\x0a\x09empty := Set new.\x0a\x09full := Set with: 5 with: #abc",
  30. referencedClasses: ["Set"],
  31. //>>excludeEnd("ide");
  32. messageSends: ["new", "with:with:"]
  33. }),
  34. $globals.ExampleSetTest);
  35. $core.addMethod(
  36. $core.method({
  37. selector: "testAdd",
  38. protocol: 'tests',
  39. fn: function (){
  40. var self=this;
  41. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  42. return $core.withContext(function($ctx1) {
  43. //>>excludeEnd("ctx");
  44. $recv(self["@empty"])._add_((5));
  45. self._assert_($recv(self["@empty"])._includes_((5)));
  46. return self;
  47. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  48. }, function($ctx1) {$ctx1.fill(self,"testAdd",{},$globals.ExampleSetTest)});
  49. //>>excludeEnd("ctx");
  50. },
  51. //>>excludeStart("ide", pragmas.excludeIdeData);
  52. args: [],
  53. source: "testAdd\x0a\x09empty add: 5.\x0a\x09self assert: (empty includes: 5)",
  54. referencedClasses: [],
  55. //>>excludeEnd("ide");
  56. messageSends: ["add:", "assert:", "includes:"]
  57. }),
  58. $globals.ExampleSetTest);
  59. $core.addMethod(
  60. $core.method({
  61. selector: "testGrow",
  62. protocol: 'tests',
  63. fn: function (){
  64. var self=this;
  65. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  66. return $core.withContext(function($ctx1) {
  67. //>>excludeEnd("ctx");
  68. $recv(self["@empty"])._addAll_((1)._to_((100)));
  69. self._assert_equals_($recv(self["@empty"])._size(),(100));
  70. return self;
  71. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  72. }, function($ctx1) {$ctx1.fill(self,"testGrow",{},$globals.ExampleSetTest)});
  73. //>>excludeEnd("ctx");
  74. },
  75. //>>excludeStart("ide", pragmas.excludeIdeData);
  76. args: [],
  77. source: "testGrow\x0a\x09empty addAll: (1 to: 100).\x0a\x09self assert: empty size equals: 100",
  78. referencedClasses: [],
  79. //>>excludeEnd("ide");
  80. messageSends: ["addAll:", "to:", "assert:equals:", "size"]
  81. }),
  82. $globals.ExampleSetTest);
  83. $core.addMethod(
  84. $core.method({
  85. selector: "testIllegal",
  86. protocol: 'tests',
  87. fn: function (){
  88. var self=this;
  89. function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
  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. }),$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. }),$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. var $1;
  480. $1=$recv($recv(aCollection)._collect_((function(each){
  481. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  482. return $core.withContext(function($ctx2) {
  483. //>>excludeEnd("ctx");
  484. return $recv(each)._selector();
  485. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  486. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  487. //>>excludeEnd("ctx");
  488. })))._asSet();
  489. return $1;
  490. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  491. }, function($ctx1) {$ctx1.fill(self,"selectorSetOf:",{aCollection:aCollection},$globals.SUnitAsyncTest)});
  492. //>>excludeEnd("ctx");
  493. },
  494. //>>excludeStart("ide", pragmas.excludeIdeData);
  495. args: ["aCollection"],
  496. source: "selectorSetOf: aCollection\x0a\x09^ (aCollection collect: [ :each | each selector ]) asSet",
  497. referencedClasses: [],
  498. //>>excludeEnd("ide");
  499. messageSends: ["asSet", "collect:", "selector"]
  500. }),
  501. $globals.SUnitAsyncTest);
  502. $core.addMethod(
  503. $core.method({
  504. selector: "setUp",
  505. protocol: 'running',
  506. fn: function (){
  507. var self=this;
  508. self["@flag"]="ok";
  509. return self;
  510. },
  511. //>>excludeStart("ide", pragmas.excludeIdeData);
  512. args: [],
  513. source: "setUp\x0a\x09flag := 'ok'",
  514. referencedClasses: [],
  515. //>>excludeEnd("ide");
  516. messageSends: []
  517. }),
  518. $globals.SUnitAsyncTest);
  519. $core.addMethod(
  520. $core.method({
  521. selector: "tearDown",
  522. protocol: 'running',
  523. fn: function (){
  524. var self=this;
  525. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  526. return $core.withContext(function($ctx1) {
  527. //>>excludeEnd("ctx");
  528. self._assert_equals_("ok",self["@flag"]);
  529. return self;
  530. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  531. }, function($ctx1) {$ctx1.fill(self,"tearDown",{},$globals.SUnitAsyncTest)});
  532. //>>excludeEnd("ctx");
  533. },
  534. //>>excludeStart("ide", pragmas.excludeIdeData);
  535. args: [],
  536. source: "tearDown\x0a\x09self assert: 'ok' equals: flag",
  537. referencedClasses: [],
  538. //>>excludeEnd("ide");
  539. messageSends: ["assert:equals:"]
  540. }),
  541. $globals.SUnitAsyncTest);
  542. $core.addMethod(
  543. $core.method({
  544. selector: "testAsyncErrorsAndFailures",
  545. protocol: 'tests',
  546. fn: function (){
  547. var self=this;
  548. var suite,runner,result,assertBlock;
  549. function $TestSuiteRunner(){return $globals.TestSuiteRunner||(typeof TestSuiteRunner=="undefined"?nil:TestSuiteRunner)}
  550. function $ResultAnnouncement(){return $globals.ResultAnnouncement||(typeof ResultAnnouncement=="undefined"?nil:ResultAnnouncement)}
  551. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  552. return $core.withContext(function($ctx1) {
  553. //>>excludeEnd("ctx");
  554. var $1,$2,$3,$4;
  555. suite=["fakeError", "fakeErrorFailingInTearDown", "fakeFailure", "testPass"]._collect_((function(each){
  556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  557. return $core.withContext(function($ctx2) {
  558. //>>excludeEnd("ctx");
  559. return $recv(self._class())._selector_(each);
  560. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  561. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  562. //>>excludeEnd("ctx");
  563. }));
  564. runner=$recv($TestSuiteRunner())._on_(suite);
  565. self._timeout_((200));
  566. result=$recv(runner)._result();
  567. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  568. $ctx1.sendIdx["result"]=1;
  569. //>>excludeEnd("ctx");
  570. assertBlock=self._async_((function(){
  571. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  572. return $core.withContext(function($ctx2) {
  573. //>>excludeEnd("ctx");
  574. $1=self._selectorSetOf_($recv(result)._errors());
  575. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  576. $ctx2.sendIdx["selectorSetOf:"]=1;
  577. //>>excludeEnd("ctx");
  578. $2=["fakeError"]._asSet();
  579. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  580. $ctx2.sendIdx["asSet"]=1;
  581. //>>excludeEnd("ctx");
  582. self._assert_equals_($1,$2);
  583. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  584. $ctx2.sendIdx["assert:equals:"]=1;
  585. //>>excludeEnd("ctx");
  586. self._assert_equals_(self._selectorSetOf_($recv(result)._failures()),["fakeErrorFailingInTearDown", "fakeFailure"]._asSet());
  587. return self._finished();
  588. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  589. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  590. //>>excludeEnd("ctx");
  591. }));
  592. $recv($recv(runner)._announcer())._on_do_($ResultAnnouncement(),(function(ann){
  593. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  594. return $core.withContext(function($ctx2) {
  595. //>>excludeEnd("ctx");
  596. $3=$recv($recv(ann)._result()).__eq_eq(result);
  597. if($core.assert($3)){
  598. $4=$recv($recv(result)._runs()).__eq($recv(result)._total());
  599. return $recv($4)._ifTrue_(assertBlock);
  600. };
  601. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  602. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
  603. //>>excludeEnd("ctx");
  604. }));
  605. $recv(runner)._run();
  606. return self;
  607. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  608. }, function($ctx1) {$ctx1.fill(self,"testAsyncErrorsAndFailures",{suite:suite,runner:runner,result:result,assertBlock:assertBlock},$globals.SUnitAsyncTest)});
  609. //>>excludeEnd("ctx");
  610. },
  611. //>>excludeStart("ide", pragmas.excludeIdeData);
  612. args: [],
  613. 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",
  614. referencedClasses: ["TestSuiteRunner", "ResultAnnouncement"],
  615. //>>excludeEnd("ide");
  616. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "finished", "on:do:", "announcer", "ifTrue:", "==", "=", "runs", "total", "run"]
  617. }),
  618. $globals.SUnitAsyncTest);
  619. $core.addMethod(
  620. $core.method({
  621. selector: "testAsyncNeedsTimeout",
  622. protocol: 'tests',
  623. fn: function (){
  624. var self=this;
  625. function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
  626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  627. return $core.withContext(function($ctx1) {
  628. //>>excludeEnd("ctx");
  629. self._should_raise_((function(){
  630. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  631. return $core.withContext(function($ctx2) {
  632. //>>excludeEnd("ctx");
  633. return self._async_((function(){
  634. }));
  635. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  636. $ctx2.sendIdx["async:"]=1;
  637. //>>excludeEnd("ctx");
  638. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  639. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  640. //>>excludeEnd("ctx");
  641. }),$Error());
  642. self._timeout_((0));
  643. self._shouldnt_raise_((function(){
  644. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  645. return $core.withContext(function($ctx2) {
  646. //>>excludeEnd("ctx");
  647. return self._async_((function(){
  648. }));
  649. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  650. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  651. //>>excludeEnd("ctx");
  652. }),$Error());
  653. self._finished();
  654. return self;
  655. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  656. }, function($ctx1) {$ctx1.fill(self,"testAsyncNeedsTimeout",{},$globals.SUnitAsyncTest)});
  657. //>>excludeEnd("ctx");
  658. },
  659. //>>excludeStart("ide", pragmas.excludeIdeData);
  660. args: [],
  661. source: "testAsyncNeedsTimeout\x0a\x09self should: [ self async: [ ] ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self async: [ ] ] raise: Error.\x0a\x09self finished",
  662. referencedClasses: ["Error"],
  663. //>>excludeEnd("ide");
  664. messageSends: ["should:raise:", "async:", "timeout:", "shouldnt:raise:", "finished"]
  665. }),
  666. $globals.SUnitAsyncTest);
  667. $core.addMethod(
  668. $core.method({
  669. selector: "testFinishedNeedsTimeout",
  670. protocol: 'tests',
  671. fn: function (){
  672. var self=this;
  673. function $Error(){return $globals.Error||(typeof Error=="undefined"?nil:Error)}
  674. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  675. return $core.withContext(function($ctx1) {
  676. //>>excludeEnd("ctx");
  677. self._should_raise_((function(){
  678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  679. return $core.withContext(function($ctx2) {
  680. //>>excludeEnd("ctx");
  681. return self._finished();
  682. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  683. $ctx2.sendIdx["finished"]=1;
  684. //>>excludeEnd("ctx");
  685. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  686. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  687. //>>excludeEnd("ctx");
  688. }),$Error());
  689. self._timeout_((0));
  690. self._shouldnt_raise_((function(){
  691. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  692. return $core.withContext(function($ctx2) {
  693. //>>excludeEnd("ctx");
  694. return self._finished();
  695. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  696. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  697. //>>excludeEnd("ctx");
  698. }),$Error());
  699. return self;
  700. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  701. }, function($ctx1) {$ctx1.fill(self,"testFinishedNeedsTimeout",{},$globals.SUnitAsyncTest)});
  702. //>>excludeEnd("ctx");
  703. },
  704. //>>excludeStart("ide", pragmas.excludeIdeData);
  705. args: [],
  706. source: "testFinishedNeedsTimeout\x0a\x09self should: [ self finished ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self finished ] raise: Error.",
  707. referencedClasses: ["Error"],
  708. //>>excludeEnd("ide");
  709. messageSends: ["should:raise:", "finished", "timeout:", "shouldnt:raise:"]
  710. }),
  711. $globals.SUnitAsyncTest);
  712. $core.addMethod(
  713. $core.method({
  714. selector: "testIsAsyncReturnsCorrectValues",
  715. protocol: 'tests',
  716. fn: function (){
  717. var self=this;
  718. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  719. return $core.withContext(function($ctx1) {
  720. //>>excludeEnd("ctx");
  721. var $1,$2;
  722. $1=self._isAsync();
  723. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  724. $ctx1.sendIdx["isAsync"]=1;
  725. //>>excludeEnd("ctx");
  726. self._deny_($1);
  727. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  728. $ctx1.sendIdx["deny:"]=1;
  729. //>>excludeEnd("ctx");
  730. self._timeout_((0));
  731. $2=self._isAsync();
  732. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  733. $ctx1.sendIdx["isAsync"]=2;
  734. //>>excludeEnd("ctx");
  735. self._assert_($2);
  736. self._finished();
  737. self._deny_(self._isAsync());
  738. return self;
  739. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  740. }, function($ctx1) {$ctx1.fill(self,"testIsAsyncReturnsCorrectValues",{},$globals.SUnitAsyncTest)});
  741. //>>excludeEnd("ctx");
  742. },
  743. //>>excludeStart("ide", pragmas.excludeIdeData);
  744. args: [],
  745. source: "testIsAsyncReturnsCorrectValues\x0a\x09self deny: self isAsync.\x0a\x09self timeout: 0.\x0a\x09self assert: self isAsync.\x0a\x09self finished.\x0a\x09self deny: self isAsync",
  746. referencedClasses: [],
  747. //>>excludeEnd("ide");
  748. messageSends: ["deny:", "isAsync", "timeout:", "assert:", "finished"]
  749. }),
  750. $globals.SUnitAsyncTest);
  751. $core.addMethod(
  752. $core.method({
  753. selector: "testPass",
  754. protocol: 'tests',
  755. fn: function (){
  756. var self=this;
  757. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  758. return $core.withContext(function($ctx1) {
  759. //>>excludeEnd("ctx");
  760. self["@flag"]="bad";
  761. self._timeout_((10));
  762. self["@flag"]=$recv(self._async_((function(){
  763. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  764. return $core.withContext(function($ctx2) {
  765. //>>excludeEnd("ctx");
  766. self._assert_(true);
  767. self._finished();
  768. self["@flag"]="ok";
  769. return self["@flag"];
  770. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  771. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  772. //>>excludeEnd("ctx");
  773. })))._valueWithTimeout_((5));
  774. return self;
  775. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  776. }, function($ctx1) {$ctx1.fill(self,"testPass",{},$globals.SUnitAsyncTest)});
  777. //>>excludeEnd("ctx");
  778. },
  779. //>>excludeStart("ide", pragmas.excludeIdeData);
  780. args: [],
  781. source: "testPass\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5",
  782. referencedClasses: [],
  783. //>>excludeEnd("ide");
  784. messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:", "finished"]
  785. }),
  786. $globals.SUnitAsyncTest);
  787. $core.addMethod(
  788. $core.method({
  789. selector: "testTimeouts",
  790. protocol: 'tests',
  791. fn: function (){
  792. var self=this;
  793. var suite,runner,result,assertBlock;
  794. function $TestSuiteRunner(){return $globals.TestSuiteRunner||(typeof TestSuiteRunner=="undefined"?nil:TestSuiteRunner)}
  795. function $Set(){return $globals.Set||(typeof Set=="undefined"?nil:Set)}
  796. function $ResultAnnouncement(){return $globals.ResultAnnouncement||(typeof ResultAnnouncement=="undefined"?nil:ResultAnnouncement)}
  797. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  798. return $core.withContext(function($ctx1) {
  799. //>>excludeEnd("ctx");
  800. var $1,$2,$3;
  801. suite=["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"]._collect_((function(each){
  802. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  803. return $core.withContext(function($ctx2) {
  804. //>>excludeEnd("ctx");
  805. return $recv(self._class())._selector_(each);
  806. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  807. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  808. //>>excludeEnd("ctx");
  809. }));
  810. runner=$recv($TestSuiteRunner())._on_(suite);
  811. self._timeout_((200));
  812. result=$recv(runner)._result();
  813. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  814. $ctx1.sendIdx["result"]=1;
  815. //>>excludeEnd("ctx");
  816. assertBlock=self._async_((function(){
  817. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  818. return $core.withContext(function($ctx2) {
  819. //>>excludeEnd("ctx");
  820. $1=self._selectorSetOf_($recv(result)._errors());
  821. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  822. $ctx2.sendIdx["selectorSetOf:"]=1;
  823. //>>excludeEnd("ctx");
  824. self._assert_equals_($1,$recv($Set())._new());
  825. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  826. $ctx2.sendIdx["assert:equals:"]=1;
  827. //>>excludeEnd("ctx");
  828. self._assert_equals_(self._selectorSetOf_($recv(result)._failures()),["fakeMultipleTimeoutFailing", "fakeTimeout"]._asSet());
  829. return self._finished();
  830. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  831. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  832. //>>excludeEnd("ctx");
  833. }));
  834. $recv($recv(runner)._announcer())._on_do_($ResultAnnouncement(),(function(ann){
  835. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  836. return $core.withContext(function($ctx2) {
  837. //>>excludeEnd("ctx");
  838. $2=$recv($recv(ann)._result()).__eq_eq(result);
  839. if($core.assert($2)){
  840. $3=$recv($recv(result)._runs()).__eq($recv(result)._total());
  841. return $recv($3)._ifTrue_(assertBlock);
  842. };
  843. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  844. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
  845. //>>excludeEnd("ctx");
  846. }));
  847. $recv(runner)._run();
  848. return self;
  849. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  850. }, function($ctx1) {$ctx1.fill(self,"testTimeouts",{suite:suite,runner:runner,result:result,assertBlock:assertBlock},$globals.SUnitAsyncTest)});
  851. //>>excludeEnd("ctx");
  852. },
  853. //>>excludeStart("ide", pragmas.excludeIdeData);
  854. args: [],
  855. 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",
  856. referencedClasses: ["TestSuiteRunner", "Set", "ResultAnnouncement"],
  857. //>>excludeEnd("ide");
  858. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "new", "failures", "asSet", "finished", "on:do:", "announcer", "ifTrue:", "==", "=", "runs", "total", "run"]
  859. }),
  860. $globals.SUnitAsyncTest);
  861. $core.addMethod(
  862. $core.method({
  863. selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
  864. protocol: 'tests',
  865. fn: function (){
  866. var self=this;
  867. var x;
  868. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  869. return $core.withContext(function($ctx1) {
  870. //>>excludeEnd("ctx");
  871. var $1;
  872. self["@flag"]="bad";
  873. self._timeout_((10));
  874. x=(0);
  875. $1=self._async_((function(){
  876. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  877. return $core.withContext(function($ctx2) {
  878. //>>excludeEnd("ctx");
  879. self._finished();
  880. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  881. $ctx2.sendIdx["finished"]=1;
  882. //>>excludeEnd("ctx");
  883. self["@flag"]="ok";
  884. self["@flag"];
  885. x=$recv(x).__plus((1));
  886. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  887. $ctx2.sendIdx["+"]=1;
  888. //>>excludeEnd("ctx");
  889. x;
  890. return self._assert_equals_(x,(1));
  891. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  892. $ctx2.sendIdx["assert:equals:"]=1;
  893. //>>excludeEnd("ctx");
  894. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  895. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  896. //>>excludeEnd("ctx");
  897. }));
  898. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  899. $ctx1.sendIdx["async:"]=1;
  900. //>>excludeEnd("ctx");
  901. self["@flag"]=$recv($1)._valueWithTimeout_((0));
  902. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  903. $ctx1.sendIdx["valueWithTimeout:"]=1;
  904. //>>excludeEnd("ctx");
  905. self["@flag"]=$recv(self._async_((function(){
  906. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  907. return $core.withContext(function($ctx2) {
  908. //>>excludeEnd("ctx");
  909. self._finished();
  910. self["@flag"]="ok";
  911. self["@flag"];
  912. x=$recv(x).__plus((1));
  913. x;
  914. return self._assert_equals_(x,(1));
  915. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  916. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  917. //>>excludeEnd("ctx");
  918. })))._valueWithTimeout_((0));
  919. return self;
  920. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  921. }, function($ctx1) {$ctx1.fill(self,"testTwoAsyncPassesWithFinishedOnlyOneIsRun",{x:x},$globals.SUnitAsyncTest)});
  922. //>>excludeEnd("ctx");
  923. },
  924. //>>excludeStart("ide", pragmas.excludeIdeData);
  925. args: [],
  926. 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.",
  927. referencedClasses: [],
  928. //>>excludeEnd("ide");
  929. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished", "+", "assert:equals:"]
  930. }),
  931. $globals.SUnitAsyncTest);
  932. });