SUnit-Tests.js 34 KB

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