SUnit-Tests.js 34 KB

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