1
0

SUnit-Tests.js 34 KB

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