SUnit-Tests.js 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817
  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.transport = {"type":"amd","amdNamespace":"amber/core"};
  5. $core.addClass("ExampleSetTest", $globals.TestCase, "SUnit-Tests");
  6. $core.setSlots($globals.ExampleSetTest, ["empty", "full"]);
  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, "SUnit-Tests");
  230. $core.setSlots($globals.SUnitAsyncTest, ["flag"]);
  231. $core.addMethod(
  232. $core.method({
  233. selector: "fakeError",
  234. protocol: "helpers",
  235. //>>excludeStart("ide", pragmas.excludeIdeData);
  236. args: [],
  237. source: "fakeError\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ flag := 'ok'. self error: 'Intentional' ]) valueWithTimeout: 20",
  238. referencedClasses: [],
  239. //>>excludeEnd("ide");
  240. pragmas: [],
  241. messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"]
  242. }, function ($methodClass){ return function (){
  243. var self=this,$self=this;
  244. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  245. return $core.withContext(function($ctx1) {
  246. //>>excludeEnd("ctx");
  247. $self.flag="bad";
  248. $self._timeout_((30));
  249. $self.flag=$recv($self._async_((function(){
  250. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  251. return $core.withContext(function($ctx2) {
  252. //>>excludeEnd("ctx");
  253. $self.flag="ok";
  254. return $self._error_("Intentional");
  255. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  256. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  257. //>>excludeEnd("ctx");
  258. })))._valueWithTimeout_((20));
  259. return self;
  260. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  261. }, function($ctx1) {$ctx1.fill(self,"fakeError",{})});
  262. //>>excludeEnd("ctx");
  263. }; }),
  264. $globals.SUnitAsyncTest);
  265. $core.addMethod(
  266. $core.method({
  267. selector: "fakeErrorFailingInTearDown",
  268. protocol: "helpers",
  269. //>>excludeStart("ide", pragmas.excludeIdeData);
  270. args: [],
  271. source: "fakeErrorFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ self error: 'Intentional' ]) valueWithTimeout: 20",
  272. referencedClasses: [],
  273. //>>excludeEnd("ide");
  274. pragmas: [],
  275. messageSends: ["timeout:", "valueWithTimeout:", "async:", "error:"]
  276. }, function ($methodClass){ return function (){
  277. var self=this,$self=this;
  278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  279. return $core.withContext(function($ctx1) {
  280. //>>excludeEnd("ctx");
  281. $self.flag="bad";
  282. $self._timeout_((30));
  283. $self.flag=$recv($self._async_((function(){
  284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  285. return $core.withContext(function($ctx2) {
  286. //>>excludeEnd("ctx");
  287. return $self._error_("Intentional");
  288. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  289. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  290. //>>excludeEnd("ctx");
  291. })))._valueWithTimeout_((20));
  292. return self;
  293. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  294. }, function($ctx1) {$ctx1.fill(self,"fakeErrorFailingInTearDown",{})});
  295. //>>excludeEnd("ctx");
  296. }; }),
  297. $globals.SUnitAsyncTest);
  298. $core.addMethod(
  299. $core.method({
  300. selector: "fakeFailure",
  301. protocol: "helpers",
  302. //>>excludeStart("ide", pragmas.excludeIdeData);
  303. args: [],
  304. source: "fakeFailure\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ flag := 'ok'. self assert: false ]) valueWithTimeout: 20",
  305. referencedClasses: [],
  306. //>>excludeEnd("ide");
  307. pragmas: [],
  308. messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:"]
  309. }, function ($methodClass){ return function (){
  310. var self=this,$self=this;
  311. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  312. return $core.withContext(function($ctx1) {
  313. //>>excludeEnd("ctx");
  314. $self.flag="bad";
  315. $self._timeout_((30));
  316. $self.flag=$recv($self._async_((function(){
  317. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  318. return $core.withContext(function($ctx2) {
  319. //>>excludeEnd("ctx");
  320. $self.flag="ok";
  321. return $self._assert_(false);
  322. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  323. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  324. //>>excludeEnd("ctx");
  325. })))._valueWithTimeout_((20));
  326. return self;
  327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  328. }, function($ctx1) {$ctx1.fill(self,"fakeFailure",{})});
  329. //>>excludeEnd("ctx");
  330. }; }),
  331. $globals.SUnitAsyncTest);
  332. $core.addMethod(
  333. $core.method({
  334. selector: "fakeMultipleTimeoutFailing",
  335. protocol: "helpers",
  336. //>>excludeStart("ide", pragmas.excludeIdeData);
  337. args: [],
  338. 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",
  339. referencedClasses: [],
  340. //>>excludeEnd("ide");
  341. pragmas: [],
  342. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
  343. }, function ($methodClass){ return function (){
  344. var self=this,$self=this;
  345. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  346. return $core.withContext(function($ctx1) {
  347. //>>excludeEnd("ctx");
  348. [$self._timeout_((100))
  349. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  350. ,$ctx1.sendIdx["timeout:"]=1
  351. //>>excludeEnd("ctx");
  352. ][0];
  353. [$recv([$self._async_((function(){
  354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  355. return $core.withContext(function($ctx2) {
  356. //>>excludeEnd("ctx");
  357. $self._timeout_((20));
  358. return $recv($self._async_((function(){
  359. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  360. return $core.withContext(function($ctx3) {
  361. //>>excludeEnd("ctx");
  362. return $self._finished();
  363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  364. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  365. //>>excludeEnd("ctx");
  366. })))._valueWithTimeout_((30));
  367. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  368. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  369. //>>excludeEnd("ctx");
  370. }))
  371. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  372. ,$ctx1.sendIdx["async:"]=1
  373. //>>excludeEnd("ctx");
  374. ][0])._valueWithTimeout_((20))
  375. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  376. ,$ctx1.sendIdx["valueWithTimeout:"]=1
  377. //>>excludeEnd("ctx");
  378. ][0];
  379. return self;
  380. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  381. }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutFailing",{})});
  382. //>>excludeEnd("ctx");
  383. }; }),
  384. $globals.SUnitAsyncTest);
  385. $core.addMethod(
  386. $core.method({
  387. selector: "fakeMultipleTimeoutPassing",
  388. protocol: "helpers",
  389. //>>excludeStart("ide", pragmas.excludeIdeData);
  390. args: [],
  391. 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",
  392. referencedClasses: [],
  393. //>>excludeEnd("ide");
  394. pragmas: [],
  395. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
  396. }, function ($methodClass){ return function (){
  397. var self=this,$self=this;
  398. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  399. return $core.withContext(function($ctx1) {
  400. //>>excludeEnd("ctx");
  401. [$self._timeout_((20))
  402. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  403. ,$ctx1.sendIdx["timeout:"]=1
  404. //>>excludeEnd("ctx");
  405. ][0];
  406. [$recv([$self._async_((function(){
  407. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  408. return $core.withContext(function($ctx2) {
  409. //>>excludeEnd("ctx");
  410. $self._timeout_((40));
  411. return $recv($self._async_((function(){
  412. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  413. return $core.withContext(function($ctx3) {
  414. //>>excludeEnd("ctx");
  415. return $self._finished();
  416. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  417. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  418. //>>excludeEnd("ctx");
  419. })))._valueWithTimeout_((20));
  420. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  421. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  422. //>>excludeEnd("ctx");
  423. }))
  424. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  425. ,$ctx1.sendIdx["async:"]=1
  426. //>>excludeEnd("ctx");
  427. ][0])._valueWithTimeout_((10))
  428. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  429. ,$ctx1.sendIdx["valueWithTimeout:"]=1
  430. //>>excludeEnd("ctx");
  431. ][0];
  432. return self;
  433. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  434. }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutPassing",{})});
  435. //>>excludeEnd("ctx");
  436. }; }),
  437. $globals.SUnitAsyncTest);
  438. $core.addMethod(
  439. $core.method({
  440. selector: "fakeNonLifoReturn",
  441. protocol: "helpers",
  442. //>>excludeStart("ide", pragmas.excludeIdeData);
  443. args: [],
  444. source: "fakeNonLifoReturn\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := (self async: [ flag := 'ok'. ^ 'non-lifo' ]) valueWithTimeout: 20",
  445. referencedClasses: [],
  446. //>>excludeEnd("ide");
  447. pragmas: [],
  448. messageSends: ["timeout:", "valueWithTimeout:", "async:"]
  449. }, function ($methodClass){ return function (){
  450. var self=this,$self=this;
  451. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  452. return $core.withContext(function($ctx1) {
  453. //>>excludeEnd("ctx");
  454. var $early={};
  455. try {
  456. $self.flag="bad";
  457. $self._timeout_((30));
  458. $self.flag=$recv($self._async_((function(){
  459. $self.flag="ok";
  460. throw $early=["non-lifo"];
  461. })))._valueWithTimeout_((20));
  462. return self;
  463. }
  464. catch(e) {if(e===$early)return e[0]; throw e}
  465. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  466. }, function($ctx1) {$ctx1.fill(self,"fakeNonLifoReturn",{})});
  467. //>>excludeEnd("ctx");
  468. }; }),
  469. $globals.SUnitAsyncTest);
  470. $core.addMethod(
  471. $core.method({
  472. selector: "fakePassFailingInTearDown",
  473. protocol: "helpers",
  474. //>>excludeStart("ide", pragmas.excludeIdeData);
  475. args: [],
  476. source: "fakePassFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09(self async: [ self finished ]) fork",
  477. referencedClasses: [],
  478. //>>excludeEnd("ide");
  479. pragmas: [],
  480. messageSends: ["timeout:", "fork", "async:", "finished"]
  481. }, function ($methodClass){ return function (){
  482. var self=this,$self=this;
  483. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  484. return $core.withContext(function($ctx1) {
  485. //>>excludeEnd("ctx");
  486. $self.flag="bad";
  487. $self._timeout_((10));
  488. $recv($self._async_((function(){
  489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  490. return $core.withContext(function($ctx2) {
  491. //>>excludeEnd("ctx");
  492. return $self._finished();
  493. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  494. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  495. //>>excludeEnd("ctx");
  496. })))._fork();
  497. return self;
  498. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  499. }, function($ctx1) {$ctx1.fill(self,"fakePassFailingInTearDown",{})});
  500. //>>excludeEnd("ctx");
  501. }; }),
  502. $globals.SUnitAsyncTest);
  503. $core.addMethod(
  504. $core.method({
  505. selector: "fakeTimeout",
  506. protocol: "helpers",
  507. //>>excludeStart("ide", pragmas.excludeIdeData);
  508. args: [],
  509. source: "fakeTimeout\x0a\x09self timeout: 10.\x0a\x09(self async: [ self finished ]) valueWithTimeout: 20",
  510. referencedClasses: [],
  511. //>>excludeEnd("ide");
  512. pragmas: [],
  513. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished"]
  514. }, function ($methodClass){ return function (){
  515. var self=this,$self=this;
  516. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  517. return $core.withContext(function($ctx1) {
  518. //>>excludeEnd("ctx");
  519. $self._timeout_((10));
  520. $recv($self._async_((function(){
  521. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  522. return $core.withContext(function($ctx2) {
  523. //>>excludeEnd("ctx");
  524. return $self._finished();
  525. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  526. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  527. //>>excludeEnd("ctx");
  528. })))._valueWithTimeout_((20));
  529. return self;
  530. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  531. }, function($ctx1) {$ctx1.fill(self,"fakeTimeout",{})});
  532. //>>excludeEnd("ctx");
  533. }; }),
  534. $globals.SUnitAsyncTest);
  535. $core.addMethod(
  536. $core.method({
  537. selector: "selectorSetOf:",
  538. protocol: "private",
  539. //>>excludeStart("ide", pragmas.excludeIdeData);
  540. args: ["aCollection"],
  541. source: "selectorSetOf: aCollection\x0a\x09^ (aCollection collect: [ :each | each selector ]) asSet",
  542. referencedClasses: [],
  543. //>>excludeEnd("ide");
  544. pragmas: [],
  545. messageSends: ["asSet", "collect:", "selector"]
  546. }, function ($methodClass){ return function (aCollection){
  547. var self=this,$self=this;
  548. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  549. return $core.withContext(function($ctx1) {
  550. //>>excludeEnd("ctx");
  551. return $recv($recv(aCollection)._collect_((function(each){
  552. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  553. return $core.withContext(function($ctx2) {
  554. //>>excludeEnd("ctx");
  555. return $recv(each)._selector();
  556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  557. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  558. //>>excludeEnd("ctx");
  559. })))._asSet();
  560. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  561. }, function($ctx1) {$ctx1.fill(self,"selectorSetOf:",{aCollection:aCollection})});
  562. //>>excludeEnd("ctx");
  563. }; }),
  564. $globals.SUnitAsyncTest);
  565. $core.addMethod(
  566. $core.method({
  567. selector: "setUp",
  568. protocol: "running",
  569. //>>excludeStart("ide", pragmas.excludeIdeData);
  570. args: [],
  571. source: "setUp\x0a\x09flag := 'ok'",
  572. referencedClasses: [],
  573. //>>excludeEnd("ide");
  574. pragmas: [],
  575. messageSends: []
  576. }, function ($methodClass){ return function (){
  577. var self=this,$self=this;
  578. $self.flag="ok";
  579. return self;
  580. }; }),
  581. $globals.SUnitAsyncTest);
  582. $core.addMethod(
  583. $core.method({
  584. selector: "tearDown",
  585. protocol: "running",
  586. //>>excludeStart("ide", pragmas.excludeIdeData);
  587. args: [],
  588. source: "tearDown\x0a\x09self assert: 'ok' equals: flag",
  589. referencedClasses: [],
  590. //>>excludeEnd("ide");
  591. pragmas: [],
  592. messageSends: ["assert:equals:"]
  593. }, function ($methodClass){ return function (){
  594. var self=this,$self=this;
  595. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  596. return $core.withContext(function($ctx1) {
  597. //>>excludeEnd("ctx");
  598. $self._assert_equals_("ok",$self.flag);
  599. return self;
  600. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  601. }, function($ctx1) {$ctx1.fill(self,"tearDown",{})});
  602. //>>excludeEnd("ctx");
  603. }; }),
  604. $globals.SUnitAsyncTest);
  605. $core.addMethod(
  606. $core.method({
  607. selector: "testAsyncErrorsAndFailures",
  608. protocol: "tests",
  609. //>>excludeStart("ide", pragmas.excludeIdeData);
  610. args: [],
  611. source: "testAsyncErrorsAndFailures\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #(fakeError fakePassFailingInTearDown 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: #(fakePassFailingInTearDown fakeErrorFailingInTearDown fakeFailure) asSet.\x0a\x09\x09self finished\x0a\x09].\x0a\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09(ann result == result and: [ result runs = result total ]) ifTrue: assertBlock ].\x0a\x09runner run",
  612. referencedClasses: ["TestSuiteRunner", "ResultAnnouncement"],
  613. //>>excludeEnd("ide");
  614. pragmas: [],
  615. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "finished", "on:do:", "announcer", "ifTrue:", "and:", "==", "=", "runs", "total", "run"]
  616. }, function ($methodClass){ return function (){
  617. var self=this,$self=this;
  618. var suite,runner,result,assertBlock;
  619. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  620. return $core.withContext(function($ctx1) {
  621. //>>excludeEnd("ctx");
  622. var $1;
  623. suite=["fakeError", "fakePassFailingInTearDown", "fakeErrorFailingInTearDown", "fakeFailure", "testPass"]._collect_((function(each){
  624. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  625. return $core.withContext(function($ctx2) {
  626. //>>excludeEnd("ctx");
  627. return $recv($self._class())._selector_(each);
  628. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  629. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  630. //>>excludeEnd("ctx");
  631. }));
  632. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  633. $self._timeout_((200));
  634. result=[$recv(runner)._result()
  635. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  636. ,$ctx1.sendIdx["result"]=1
  637. //>>excludeEnd("ctx");
  638. ][0];
  639. assertBlock=$self._async_((function(){
  640. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  641. return $core.withContext(function($ctx2) {
  642. //>>excludeEnd("ctx");
  643. [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
  644. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  645. ,$ctx2.sendIdx["selectorSetOf:"]=1
  646. //>>excludeEnd("ctx");
  647. ][0],[["fakeError"]._asSet()
  648. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  649. ,$ctx2.sendIdx["asSet"]=1
  650. //>>excludeEnd("ctx");
  651. ][0])
  652. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  653. ,$ctx2.sendIdx["assert:equals:"]=1
  654. //>>excludeEnd("ctx");
  655. ][0];
  656. $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),["fakePassFailingInTearDown", "fakeErrorFailingInTearDown", "fakeFailure"]._asSet());
  657. return $self._finished();
  658. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  659. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  660. //>>excludeEnd("ctx");
  661. }));
  662. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  663. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  664. return $core.withContext(function($ctx2) {
  665. //>>excludeEnd("ctx");
  666. if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
  667. $1=$recv($recv(result)._runs()).__eq($recv(result)._total());
  668. } else {
  669. $1=false;
  670. }
  671. return $recv($1)._ifTrue_(assertBlock);
  672. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  673. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
  674. //>>excludeEnd("ctx");
  675. }));
  676. $recv(runner)._run();
  677. return self;
  678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  679. }, function($ctx1) {$ctx1.fill(self,"testAsyncErrorsAndFailures",{suite:suite,runner:runner,result:result,assertBlock:assertBlock})});
  680. //>>excludeEnd("ctx");
  681. }; }),
  682. $globals.SUnitAsyncTest);
  683. $core.addMethod(
  684. $core.method({
  685. selector: "testAsyncNeedsTimeout",
  686. protocol: "tests",
  687. //>>excludeStart("ide", pragmas.excludeIdeData);
  688. args: [],
  689. source: "testAsyncNeedsTimeout\x0a\x09self should: [ self async: [ ] ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self async: [ ] ] raise: Error.\x0a\x09self finished",
  690. referencedClasses: ["Error"],
  691. //>>excludeEnd("ide");
  692. pragmas: [],
  693. messageSends: ["should:raise:", "async:", "timeout:", "shouldnt:raise:", "finished"]
  694. }, function ($methodClass){ return function (){
  695. var self=this,$self=this;
  696. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  697. return $core.withContext(function($ctx1) {
  698. //>>excludeEnd("ctx");
  699. $self._should_raise_((function(){
  700. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  701. return $core.withContext(function($ctx2) {
  702. //>>excludeEnd("ctx");
  703. return [$self._async_((function(){
  704. }))
  705. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  706. ,$ctx2.sendIdx["async:"]=1
  707. //>>excludeEnd("ctx");
  708. ][0];
  709. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  710. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  711. //>>excludeEnd("ctx");
  712. }),$globals.Error);
  713. $self._timeout_((0));
  714. $self._shouldnt_raise_((function(){
  715. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  716. return $core.withContext(function($ctx2) {
  717. //>>excludeEnd("ctx");
  718. return $self._async_((function(){
  719. }));
  720. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  721. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  722. //>>excludeEnd("ctx");
  723. }),$globals.Error);
  724. $self._finished();
  725. return self;
  726. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  727. }, function($ctx1) {$ctx1.fill(self,"testAsyncNeedsTimeout",{})});
  728. //>>excludeEnd("ctx");
  729. }; }),
  730. $globals.SUnitAsyncTest);
  731. $core.addMethod(
  732. $core.method({
  733. selector: "testFinishedNeedsTimeout",
  734. protocol: "tests",
  735. //>>excludeStart("ide", pragmas.excludeIdeData);
  736. args: [],
  737. source: "testFinishedNeedsTimeout\x0a\x09self should: [ self finished ] raise: Error.\x0a\x09self timeout: 0.\x0a\x09self shouldnt: [ self finished ] raise: Error.",
  738. referencedClasses: ["Error"],
  739. //>>excludeEnd("ide");
  740. pragmas: [],
  741. messageSends: ["should:raise:", "finished", "timeout:", "shouldnt:raise:"]
  742. }, function ($methodClass){ return function (){
  743. var self=this,$self=this;
  744. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  745. return $core.withContext(function($ctx1) {
  746. //>>excludeEnd("ctx");
  747. $self._should_raise_((function(){
  748. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  749. return $core.withContext(function($ctx2) {
  750. //>>excludeEnd("ctx");
  751. return [$self._finished()
  752. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  753. ,$ctx2.sendIdx["finished"]=1
  754. //>>excludeEnd("ctx");
  755. ][0];
  756. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  757. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  758. //>>excludeEnd("ctx");
  759. }),$globals.Error);
  760. $self._timeout_((0));
  761. $self._shouldnt_raise_((function(){
  762. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  763. return $core.withContext(function($ctx2) {
  764. //>>excludeEnd("ctx");
  765. return $self._finished();
  766. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  767. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  768. //>>excludeEnd("ctx");
  769. }),$globals.Error);
  770. return self;
  771. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  772. }, function($ctx1) {$ctx1.fill(self,"testFinishedNeedsTimeout",{})});
  773. //>>excludeEnd("ctx");
  774. }; }),
  775. $globals.SUnitAsyncTest);
  776. $core.addMethod(
  777. $core.method({
  778. selector: "testIsAsyncReturnsCorrectValues",
  779. protocol: "tests",
  780. //>>excludeStart("ide", pragmas.excludeIdeData);
  781. args: [],
  782. source: "testIsAsyncReturnsCorrectValues\x0a\x09self deny: self isAsync.\x0a\x09self timeout: 0.\x0a\x09self assert: self isAsync.\x0a\x09self finished.\x0a\x09self deny: self isAsync",
  783. referencedClasses: [],
  784. //>>excludeEnd("ide");
  785. pragmas: [],
  786. messageSends: ["deny:", "isAsync", "timeout:", "assert:", "finished"]
  787. }, function ($methodClass){ return function (){
  788. var self=this,$self=this;
  789. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  790. return $core.withContext(function($ctx1) {
  791. //>>excludeEnd("ctx");
  792. [$self._deny_([$self._isAsync()
  793. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  794. ,$ctx1.sendIdx["isAsync"]=1
  795. //>>excludeEnd("ctx");
  796. ][0])
  797. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  798. ,$ctx1.sendIdx["deny:"]=1
  799. //>>excludeEnd("ctx");
  800. ][0];
  801. $self._timeout_((0));
  802. $self._assert_([$self._isAsync()
  803. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  804. ,$ctx1.sendIdx["isAsync"]=2
  805. //>>excludeEnd("ctx");
  806. ][0]);
  807. $self._finished();
  808. $self._deny_($self._isAsync());
  809. return self;
  810. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  811. }, function($ctx1) {$ctx1.fill(self,"testIsAsyncReturnsCorrectValues",{})});
  812. //>>excludeEnd("ctx");
  813. }; }),
  814. $globals.SUnitAsyncTest);
  815. $core.addMethod(
  816. $core.method({
  817. selector: "testNonLifo",
  818. protocol: "tests",
  819. //>>excludeStart("ide", pragmas.excludeIdeData);
  820. args: [],
  821. source: "testNonLifo\x0a\x09| suite runner result assertBlock |\x0a\x09suite := #(fakeNonLifoReturn 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: #(fakeNonLifoReturn) asSet.\x0a\x09\x09self assert: (self selectorSetOf: result failures) equals: Set new.\x0a\x09\x09\x22TODO check that error is indeed a correct NonLifoReturn\x22\x0a\x09\x09self finished\x0a\x09].\x0a\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09(ann result == result and: [ result runs = result total ]) ifTrue: assertBlock ].\x0a\x09runner run",
  822. referencedClasses: ["TestSuiteRunner", "Set", "ResultAnnouncement"],
  823. //>>excludeEnd("ide");
  824. pragmas: [],
  825. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "new", "finished", "on:do:", "announcer", "ifTrue:", "and:", "==", "=", "runs", "total", "run"]
  826. }, function ($methodClass){ return function (){
  827. var self=this,$self=this;
  828. var suite,runner,result,assertBlock;
  829. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  830. return $core.withContext(function($ctx1) {
  831. //>>excludeEnd("ctx");
  832. var $1;
  833. suite=["fakeNonLifoReturn", "testPass"]._collect_((function(each){
  834. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  835. return $core.withContext(function($ctx2) {
  836. //>>excludeEnd("ctx");
  837. return $recv($self._class())._selector_(each);
  838. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  839. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  840. //>>excludeEnd("ctx");
  841. }));
  842. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  843. $self._timeout_((200));
  844. result=[$recv(runner)._result()
  845. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  846. ,$ctx1.sendIdx["result"]=1
  847. //>>excludeEnd("ctx");
  848. ][0];
  849. assertBlock=$self._async_((function(){
  850. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  851. return $core.withContext(function($ctx2) {
  852. //>>excludeEnd("ctx");
  853. [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
  854. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  855. ,$ctx2.sendIdx["selectorSetOf:"]=1
  856. //>>excludeEnd("ctx");
  857. ][0],["fakeNonLifoReturn"]._asSet())
  858. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  859. ,$ctx2.sendIdx["assert:equals:"]=1
  860. //>>excludeEnd("ctx");
  861. ][0];
  862. $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),$recv($globals.Set)._new());
  863. return $self._finished();
  864. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  865. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  866. //>>excludeEnd("ctx");
  867. }));
  868. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  869. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  870. return $core.withContext(function($ctx2) {
  871. //>>excludeEnd("ctx");
  872. if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
  873. $1=$recv($recv(result)._runs()).__eq($recv(result)._total());
  874. } else {
  875. $1=false;
  876. }
  877. return $recv($1)._ifTrue_(assertBlock);
  878. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  879. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
  880. //>>excludeEnd("ctx");
  881. }));
  882. $recv(runner)._run();
  883. return self;
  884. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  885. }, function($ctx1) {$ctx1.fill(self,"testNonLifo",{suite:suite,runner:runner,result:result,assertBlock:assertBlock})});
  886. //>>excludeEnd("ctx");
  887. }; }),
  888. $globals.SUnitAsyncTest);
  889. $core.addMethod(
  890. $core.method({
  891. selector: "testPass",
  892. protocol: "tests",
  893. //>>excludeStart("ide", pragmas.excludeIdeData);
  894. args: [],
  895. source: "testPass\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09flag := (self async: [ self assert: true. self finished. flag := 'ok' ]) valueWithTimeout: 5",
  896. referencedClasses: [],
  897. //>>excludeEnd("ide");
  898. pragmas: [],
  899. messageSends: ["timeout:", "valueWithTimeout:", "async:", "assert:", "finished"]
  900. }, function ($methodClass){ return function (){
  901. var self=this,$self=this;
  902. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  903. return $core.withContext(function($ctx1) {
  904. //>>excludeEnd("ctx");
  905. $self.flag="bad";
  906. $self._timeout_((10));
  907. $self.flag=$recv($self._async_((function(){
  908. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  909. return $core.withContext(function($ctx2) {
  910. //>>excludeEnd("ctx");
  911. $self._assert_(true);
  912. $self._finished();
  913. $self.flag="ok";
  914. return $self.flag;
  915. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  916. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  917. //>>excludeEnd("ctx");
  918. })))._valueWithTimeout_((5));
  919. return self;
  920. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  921. }, function($ctx1) {$ctx1.fill(self,"testPass",{})});
  922. //>>excludeEnd("ctx");
  923. }; }),
  924. $globals.SUnitAsyncTest);
  925. $core.addMethod(
  926. $core.method({
  927. selector: "testTimeouts",
  928. protocol: "tests",
  929. //>>excludeStart("ide", pragmas.excludeIdeData);
  930. args: [],
  931. 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\x09(ann result == result and: [ result runs = result total ]) ifTrue: assertBlock ].\x0a\x09runner run",
  932. referencedClasses: ["TestSuiteRunner", "Set", "ResultAnnouncement"],
  933. //>>excludeEnd("ide");
  934. pragmas: [],
  935. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "async:", "assert:equals:", "selectorSetOf:", "errors", "new", "failures", "asSet", "finished", "on:do:", "announcer", "ifTrue:", "and:", "==", "=", "runs", "total", "run"]
  936. }, function ($methodClass){ return function (){
  937. var self=this,$self=this;
  938. var suite,runner,result,assertBlock;
  939. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  940. return $core.withContext(function($ctx1) {
  941. //>>excludeEnd("ctx");
  942. var $1;
  943. suite=["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"]._collect_((function(each){
  944. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  945. return $core.withContext(function($ctx2) {
  946. //>>excludeEnd("ctx");
  947. return $recv($self._class())._selector_(each);
  948. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  949. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  950. //>>excludeEnd("ctx");
  951. }));
  952. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  953. $self._timeout_((200));
  954. result=[$recv(runner)._result()
  955. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  956. ,$ctx1.sendIdx["result"]=1
  957. //>>excludeEnd("ctx");
  958. ][0];
  959. assertBlock=$self._async_((function(){
  960. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  961. return $core.withContext(function($ctx2) {
  962. //>>excludeEnd("ctx");
  963. [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
  964. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  965. ,$ctx2.sendIdx["selectorSetOf:"]=1
  966. //>>excludeEnd("ctx");
  967. ][0],$recv($globals.Set)._new())
  968. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  969. ,$ctx2.sendIdx["assert:equals:"]=1
  970. //>>excludeEnd("ctx");
  971. ][0];
  972. $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),["fakeMultipleTimeoutFailing", "fakeTimeout"]._asSet());
  973. return $self._finished();
  974. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  975. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  976. //>>excludeEnd("ctx");
  977. }));
  978. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  979. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  980. return $core.withContext(function($ctx2) {
  981. //>>excludeEnd("ctx");
  982. if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
  983. $1=$recv($recv(result)._runs()).__eq($recv(result)._total());
  984. } else {
  985. $1=false;
  986. }
  987. return $recv($1)._ifTrue_(assertBlock);
  988. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  989. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1,3)});
  990. //>>excludeEnd("ctx");
  991. }));
  992. $recv(runner)._run();
  993. return self;
  994. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  995. }, function($ctx1) {$ctx1.fill(self,"testTimeouts",{suite:suite,runner:runner,result:result,assertBlock:assertBlock})});
  996. //>>excludeEnd("ctx");
  997. }; }),
  998. $globals.SUnitAsyncTest);
  999. $core.addMethod(
  1000. $core.method({
  1001. selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
  1002. protocol: "tests",
  1003. //>>excludeStart("ide", pragmas.excludeIdeData);
  1004. args: [],
  1005. 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.",
  1006. referencedClasses: [],
  1007. //>>excludeEnd("ide");
  1008. pragmas: [],
  1009. messageSends: ["timeout:", "valueWithTimeout:", "async:", "finished", "+", "assert:equals:"]
  1010. }, function ($methodClass){ return function (){
  1011. var self=this,$self=this;
  1012. var x;
  1013. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1014. return $core.withContext(function($ctx1) {
  1015. //>>excludeEnd("ctx");
  1016. $self.flag="bad";
  1017. $self._timeout_((10));
  1018. x=(0);
  1019. $self.flag=[$recv([$self._async_((function(){
  1020. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1021. return $core.withContext(function($ctx2) {
  1022. //>>excludeEnd("ctx");
  1023. [$self._finished()
  1024. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1025. ,$ctx2.sendIdx["finished"]=1
  1026. //>>excludeEnd("ctx");
  1027. ][0];
  1028. $self.flag="ok";
  1029. x=[$recv(x).__plus((1))
  1030. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1031. ,$ctx2.sendIdx["+"]=1
  1032. //>>excludeEnd("ctx");
  1033. ][0];
  1034. return [$self._assert_equals_(x,(1))
  1035. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1036. ,$ctx2.sendIdx["assert:equals:"]=1
  1037. //>>excludeEnd("ctx");
  1038. ][0];
  1039. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1040. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1041. //>>excludeEnd("ctx");
  1042. }))
  1043. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1044. ,$ctx1.sendIdx["async:"]=1
  1045. //>>excludeEnd("ctx");
  1046. ][0])._valueWithTimeout_((0))
  1047. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1048. ,$ctx1.sendIdx["valueWithTimeout:"]=1
  1049. //>>excludeEnd("ctx");
  1050. ][0];
  1051. $self.flag=$recv($self._async_((function(){
  1052. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1053. return $core.withContext(function($ctx2) {
  1054. //>>excludeEnd("ctx");
  1055. $self._finished();
  1056. $self.flag="ok";
  1057. x=$recv(x).__plus((1));
  1058. return $self._assert_equals_(x,(1));
  1059. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1060. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1061. //>>excludeEnd("ctx");
  1062. })))._valueWithTimeout_((0));
  1063. return self;
  1064. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1065. }, function($ctx1) {$ctx1.fill(self,"testTwoAsyncPassesWithFinishedOnlyOneIsRun",{x:x})});
  1066. //>>excludeEnd("ctx");
  1067. }; }),
  1068. $globals.SUnitAsyncTest);
  1069. $core.addClass("SUnitPromiseTest", $globals.TestCase, "SUnit-Tests");
  1070. $core.setSlots($globals.SUnitPromiseTest, ["flag"]);
  1071. $core.addMethod(
  1072. $core.method({
  1073. selector: "fakeError",
  1074. protocol: "helpers",
  1075. //>>excludeStart("ide", pragmas.excludeIdeData);
  1076. args: [],
  1077. source: "fakeError\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := Promise delayMilliseconds: 20.\x0a\x09^ flag then: [ flag := 'ok'. self error: 'Intentional' ]",
  1078. referencedClasses: ["Promise"],
  1079. //>>excludeEnd("ide");
  1080. pragmas: [],
  1081. messageSends: ["timeout:", "delayMilliseconds:", "then:", "error:"]
  1082. }, function ($methodClass){ return function (){
  1083. var self=this,$self=this;
  1084. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1085. return $core.withContext(function($ctx1) {
  1086. //>>excludeEnd("ctx");
  1087. $self.flag="bad";
  1088. $self._timeout_((30));
  1089. $self.flag=$recv($globals.Promise)._delayMilliseconds_((20));
  1090. return $recv($self.flag)._then_((function(){
  1091. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1092. return $core.withContext(function($ctx2) {
  1093. //>>excludeEnd("ctx");
  1094. $self.flag="ok";
  1095. return $self._error_("Intentional");
  1096. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1097. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1098. //>>excludeEnd("ctx");
  1099. }));
  1100. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1101. }, function($ctx1) {$ctx1.fill(self,"fakeError",{})});
  1102. //>>excludeEnd("ctx");
  1103. }; }),
  1104. $globals.SUnitPromiseTest);
  1105. $core.addMethod(
  1106. $core.method({
  1107. selector: "fakeErrorFailingInTearDown",
  1108. protocol: "helpers",
  1109. //>>excludeStart("ide", pragmas.excludeIdeData);
  1110. args: [],
  1111. source: "fakeErrorFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := Promise delayMilliseconds: 20.\x0a\x09^ flag then: [ self error: 'Intentional' ]",
  1112. referencedClasses: ["Promise"],
  1113. //>>excludeEnd("ide");
  1114. pragmas: [],
  1115. messageSends: ["timeout:", "delayMilliseconds:", "then:", "error:"]
  1116. }, function ($methodClass){ return function (){
  1117. var self=this,$self=this;
  1118. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1119. return $core.withContext(function($ctx1) {
  1120. //>>excludeEnd("ctx");
  1121. $self.flag="bad";
  1122. $self._timeout_((30));
  1123. $self.flag=$recv($globals.Promise)._delayMilliseconds_((20));
  1124. return $recv($self.flag)._then_((function(){
  1125. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1126. return $core.withContext(function($ctx2) {
  1127. //>>excludeEnd("ctx");
  1128. return $self._error_("Intentional");
  1129. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1130. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1131. //>>excludeEnd("ctx");
  1132. }));
  1133. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1134. }, function($ctx1) {$ctx1.fill(self,"fakeErrorFailingInTearDown",{})});
  1135. //>>excludeEnd("ctx");
  1136. }; }),
  1137. $globals.SUnitPromiseTest);
  1138. $core.addMethod(
  1139. $core.method({
  1140. selector: "fakeFailure",
  1141. protocol: "helpers",
  1142. //>>excludeStart("ide", pragmas.excludeIdeData);
  1143. args: [],
  1144. source: "fakeFailure\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := Promise delayMilliseconds: 20.\x0a\x09^ flag then: [ flag := 'ok'. self assert: false ]",
  1145. referencedClasses: ["Promise"],
  1146. //>>excludeEnd("ide");
  1147. pragmas: [],
  1148. messageSends: ["timeout:", "delayMilliseconds:", "then:", "assert:"]
  1149. }, function ($methodClass){ return function (){
  1150. var self=this,$self=this;
  1151. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1152. return $core.withContext(function($ctx1) {
  1153. //>>excludeEnd("ctx");
  1154. $self.flag="bad";
  1155. $self._timeout_((30));
  1156. $self.flag=$recv($globals.Promise)._delayMilliseconds_((20));
  1157. return $recv($self.flag)._then_((function(){
  1158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1159. return $core.withContext(function($ctx2) {
  1160. //>>excludeEnd("ctx");
  1161. $self.flag="ok";
  1162. return $self._assert_(false);
  1163. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1164. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1165. //>>excludeEnd("ctx");
  1166. }));
  1167. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1168. }, function($ctx1) {$ctx1.fill(self,"fakeFailure",{})});
  1169. //>>excludeEnd("ctx");
  1170. }; }),
  1171. $globals.SUnitPromiseTest);
  1172. $core.addMethod(
  1173. $core.method({
  1174. selector: "fakeMultipleTimeoutFailing",
  1175. protocol: "helpers",
  1176. //>>excludeStart("ide", pragmas.excludeIdeData);
  1177. args: [],
  1178. source: "fakeMultipleTimeoutFailing\x0a\x09self timeout: 100.\x0a\x09^ (Promise delayMilliseconds: 20) then: [ self timeout: 20. Promise delayMilliseconds: 30 ]",
  1179. referencedClasses: ["Promise"],
  1180. //>>excludeEnd("ide");
  1181. pragmas: [],
  1182. messageSends: ["timeout:", "then:", "delayMilliseconds:"]
  1183. }, function ($methodClass){ return function (){
  1184. var self=this,$self=this;
  1185. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1186. return $core.withContext(function($ctx1) {
  1187. //>>excludeEnd("ctx");
  1188. [$self._timeout_((100))
  1189. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1190. ,$ctx1.sendIdx["timeout:"]=1
  1191. //>>excludeEnd("ctx");
  1192. ][0];
  1193. return $recv([$recv($globals.Promise)._delayMilliseconds_((20))
  1194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1195. ,$ctx1.sendIdx["delayMilliseconds:"]=1
  1196. //>>excludeEnd("ctx");
  1197. ][0])._then_((function(){
  1198. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1199. return $core.withContext(function($ctx2) {
  1200. //>>excludeEnd("ctx");
  1201. $self._timeout_((20));
  1202. return $recv($globals.Promise)._delayMilliseconds_((30));
  1203. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1204. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1205. //>>excludeEnd("ctx");
  1206. }));
  1207. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1208. }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutFailing",{})});
  1209. //>>excludeEnd("ctx");
  1210. }; }),
  1211. $globals.SUnitPromiseTest);
  1212. $core.addMethod(
  1213. $core.method({
  1214. selector: "fakeMultipleTimeoutPassing",
  1215. protocol: "helpers",
  1216. //>>excludeStart("ide", pragmas.excludeIdeData);
  1217. args: [],
  1218. source: "fakeMultipleTimeoutPassing\x0a\x09self timeout: 20.\x0a\x09^ (Promise delayMilliseconds: 10) then: [ self timeout: 40. Promise delayMilliseconds: 20 ]",
  1219. referencedClasses: ["Promise"],
  1220. //>>excludeEnd("ide");
  1221. pragmas: [],
  1222. messageSends: ["timeout:", "then:", "delayMilliseconds:"]
  1223. }, function ($methodClass){ return function (){
  1224. var self=this,$self=this;
  1225. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1226. return $core.withContext(function($ctx1) {
  1227. //>>excludeEnd("ctx");
  1228. [$self._timeout_((20))
  1229. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1230. ,$ctx1.sendIdx["timeout:"]=1
  1231. //>>excludeEnd("ctx");
  1232. ][0];
  1233. return $recv([$recv($globals.Promise)._delayMilliseconds_((10))
  1234. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1235. ,$ctx1.sendIdx["delayMilliseconds:"]=1
  1236. //>>excludeEnd("ctx");
  1237. ][0])._then_((function(){
  1238. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1239. return $core.withContext(function($ctx2) {
  1240. //>>excludeEnd("ctx");
  1241. $self._timeout_((40));
  1242. return $recv($globals.Promise)._delayMilliseconds_((20));
  1243. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1244. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1245. //>>excludeEnd("ctx");
  1246. }));
  1247. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1248. }, function($ctx1) {$ctx1.fill(self,"fakeMultipleTimeoutPassing",{})});
  1249. //>>excludeEnd("ctx");
  1250. }; }),
  1251. $globals.SUnitPromiseTest);
  1252. $core.addMethod(
  1253. $core.method({
  1254. selector: "fakeNonLifoReturn",
  1255. protocol: "helpers",
  1256. //>>excludeStart("ide", pragmas.excludeIdeData);
  1257. args: [],
  1258. source: "fakeNonLifoReturn\x0a\x09flag := 'bad'.\x0a\x09self timeout: 30.\x0a\x09flag := Promise delayMilliseconds: 20.\x0a\x09^ flag then: [ flag := 'ok'. ^ 'non-lifo' ]",
  1259. referencedClasses: ["Promise"],
  1260. //>>excludeEnd("ide");
  1261. pragmas: [],
  1262. messageSends: ["timeout:", "delayMilliseconds:", "then:"]
  1263. }, function ($methodClass){ return function (){
  1264. var self=this,$self=this;
  1265. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1266. return $core.withContext(function($ctx1) {
  1267. //>>excludeEnd("ctx");
  1268. var $early={};
  1269. try {
  1270. $self.flag="bad";
  1271. $self._timeout_((30));
  1272. $self.flag=$recv($globals.Promise)._delayMilliseconds_((20));
  1273. return $recv($self.flag)._then_((function(){
  1274. $self.flag="ok";
  1275. throw $early=["non-lifo"];
  1276. }));
  1277. }
  1278. catch(e) {if(e===$early)return e[0]; throw e}
  1279. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1280. }, function($ctx1) {$ctx1.fill(self,"fakeNonLifoReturn",{})});
  1281. //>>excludeEnd("ctx");
  1282. }; }),
  1283. $globals.SUnitPromiseTest);
  1284. $core.addMethod(
  1285. $core.method({
  1286. selector: "fakePassFailingInTearDown",
  1287. protocol: "helpers",
  1288. //>>excludeStart("ide", pragmas.excludeIdeData);
  1289. args: [],
  1290. source: "fakePassFailingInTearDown\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09^ Promise new",
  1291. referencedClasses: ["Promise"],
  1292. //>>excludeEnd("ide");
  1293. pragmas: [],
  1294. messageSends: ["timeout:", "new"]
  1295. }, function ($methodClass){ return function (){
  1296. var self=this,$self=this;
  1297. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1298. return $core.withContext(function($ctx1) {
  1299. //>>excludeEnd("ctx");
  1300. $self.flag="bad";
  1301. $self._timeout_((10));
  1302. return $recv($globals.Promise)._new();
  1303. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1304. }, function($ctx1) {$ctx1.fill(self,"fakePassFailingInTearDown",{})});
  1305. //>>excludeEnd("ctx");
  1306. }; }),
  1307. $globals.SUnitPromiseTest);
  1308. $core.addMethod(
  1309. $core.method({
  1310. selector: "fakePromiseWithoutTimeout",
  1311. protocol: "helpers",
  1312. //>>excludeStart("ide", pragmas.excludeIdeData);
  1313. args: [],
  1314. source: "fakePromiseWithoutTimeout\x0a\x09^ Promise delayMilliseconds: 10",
  1315. referencedClasses: ["Promise"],
  1316. //>>excludeEnd("ide");
  1317. pragmas: [],
  1318. messageSends: ["delayMilliseconds:"]
  1319. }, function ($methodClass){ return function (){
  1320. var self=this,$self=this;
  1321. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1322. return $core.withContext(function($ctx1) {
  1323. //>>excludeEnd("ctx");
  1324. return $recv($globals.Promise)._delayMilliseconds_((10));
  1325. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1326. }, function($ctx1) {$ctx1.fill(self,"fakePromiseWithoutTimeout",{})});
  1327. //>>excludeEnd("ctx");
  1328. }; }),
  1329. $globals.SUnitPromiseTest);
  1330. $core.addMethod(
  1331. $core.method({
  1332. selector: "fakeTimeout",
  1333. protocol: "helpers",
  1334. //>>excludeStart("ide", pragmas.excludeIdeData);
  1335. args: [],
  1336. source: "fakeTimeout\x0a\x09self timeout: 10.\x0a\x09^ Promise delayMilliseconds: 20",
  1337. referencedClasses: ["Promise"],
  1338. //>>excludeEnd("ide");
  1339. pragmas: [],
  1340. messageSends: ["timeout:", "delayMilliseconds:"]
  1341. }, function ($methodClass){ return function (){
  1342. var self=this,$self=this;
  1343. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1344. return $core.withContext(function($ctx1) {
  1345. //>>excludeEnd("ctx");
  1346. $self._timeout_((10));
  1347. return $recv($globals.Promise)._delayMilliseconds_((20));
  1348. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1349. }, function($ctx1) {$ctx1.fill(self,"fakeTimeout",{})});
  1350. //>>excludeEnd("ctx");
  1351. }; }),
  1352. $globals.SUnitPromiseTest);
  1353. $core.addMethod(
  1354. $core.method({
  1355. selector: "fakeTimeoutSendOnly",
  1356. protocol: "helpers",
  1357. //>>excludeStart("ide", pragmas.excludeIdeData);
  1358. args: [],
  1359. source: "fakeTimeoutSendOnly\x0a\x09self timeout: 10",
  1360. referencedClasses: [],
  1361. //>>excludeEnd("ide");
  1362. pragmas: [],
  1363. messageSends: ["timeout:"]
  1364. }, function ($methodClass){ return function (){
  1365. var self=this,$self=this;
  1366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1367. return $core.withContext(function($ctx1) {
  1368. //>>excludeEnd("ctx");
  1369. $self._timeout_((10));
  1370. return self;
  1371. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1372. }, function($ctx1) {$ctx1.fill(self,"fakeTimeoutSendOnly",{})});
  1373. //>>excludeEnd("ctx");
  1374. }; }),
  1375. $globals.SUnitPromiseTest);
  1376. $core.addMethod(
  1377. $core.method({
  1378. selector: "selectorSetOf:",
  1379. protocol: "private",
  1380. //>>excludeStart("ide", pragmas.excludeIdeData);
  1381. args: ["aCollection"],
  1382. source: "selectorSetOf: aCollection\x0a\x09^ (aCollection collect: [ :each | each selector ]) asSet",
  1383. referencedClasses: [],
  1384. //>>excludeEnd("ide");
  1385. pragmas: [],
  1386. messageSends: ["asSet", "collect:", "selector"]
  1387. }, function ($methodClass){ return function (aCollection){
  1388. var self=this,$self=this;
  1389. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1390. return $core.withContext(function($ctx1) {
  1391. //>>excludeEnd("ctx");
  1392. return $recv($recv(aCollection)._collect_((function(each){
  1393. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1394. return $core.withContext(function($ctx2) {
  1395. //>>excludeEnd("ctx");
  1396. return $recv(each)._selector();
  1397. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1398. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1399. //>>excludeEnd("ctx");
  1400. })))._asSet();
  1401. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1402. }, function($ctx1) {$ctx1.fill(self,"selectorSetOf:",{aCollection:aCollection})});
  1403. //>>excludeEnd("ctx");
  1404. }; }),
  1405. $globals.SUnitPromiseTest);
  1406. $core.addMethod(
  1407. $core.method({
  1408. selector: "setUp",
  1409. protocol: "running",
  1410. //>>excludeStart("ide", pragmas.excludeIdeData);
  1411. args: [],
  1412. source: "setUp\x0a\x09flag := 'ok'",
  1413. referencedClasses: [],
  1414. //>>excludeEnd("ide");
  1415. pragmas: [],
  1416. messageSends: []
  1417. }, function ($methodClass){ return function (){
  1418. var self=this,$self=this;
  1419. $self.flag="ok";
  1420. return self;
  1421. }; }),
  1422. $globals.SUnitPromiseTest);
  1423. $core.addMethod(
  1424. $core.method({
  1425. selector: "tearDown",
  1426. protocol: "running",
  1427. //>>excludeStart("ide", pragmas.excludeIdeData);
  1428. args: [],
  1429. source: "tearDown\x0a\x09self assert: 'ok' equals: flag",
  1430. referencedClasses: [],
  1431. //>>excludeEnd("ide");
  1432. pragmas: [],
  1433. messageSends: ["assert:equals:"]
  1434. }, function ($methodClass){ return function (){
  1435. var self=this,$self=this;
  1436. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1437. return $core.withContext(function($ctx1) {
  1438. //>>excludeEnd("ctx");
  1439. $self._assert_equals_("ok",$self.flag);
  1440. return self;
  1441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1442. }, function($ctx1) {$ctx1.fill(self,"tearDown",{})});
  1443. //>>excludeEnd("ctx");
  1444. }; }),
  1445. $globals.SUnitPromiseTest);
  1446. $core.addMethod(
  1447. $core.method({
  1448. selector: "testIsAsyncReturnsCorrectValues",
  1449. protocol: "tests",
  1450. //>>excludeStart("ide", pragmas.excludeIdeData);
  1451. args: [],
  1452. source: "testIsAsyncReturnsCorrectValues\x0a\x09self deny: self isAsync.\x0a\x09self timeout: 0.\x0a\x09self assert: self isAsync.\x0a\x09\x22self finished.\x0a\x09self deny: self isAsync\x22\x0a\x09^ Promise new",
  1453. referencedClasses: ["Promise"],
  1454. //>>excludeEnd("ide");
  1455. pragmas: [],
  1456. messageSends: ["deny:", "isAsync", "timeout:", "assert:", "new"]
  1457. }, function ($methodClass){ return function (){
  1458. var self=this,$self=this;
  1459. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1460. return $core.withContext(function($ctx1) {
  1461. //>>excludeEnd("ctx");
  1462. $self._deny_([$self._isAsync()
  1463. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1464. ,$ctx1.sendIdx["isAsync"]=1
  1465. //>>excludeEnd("ctx");
  1466. ][0]);
  1467. $self._timeout_((0));
  1468. $self._assert_($self._isAsync());
  1469. return $recv($globals.Promise)._new();
  1470. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1471. }, function($ctx1) {$ctx1.fill(self,"testIsAsyncReturnsCorrectValues",{})});
  1472. //>>excludeEnd("ctx");
  1473. }; }),
  1474. $globals.SUnitPromiseTest);
  1475. $core.addMethod(
  1476. $core.method({
  1477. selector: "testNonLifo",
  1478. protocol: "tests",
  1479. //>>excludeStart("ide", pragmas.excludeIdeData);
  1480. args: [],
  1481. source: "testNonLifo\x0a\x09| suite runner result |\x0a\x09suite := #(fakeNonLifoReturn testPass) collect: [ :each | self class selector: each ].\x0a\x09runner := TestSuiteRunner on: suite.\x0a\x09self timeout: 200.\x0a\x09result := runner result.\x0a\x09^ Promise new: [ :model |\x0a\x09\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09\x09(ann result == result and: [ result runs = result total ]) ifTrue: [ model do: [\x0a\x09\x09\x09\x09self assert: (self selectorSetOf: result errors) equals: #(fakeNonLifoReturn) asSet.\x0a\x09\x09\x09\x09self assert: (self selectorSetOf: result failures) equals: Set new.\x0a\x09\x09\x09\x09\x22TODO check that error is indeed a correct NonLifoReturn\x22\x0a\x09\x09] ] ].\x0a\x09\x09runner run ]",
  1482. referencedClasses: ["TestSuiteRunner", "Promise", "ResultAnnouncement", "Set"],
  1483. //>>excludeEnd("ide");
  1484. pragmas: [],
  1485. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "new:", "on:do:", "announcer", "ifTrue:", "and:", "==", "=", "runs", "total", "do:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "new", "run"]
  1486. }, function ($methodClass){ return function (){
  1487. var self=this,$self=this;
  1488. var suite,runner,result;
  1489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1490. return $core.withContext(function($ctx1) {
  1491. //>>excludeEnd("ctx");
  1492. var $1;
  1493. suite=["fakeNonLifoReturn", "testPass"]._collect_((function(each){
  1494. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1495. return $core.withContext(function($ctx2) {
  1496. //>>excludeEnd("ctx");
  1497. return $recv($self._class())._selector_(each);
  1498. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1499. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1500. //>>excludeEnd("ctx");
  1501. }));
  1502. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  1503. $self._timeout_((200));
  1504. result=[$recv(runner)._result()
  1505. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1506. ,$ctx1.sendIdx["result"]=1
  1507. //>>excludeEnd("ctx");
  1508. ][0];
  1509. return $recv($globals.Promise)._new_((function(model){
  1510. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1511. return $core.withContext(function($ctx2) {
  1512. //>>excludeEnd("ctx");
  1513. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  1514. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1515. return $core.withContext(function($ctx3) {
  1516. //>>excludeEnd("ctx");
  1517. if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
  1518. $1=$recv($recv(result)._runs()).__eq($recv(result)._total());
  1519. } else {
  1520. $1=false;
  1521. }
  1522. if($core.assert($1)){
  1523. return $recv(model)._do_((function(){
  1524. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1525. return $core.withContext(function($ctx4) {
  1526. //>>excludeEnd("ctx");
  1527. [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
  1528. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1529. ,$ctx4.sendIdx["selectorSetOf:"]=1
  1530. //>>excludeEnd("ctx");
  1531. ][0],["fakeNonLifoReturn"]._asSet())
  1532. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1533. ,$ctx4.sendIdx["assert:equals:"]=1
  1534. //>>excludeEnd("ctx");
  1535. ][0];
  1536. return $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),$recv($globals.Set)._new());
  1537. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1538. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)});
  1539. //>>excludeEnd("ctx");
  1540. }));
  1541. }
  1542. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1543. }, function($ctx3) {$ctx3.fillBlock({ann:ann},$ctx2,3)});
  1544. //>>excludeEnd("ctx");
  1545. }));
  1546. return $recv(runner)._run();
  1547. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1548. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1,2)});
  1549. //>>excludeEnd("ctx");
  1550. }));
  1551. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1552. }, function($ctx1) {$ctx1.fill(self,"testNonLifo",{suite:suite,runner:runner,result:result})});
  1553. //>>excludeEnd("ctx");
  1554. }; }),
  1555. $globals.SUnitPromiseTest);
  1556. $core.addMethod(
  1557. $core.method({
  1558. selector: "testPass",
  1559. protocol: "tests",
  1560. //>>excludeStart("ide", pragmas.excludeIdeData);
  1561. args: [],
  1562. source: "testPass\x0a\x09flag := 'bad'.\x0a\x09self timeout: 10.\x0a\x09flag := Promise delayMilliseconds: 5.\x0a\x09^ flag then: [ self assert: true. flag := 'ok' ]",
  1563. referencedClasses: ["Promise"],
  1564. //>>excludeEnd("ide");
  1565. pragmas: [],
  1566. messageSends: ["timeout:", "delayMilliseconds:", "then:", "assert:"]
  1567. }, function ($methodClass){ return function (){
  1568. var self=this,$self=this;
  1569. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1570. return $core.withContext(function($ctx1) {
  1571. //>>excludeEnd("ctx");
  1572. $self.flag="bad";
  1573. $self._timeout_((10));
  1574. $self.flag=$recv($globals.Promise)._delayMilliseconds_((5));
  1575. return $recv($self.flag)._then_((function(){
  1576. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1577. return $core.withContext(function($ctx2) {
  1578. //>>excludeEnd("ctx");
  1579. $self._assert_(true);
  1580. $self.flag="ok";
  1581. return $self.flag;
  1582. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1583. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1584. //>>excludeEnd("ctx");
  1585. }));
  1586. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1587. }, function($ctx1) {$ctx1.fill(self,"testPass",{})});
  1588. //>>excludeEnd("ctx");
  1589. }; }),
  1590. $globals.SUnitPromiseTest);
  1591. $core.addMethod(
  1592. $core.method({
  1593. selector: "testPromiseErrorsAndFailures",
  1594. protocol: "tests",
  1595. //>>excludeStart("ide", pragmas.excludeIdeData);
  1596. args: [],
  1597. source: "testPromiseErrorsAndFailures\x0a\x09| suite runner result |\x0a\x09suite := #(fakeError fakePassFailingInTearDown fakeErrorFailingInTearDown fakeFailure testPass) collect: [ :each | self class selector: each ].\x0a\x09runner := TestSuiteRunner on: suite.\x0a\x09self timeout: 200.\x0a\x09result := runner result.\x0a\x09^ Promise new: [ :model |\x0a\x09\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09\x09(ann result == result and: [ result runs = result total ]) ifTrue: [ model do: [\x0a\x09\x09\x09\x09self assert: (self selectorSetOf: result errors) equals: #(fakeError) asSet.\x0a\x09\x09\x09\x09self assert: (self selectorSetOf: result failures) equals: #(fakePassFailingInTearDown fakeErrorFailingInTearDown fakeFailure) asSet ] ] ].\x0a\x09\x09runner run ]",
  1598. referencedClasses: ["TestSuiteRunner", "Promise", "ResultAnnouncement"],
  1599. //>>excludeEnd("ide");
  1600. pragmas: [],
  1601. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "new:", "on:do:", "announcer", "ifTrue:", "and:", "==", "=", "runs", "total", "do:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "run"]
  1602. }, function ($methodClass){ return function (){
  1603. var self=this,$self=this;
  1604. var suite,runner,result;
  1605. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1606. return $core.withContext(function($ctx1) {
  1607. //>>excludeEnd("ctx");
  1608. var $1;
  1609. suite=["fakeError", "fakePassFailingInTearDown", "fakeErrorFailingInTearDown", "fakeFailure", "testPass"]._collect_((function(each){
  1610. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1611. return $core.withContext(function($ctx2) {
  1612. //>>excludeEnd("ctx");
  1613. return $recv($self._class())._selector_(each);
  1614. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1615. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1616. //>>excludeEnd("ctx");
  1617. }));
  1618. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  1619. $self._timeout_((200));
  1620. result=[$recv(runner)._result()
  1621. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1622. ,$ctx1.sendIdx["result"]=1
  1623. //>>excludeEnd("ctx");
  1624. ][0];
  1625. return $recv($globals.Promise)._new_((function(model){
  1626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1627. return $core.withContext(function($ctx2) {
  1628. //>>excludeEnd("ctx");
  1629. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  1630. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1631. return $core.withContext(function($ctx3) {
  1632. //>>excludeEnd("ctx");
  1633. if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
  1634. $1=$recv($recv(result)._runs()).__eq($recv(result)._total());
  1635. } else {
  1636. $1=false;
  1637. }
  1638. if($core.assert($1)){
  1639. return $recv(model)._do_((function(){
  1640. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1641. return $core.withContext(function($ctx4) {
  1642. //>>excludeEnd("ctx");
  1643. [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
  1644. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1645. ,$ctx4.sendIdx["selectorSetOf:"]=1
  1646. //>>excludeEnd("ctx");
  1647. ][0],[["fakeError"]._asSet()
  1648. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1649. ,$ctx4.sendIdx["asSet"]=1
  1650. //>>excludeEnd("ctx");
  1651. ][0])
  1652. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1653. ,$ctx4.sendIdx["assert:equals:"]=1
  1654. //>>excludeEnd("ctx");
  1655. ][0];
  1656. return $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),["fakePassFailingInTearDown", "fakeErrorFailingInTearDown", "fakeFailure"]._asSet());
  1657. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1658. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)});
  1659. //>>excludeEnd("ctx");
  1660. }));
  1661. }
  1662. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1663. }, function($ctx3) {$ctx3.fillBlock({ann:ann},$ctx2,3)});
  1664. //>>excludeEnd("ctx");
  1665. }));
  1666. return $recv(runner)._run();
  1667. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1668. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1,2)});
  1669. //>>excludeEnd("ctx");
  1670. }));
  1671. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1672. }, function($ctx1) {$ctx1.fill(self,"testPromiseErrorsAndFailures",{suite:suite,runner:runner,result:result})});
  1673. //>>excludeEnd("ctx");
  1674. }; }),
  1675. $globals.SUnitPromiseTest);
  1676. $core.addMethod(
  1677. $core.method({
  1678. selector: "testTimeouts",
  1679. protocol: "tests",
  1680. //>>excludeStart("ide", pragmas.excludeIdeData);
  1681. args: [],
  1682. source: "testTimeouts\x0a\x09| suite runner result |\x0a\x09suite := #(fakeTimeout fakeMultipleTimeoutFailing fakeMultipleTimeoutPassing fakeTimeoutSendOnly fakePromiseWithoutTimeout testPass) collect: [ :each | self class selector: each ].\x0a\x09runner := TestSuiteRunner on: suite.\x0a\x09self timeout: 200.\x0a\x09result := runner result.\x0a\x09^ Promise new: [ :model |\x0a\x09\x09runner announcer on: ResultAnnouncement do: [ :ann |\x0a\x09\x09\x09(ann result == result and: [ result runs = result total ]) ifTrue: [ model do: [\x0a\x09\x09\x09\x09self assert: (self selectorSetOf: result errors) equals: #() asSet.\x0a\x09\x09\x09\x09self assert: (self selectorSetOf: result failures) equals: #(fakeMultipleTimeoutFailing fakeTimeout fakeTimeoutSendOnly fakePromiseWithoutTimeout) asSet ] ] ].\x0a\x09\x09runner run ]",
  1683. referencedClasses: ["TestSuiteRunner", "Promise", "ResultAnnouncement"],
  1684. //>>excludeEnd("ide");
  1685. pragmas: [],
  1686. messageSends: ["collect:", "selector:", "class", "on:", "timeout:", "result", "new:", "on:do:", "announcer", "ifTrue:", "and:", "==", "=", "runs", "total", "do:", "assert:equals:", "selectorSetOf:", "errors", "asSet", "failures", "run"]
  1687. }, function ($methodClass){ return function (){
  1688. var self=this,$self=this;
  1689. var suite,runner,result;
  1690. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1691. return $core.withContext(function($ctx1) {
  1692. //>>excludeEnd("ctx");
  1693. var $1;
  1694. suite=["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "fakeTimeoutSendOnly", "fakePromiseWithoutTimeout", "testPass"]._collect_((function(each){
  1695. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1696. return $core.withContext(function($ctx2) {
  1697. //>>excludeEnd("ctx");
  1698. return $recv($self._class())._selector_(each);
  1699. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1700. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1701. //>>excludeEnd("ctx");
  1702. }));
  1703. runner=$recv($globals.TestSuiteRunner)._on_(suite);
  1704. $self._timeout_((200));
  1705. result=[$recv(runner)._result()
  1706. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1707. ,$ctx1.sendIdx["result"]=1
  1708. //>>excludeEnd("ctx");
  1709. ][0];
  1710. return $recv($globals.Promise)._new_((function(model){
  1711. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1712. return $core.withContext(function($ctx2) {
  1713. //>>excludeEnd("ctx");
  1714. $recv($recv(runner)._announcer())._on_do_($globals.ResultAnnouncement,(function(ann){
  1715. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1716. return $core.withContext(function($ctx3) {
  1717. //>>excludeEnd("ctx");
  1718. if($core.assert($recv($recv(ann)._result()).__eq_eq(result))){
  1719. $1=$recv($recv(result)._runs()).__eq($recv(result)._total());
  1720. } else {
  1721. $1=false;
  1722. }
  1723. if($core.assert($1)){
  1724. return $recv(model)._do_((function(){
  1725. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1726. return $core.withContext(function($ctx4) {
  1727. //>>excludeEnd("ctx");
  1728. [$self._assert_equals_([$self._selectorSetOf_($recv(result)._errors())
  1729. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1730. ,$ctx4.sendIdx["selectorSetOf:"]=1
  1731. //>>excludeEnd("ctx");
  1732. ][0],[[]._asSet()
  1733. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1734. ,$ctx4.sendIdx["asSet"]=1
  1735. //>>excludeEnd("ctx");
  1736. ][0])
  1737. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1738. ,$ctx4.sendIdx["assert:equals:"]=1
  1739. //>>excludeEnd("ctx");
  1740. ][0];
  1741. return $self._assert_equals_($self._selectorSetOf_($recv(result)._failures()),["fakeMultipleTimeoutFailing", "fakeTimeout", "fakeTimeoutSendOnly", "fakePromiseWithoutTimeout"]._asSet());
  1742. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1743. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)});
  1744. //>>excludeEnd("ctx");
  1745. }));
  1746. }
  1747. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1748. }, function($ctx3) {$ctx3.fillBlock({ann:ann},$ctx2,3)});
  1749. //>>excludeEnd("ctx");
  1750. }));
  1751. return $recv(runner)._run();
  1752. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1753. }, function($ctx2) {$ctx2.fillBlock({model:model},$ctx1,2)});
  1754. //>>excludeEnd("ctx");
  1755. }));
  1756. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1757. }, function($ctx1) {$ctx1.fill(self,"testTimeouts",{suite:suite,runner:runner,result:result})});
  1758. //>>excludeEnd("ctx");
  1759. }; }),
  1760. $globals.SUnitPromiseTest);
  1761. });