1
0

SUnit.js 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820
  1. define(["amber/boot", "amber_core/Kernel-Classes", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Infrastructure", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  3. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  4. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  5. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  6. $core.addPackage("SUnit");
  7. $core.packages["SUnit"].innerEval = function (expr) { return eval(expr); };
  8. $core.packages["SUnit"].transport = {"type":"amd","amdNamespace":"amber_core"};
  9. $core.addClass("ResultAnnouncement", $globals.Object, ["result"], "SUnit");
  10. //>>excludeStart("ide", pragmas.excludeIdeData);
  11. $globals.ResultAnnouncement.comment="I get signaled when a `TestCase` has been run.\x0a\x0aMy instances hold the result (instance of `TestResult`) of the test run.";
  12. //>>excludeEnd("ide");
  13. $core.addMethod(
  14. $core.method({
  15. selector: "result",
  16. protocol: "accessing",
  17. fn: function (){
  18. var self=this,$self=this;
  19. return $self["@result"];
  20. },
  21. //>>excludeStart("ide", pragmas.excludeIdeData);
  22. args: [],
  23. source: "result\x0a\x09^ result",
  24. referencedClasses: [],
  25. //>>excludeEnd("ide");
  26. messageSends: []
  27. }),
  28. $globals.ResultAnnouncement);
  29. $core.addMethod(
  30. $core.method({
  31. selector: "result:",
  32. protocol: "accessing",
  33. fn: function (aTestResult){
  34. var self=this,$self=this;
  35. $self["@result"]=aTestResult;
  36. return self;
  37. },
  38. //>>excludeStart("ide", pragmas.excludeIdeData);
  39. args: ["aTestResult"],
  40. source: "result: aTestResult\x0a\x09result := aTestResult",
  41. referencedClasses: [],
  42. //>>excludeEnd("ide");
  43. messageSends: []
  44. }),
  45. $globals.ResultAnnouncement);
  46. $core.addClass("TestCase", $globals.Object, ["testSelector", "asyncTimeout", "context"], "SUnit");
  47. //>>excludeStart("ide", pragmas.excludeIdeData);
  48. $globals.TestCase.comment="I am an implementation of the command pattern to run a test.\x0a\x0a## API\x0a\x0aMy instances are created with the class method `#selector:`,\x0apassing the symbol that names the method to be executed when the test case runs.\x0a\x0aWhen you discover a new fixture, subclass `TestCase` and create a `#test...` method for the first test.\x0aAs that method develops and more `#test...` methods are added, you will find yourself refactoring temps\x0ainto instance variables for the objects in the fixture and overriding `#setUp` to initialize these variables.\x0aAs required, override `#tearDown` to nil references, release objects and deallocate.";
  49. //>>excludeEnd("ide");
  50. $core.addMethod(
  51. $core.method({
  52. selector: "assert:",
  53. protocol: "testing",
  54. fn: function (aBoolean){
  55. var self=this,$self=this;
  56. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  57. return $core.withContext(function($ctx1) {
  58. //>>excludeEnd("ctx");
  59. $self._assert_description_(aBoolean,"Assertion failed");
  60. return self;
  61. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  62. }, function($ctx1) {$ctx1.fill(self,"assert:",{aBoolean:aBoolean},$globals.TestCase)});
  63. //>>excludeEnd("ctx");
  64. },
  65. //>>excludeStart("ide", pragmas.excludeIdeData);
  66. args: ["aBoolean"],
  67. source: "assert: aBoolean\x0a\x09self assert: aBoolean description: 'Assertion failed'",
  68. referencedClasses: [],
  69. //>>excludeEnd("ide");
  70. messageSends: ["assert:description:"]
  71. }),
  72. $globals.TestCase);
  73. $core.addMethod(
  74. $core.method({
  75. selector: "assert:description:",
  76. protocol: "testing",
  77. fn: function (aBoolean,aString){
  78. var self=this,$self=this;
  79. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  80. return $core.withContext(function($ctx1) {
  81. //>>excludeEnd("ctx");
  82. if(!$core.assert(aBoolean)){
  83. $self._signalFailure_(aString);
  84. }
  85. return self;
  86. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  87. }, function($ctx1) {$ctx1.fill(self,"assert:description:",{aBoolean:aBoolean,aString:aString},$globals.TestCase)});
  88. //>>excludeEnd("ctx");
  89. },
  90. //>>excludeStart("ide", pragmas.excludeIdeData);
  91. args: ["aBoolean", "aString"],
  92. source: "assert: aBoolean description: aString\x0a\x09aBoolean ifFalse: [ self signalFailure: aString ]",
  93. referencedClasses: [],
  94. //>>excludeEnd("ide");
  95. messageSends: ["ifFalse:", "signalFailure:"]
  96. }),
  97. $globals.TestCase);
  98. $core.addMethod(
  99. $core.method({
  100. selector: "assert:equals:",
  101. protocol: "testing",
  102. fn: function (actual,expected){
  103. var self=this,$self=this;
  104. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  105. return $core.withContext(function($ctx1) {
  106. //>>excludeEnd("ctx");
  107. var $1,$5,$4,$3,$2;
  108. $1=$recv(actual).__eq(expected);
  109. $5=$recv(expected)._printString();
  110. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  111. $ctx1.sendIdx["printString"]=1;
  112. //>>excludeEnd("ctx");
  113. $4="Expected: ".__comma($5);
  114. $3=$recv($4).__comma(" but was: ");
  115. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  116. $ctx1.sendIdx[","]=2;
  117. //>>excludeEnd("ctx");
  118. $2=$recv($3).__comma($recv(actual)._printString());
  119. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  120. $ctx1.sendIdx[","]=1;
  121. //>>excludeEnd("ctx");
  122. return $self._assert_description_($1,$2);
  123. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  124. }, function($ctx1) {$ctx1.fill(self,"assert:equals:",{actual:actual,expected:expected},$globals.TestCase)});
  125. //>>excludeEnd("ctx");
  126. },
  127. //>>excludeStart("ide", pragmas.excludeIdeData);
  128. args: ["actual", "expected"],
  129. source: "assert: actual equals: expected\x0a\x09^ self assert: (actual = expected) description: 'Expected: ', expected printString, ' but was: ', actual printString",
  130. referencedClasses: [],
  131. //>>excludeEnd("ide");
  132. messageSends: ["assert:description:", "=", ",", "printString"]
  133. }),
  134. $globals.TestCase);
  135. $core.addMethod(
  136. $core.method({
  137. selector: "async:",
  138. protocol: "async",
  139. fn: function (aBlock){
  140. var self=this,$self=this;
  141. var c;
  142. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  143. return $core.withContext(function($ctx1) {
  144. //>>excludeEnd("ctx");
  145. var $1;
  146. $self._errorIfNotAsync_("#async");
  147. c=$self["@context"];
  148. return (function(){
  149. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  150. return $core.withContext(function($ctx2) {
  151. //>>excludeEnd("ctx");
  152. $1=$self._isAsync();
  153. if($core.assert($1)){
  154. return $recv(c)._execute_(aBlock);
  155. }
  156. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  157. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  158. //>>excludeEnd("ctx");
  159. });
  160. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  161. }, function($ctx1) {$ctx1.fill(self,"async:",{aBlock:aBlock,c:c},$globals.TestCase)});
  162. //>>excludeEnd("ctx");
  163. },
  164. //>>excludeStart("ide", pragmas.excludeIdeData);
  165. args: ["aBlock"],
  166. source: "async: aBlock\x0a\x09| c |\x0a\x09self errorIfNotAsync: '#async'.\x0a\x09c := context.\x0a\x09^ [ self isAsync ifTrue: [ c execute: aBlock ] ]",
  167. referencedClasses: [],
  168. //>>excludeEnd("ide");
  169. messageSends: ["errorIfNotAsync:", "ifTrue:", "isAsync", "execute:"]
  170. }),
  171. $globals.TestCase);
  172. $core.addMethod(
  173. $core.method({
  174. selector: "context:",
  175. protocol: "accessing",
  176. fn: function (aRunningTestContext){
  177. var self=this,$self=this;
  178. $self["@context"]=aRunningTestContext;
  179. return self;
  180. },
  181. //>>excludeStart("ide", pragmas.excludeIdeData);
  182. args: ["aRunningTestContext"],
  183. source: "context: aRunningTestContext\x0a\x09context := aRunningTestContext",
  184. referencedClasses: [],
  185. //>>excludeEnd("ide");
  186. messageSends: []
  187. }),
  188. $globals.TestCase);
  189. $core.addMethod(
  190. $core.method({
  191. selector: "deny:",
  192. protocol: "testing",
  193. fn: function (aBoolean){
  194. var self=this,$self=this;
  195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  196. return $core.withContext(function($ctx1) {
  197. //>>excludeEnd("ctx");
  198. $self._assert_($recv(aBoolean)._not());
  199. return self;
  200. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  201. }, function($ctx1) {$ctx1.fill(self,"deny:",{aBoolean:aBoolean},$globals.TestCase)});
  202. //>>excludeEnd("ctx");
  203. },
  204. //>>excludeStart("ide", pragmas.excludeIdeData);
  205. args: ["aBoolean"],
  206. source: "deny: aBoolean\x0a\x09self assert: aBoolean not",
  207. referencedClasses: [],
  208. //>>excludeEnd("ide");
  209. messageSends: ["assert:", "not"]
  210. }),
  211. $globals.TestCase);
  212. $core.addMethod(
  213. $core.method({
  214. selector: "errorIfNotAsync:",
  215. protocol: "error handling",
  216. fn: function (aString){
  217. var self=this,$self=this;
  218. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  219. return $core.withContext(function($ctx1) {
  220. //>>excludeEnd("ctx");
  221. var $1;
  222. $1=$self._isAsync();
  223. if(!$core.assert($1)){
  224. $self._error_($recv(aString).__comma(" used without prior #timeout:"));
  225. }
  226. return self;
  227. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  228. }, function($ctx1) {$ctx1.fill(self,"errorIfNotAsync:",{aString:aString},$globals.TestCase)});
  229. //>>excludeEnd("ctx");
  230. },
  231. //>>excludeStart("ide", pragmas.excludeIdeData);
  232. args: ["aString"],
  233. source: "errorIfNotAsync: aString\x0a\x09self isAsync ifFalse: [\x0a\x09\x09self error: aString, ' used without prior #timeout:' ]",
  234. referencedClasses: [],
  235. //>>excludeEnd("ide");
  236. messageSends: ["ifFalse:", "isAsync", "error:", ","]
  237. }),
  238. $globals.TestCase);
  239. $core.addMethod(
  240. $core.method({
  241. selector: "finished",
  242. protocol: "async",
  243. fn: function (){
  244. var self=this,$self=this;
  245. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  246. return $core.withContext(function($ctx1) {
  247. //>>excludeEnd("ctx");
  248. $self._errorIfNotAsync_("#finished");
  249. $self["@asyncTimeout"]=nil;
  250. return self;
  251. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  252. }, function($ctx1) {$ctx1.fill(self,"finished",{},$globals.TestCase)});
  253. //>>excludeEnd("ctx");
  254. },
  255. //>>excludeStart("ide", pragmas.excludeIdeData);
  256. args: [],
  257. source: "finished\x0a\x09self errorIfNotAsync: '#finished'.\x0a\x09asyncTimeout := nil",
  258. referencedClasses: [],
  259. //>>excludeEnd("ide");
  260. messageSends: ["errorIfNotAsync:"]
  261. }),
  262. $globals.TestCase);
  263. $core.addMethod(
  264. $core.method({
  265. selector: "isAsync",
  266. protocol: "testing",
  267. fn: function (){
  268. var self=this,$self=this;
  269. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  270. return $core.withContext(function($ctx1) {
  271. //>>excludeEnd("ctx");
  272. return $recv($self["@asyncTimeout"])._notNil();
  273. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  274. }, function($ctx1) {$ctx1.fill(self,"isAsync",{},$globals.TestCase)});
  275. //>>excludeEnd("ctx");
  276. },
  277. //>>excludeStart("ide", pragmas.excludeIdeData);
  278. args: [],
  279. source: "isAsync\x0a\x09^ asyncTimeout notNil",
  280. referencedClasses: [],
  281. //>>excludeEnd("ide");
  282. messageSends: ["notNil"]
  283. }),
  284. $globals.TestCase);
  285. $core.addMethod(
  286. $core.method({
  287. selector: "performTest",
  288. protocol: "running",
  289. fn: function (){
  290. var self=this,$self=this;
  291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  292. return $core.withContext(function($ctx1) {
  293. //>>excludeEnd("ctx");
  294. $self["@asyncTimeout"]=nil;
  295. $self._perform_($self._selector());
  296. return self;
  297. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  298. }, function($ctx1) {$ctx1.fill(self,"performTest",{},$globals.TestCase)});
  299. //>>excludeEnd("ctx");
  300. },
  301. //>>excludeStart("ide", pragmas.excludeIdeData);
  302. args: [],
  303. source: "performTest\x0a\x09asyncTimeout := nil.\x0a\x09self perform: self selector",
  304. referencedClasses: [],
  305. //>>excludeEnd("ide");
  306. messageSends: ["perform:", "selector"]
  307. }),
  308. $globals.TestCase);
  309. $core.addMethod(
  310. $core.method({
  311. selector: "runCase",
  312. protocol: "running",
  313. fn: function (){
  314. var self=this,$self=this;
  315. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  316. return $core.withContext(function($ctx1) {
  317. //>>excludeEnd("ctx");
  318. $recv($recv($globals.TestContext)._testCase_(self))._start();
  319. return self;
  320. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  321. }, function($ctx1) {$ctx1.fill(self,"runCase",{},$globals.TestCase)});
  322. //>>excludeEnd("ctx");
  323. },
  324. //>>excludeStart("ide", pragmas.excludeIdeData);
  325. args: [],
  326. source: "runCase\x0a\x09\x22Runs a test case in isolated context, leaking all errors.\x22\x0a\x0a\x09(TestContext testCase: self) start",
  327. referencedClasses: ["TestContext"],
  328. //>>excludeEnd("ide");
  329. messageSends: ["start", "testCase:"]
  330. }),
  331. $globals.TestCase);
  332. $core.addMethod(
  333. $core.method({
  334. selector: "selector",
  335. protocol: "accessing",
  336. fn: function (){
  337. var self=this,$self=this;
  338. return $self["@testSelector"];
  339. },
  340. //>>excludeStart("ide", pragmas.excludeIdeData);
  341. args: [],
  342. source: "selector\x0a\x09^ testSelector",
  343. referencedClasses: [],
  344. //>>excludeEnd("ide");
  345. messageSends: []
  346. }),
  347. $globals.TestCase);
  348. $core.addMethod(
  349. $core.method({
  350. selector: "setTestSelector:",
  351. protocol: "accessing",
  352. fn: function (aSelector){
  353. var self=this,$self=this;
  354. $self["@testSelector"]=aSelector;
  355. return self;
  356. },
  357. //>>excludeStart("ide", pragmas.excludeIdeData);
  358. args: ["aSelector"],
  359. source: "setTestSelector: aSelector\x0a\x09testSelector := aSelector",
  360. referencedClasses: [],
  361. //>>excludeEnd("ide");
  362. messageSends: []
  363. }),
  364. $globals.TestCase);
  365. $core.addMethod(
  366. $core.method({
  367. selector: "setUp",
  368. protocol: "running",
  369. fn: function (){
  370. var self=this,$self=this;
  371. return self;
  372. },
  373. //>>excludeStart("ide", pragmas.excludeIdeData);
  374. args: [],
  375. source: "setUp",
  376. referencedClasses: [],
  377. //>>excludeEnd("ide");
  378. messageSends: []
  379. }),
  380. $globals.TestCase);
  381. $core.addMethod(
  382. $core.method({
  383. selector: "should:",
  384. protocol: "testing",
  385. fn: function (aBlock){
  386. var self=this,$self=this;
  387. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  388. return $core.withContext(function($ctx1) {
  389. //>>excludeEnd("ctx");
  390. $self._assert_($recv(aBlock)._value());
  391. return self;
  392. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  393. }, function($ctx1) {$ctx1.fill(self,"should:",{aBlock:aBlock},$globals.TestCase)});
  394. //>>excludeEnd("ctx");
  395. },
  396. //>>excludeStart("ide", pragmas.excludeIdeData);
  397. args: ["aBlock"],
  398. source: "should: aBlock\x0a\x09self assert: aBlock value",
  399. referencedClasses: [],
  400. //>>excludeEnd("ide");
  401. messageSends: ["assert:", "value"]
  402. }),
  403. $globals.TestCase);
  404. $core.addMethod(
  405. $core.method({
  406. selector: "should:raise:",
  407. protocol: "testing",
  408. fn: function (aBlock,anExceptionClass){
  409. var self=this,$self=this;
  410. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  411. return $core.withContext(function($ctx1) {
  412. //>>excludeEnd("ctx");
  413. $self._assert_($recv((function(){
  414. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  415. return $core.withContext(function($ctx2) {
  416. //>>excludeEnd("ctx");
  417. $recv(aBlock)._value();
  418. return false;
  419. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  420. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  421. //>>excludeEnd("ctx");
  422. }))._on_do_(anExceptionClass,(function(ex){
  423. return true;
  424. })));
  425. return self;
  426. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  427. }, function($ctx1) {$ctx1.fill(self,"should:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass},$globals.TestCase)});
  428. //>>excludeEnd("ctx");
  429. },
  430. //>>excludeStart("ide", pragmas.excludeIdeData);
  431. args: ["aBlock", "anExceptionClass"],
  432. source: "should: aBlock raise: anExceptionClass\x0a\x09self assert: ([ aBlock value. false ]\x0a\x09\x09on: anExceptionClass\x0a\x09\x09do: [ :ex | true ])",
  433. referencedClasses: [],
  434. //>>excludeEnd("ide");
  435. messageSends: ["assert:", "on:do:", "value"]
  436. }),
  437. $globals.TestCase);
  438. $core.addMethod(
  439. $core.method({
  440. selector: "shouldnt:raise:",
  441. protocol: "testing",
  442. fn: function (aBlock,anExceptionClass){
  443. var self=this,$self=this;
  444. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  445. return $core.withContext(function($ctx1) {
  446. //>>excludeEnd("ctx");
  447. $self._assert_($recv((function(){
  448. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  449. return $core.withContext(function($ctx2) {
  450. //>>excludeEnd("ctx");
  451. $recv(aBlock)._value();
  452. return true;
  453. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  454. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  455. //>>excludeEnd("ctx");
  456. }))._on_do_(anExceptionClass,(function(ex){
  457. return false;
  458. })));
  459. return self;
  460. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  461. }, function($ctx1) {$ctx1.fill(self,"shouldnt:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass},$globals.TestCase)});
  462. //>>excludeEnd("ctx");
  463. },
  464. //>>excludeStart("ide", pragmas.excludeIdeData);
  465. args: ["aBlock", "anExceptionClass"],
  466. source: "shouldnt: aBlock raise: anExceptionClass\x0a\x09self assert: ([ aBlock value. true ]\x0a\x09\x09on: anExceptionClass\x0a\x09\x09do: [ :ex | false ])",
  467. referencedClasses: [],
  468. //>>excludeEnd("ide");
  469. messageSends: ["assert:", "on:do:", "value"]
  470. }),
  471. $globals.TestCase);
  472. $core.addMethod(
  473. $core.method({
  474. selector: "signalFailure:",
  475. protocol: "private",
  476. fn: function (aString){
  477. var self=this,$self=this;
  478. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  479. return $core.withContext(function($ctx1) {
  480. //>>excludeEnd("ctx");
  481. var $1;
  482. $1=$recv($globals.TestFailure)._new();
  483. $recv($1)._messageText_(aString);
  484. $recv($1)._signal();
  485. return self;
  486. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  487. }, function($ctx1) {$ctx1.fill(self,"signalFailure:",{aString:aString},$globals.TestCase)});
  488. //>>excludeEnd("ctx");
  489. },
  490. //>>excludeStart("ide", pragmas.excludeIdeData);
  491. args: ["aString"],
  492. source: "signalFailure: aString\x0a\x09TestFailure new\x0a\x09\x09messageText: aString;\x0a\x09\x09signal",
  493. referencedClasses: ["TestFailure"],
  494. //>>excludeEnd("ide");
  495. messageSends: ["messageText:", "new", "signal"]
  496. }),
  497. $globals.TestCase);
  498. $core.addMethod(
  499. $core.method({
  500. selector: "tearDown",
  501. protocol: "running",
  502. fn: function (){
  503. var self=this,$self=this;
  504. return self;
  505. },
  506. //>>excludeStart("ide", pragmas.excludeIdeData);
  507. args: [],
  508. source: "tearDown",
  509. referencedClasses: [],
  510. //>>excludeEnd("ide");
  511. messageSends: []
  512. }),
  513. $globals.TestCase);
  514. $core.addMethod(
  515. $core.method({
  516. selector: "timeout:",
  517. protocol: "async",
  518. fn: function (aNumber){
  519. var self=this,$self=this;
  520. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  521. return $core.withContext(function($ctx1) {
  522. //>>excludeEnd("ctx");
  523. var $1,$receiver;
  524. $1=$self["@asyncTimeout"];
  525. if(($receiver = $1) == null || $receiver.a$nil){
  526. $1;
  527. } else {
  528. $recv($self["@asyncTimeout"])._clearTimeout();
  529. }
  530. $self["@asyncTimeout"]=(0);
  531. $self["@asyncTimeout"]=$recv($self._async_((function(){
  532. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  533. return $core.withContext(function($ctx2) {
  534. //>>excludeEnd("ctx");
  535. return $self._assert_description_(false,"SUnit grace time exhausted");
  536. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  537. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  538. //>>excludeEnd("ctx");
  539. })))._valueWithTimeout_(aNumber);
  540. return self;
  541. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  542. }, function($ctx1) {$ctx1.fill(self,"timeout:",{aNumber:aNumber},$globals.TestCase)});
  543. //>>excludeEnd("ctx");
  544. },
  545. //>>excludeStart("ide", pragmas.excludeIdeData);
  546. args: ["aNumber"],
  547. source: "timeout: aNumber\x0a\x09\x22Set a grace time timeout in milliseconds to run the test asynchronously\x22\x0a\x09\x0a\x09asyncTimeout ifNotNil: [ asyncTimeout clearTimeout ].\x0a\x09\x0a\x09\x22to allow #async: message send without throwing an error\x22\x0a\x09asyncTimeout := 0.\x0a\x09\x0a\x09asyncTimeout := (self async: [\x0a\x09\x09self assert: false description: 'SUnit grace time exhausted' ])\x0a\x09\x09\x09valueWithTimeout: aNumber",
  548. referencedClasses: [],
  549. //>>excludeEnd("ide");
  550. messageSends: ["ifNotNil:", "clearTimeout", "valueWithTimeout:", "async:", "assert:description:"]
  551. }),
  552. $globals.TestCase);
  553. $core.addMethod(
  554. $core.method({
  555. selector: "allTestSelectors",
  556. protocol: "accessing",
  557. fn: function (){
  558. var self=this,$self=this;
  559. var selectors;
  560. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  561. return $core.withContext(function($ctx1) {
  562. //>>excludeEnd("ctx");
  563. var $1;
  564. selectors=$self._testSelectors();
  565. $1=$self._shouldInheritSelectors();
  566. if($core.assert($1)){
  567. $recv(selectors)._addAll_($recv($self._superclass())._allTestSelectors());
  568. }
  569. return selectors;
  570. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  571. }, function($ctx1) {$ctx1.fill(self,"allTestSelectors",{selectors:selectors},$globals.TestCase.a$cls)});
  572. //>>excludeEnd("ctx");
  573. },
  574. //>>excludeStart("ide", pragmas.excludeIdeData);
  575. args: [],
  576. source: "allTestSelectors\x0a\x09| selectors |\x0a\x09selectors := self testSelectors.\x0a\x09self shouldInheritSelectors ifTrue: [\x0a\x09\x09selectors addAll: self superclass allTestSelectors ].\x0a\x09^ selectors",
  577. referencedClasses: [],
  578. //>>excludeEnd("ide");
  579. messageSends: ["testSelectors", "ifTrue:", "shouldInheritSelectors", "addAll:", "allTestSelectors", "superclass"]
  580. }),
  581. $globals.TestCase.a$cls);
  582. $core.addMethod(
  583. $core.method({
  584. selector: "buildSuite",
  585. protocol: "accessing",
  586. fn: function (){
  587. var self=this,$self=this;
  588. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  589. return $core.withContext(function($ctx1) {
  590. //>>excludeEnd("ctx");
  591. return $recv($self._allTestSelectors())._collect_((function(each){
  592. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  593. return $core.withContext(function($ctx2) {
  594. //>>excludeEnd("ctx");
  595. return $self._selector_(each);
  596. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  597. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  598. //>>excludeEnd("ctx");
  599. }));
  600. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  601. }, function($ctx1) {$ctx1.fill(self,"buildSuite",{},$globals.TestCase.a$cls)});
  602. //>>excludeEnd("ctx");
  603. },
  604. //>>excludeStart("ide", pragmas.excludeIdeData);
  605. args: [],
  606. source: "buildSuite\x0a\x09^ self allTestSelectors collect: [ :each | self selector: each ]",
  607. referencedClasses: [],
  608. //>>excludeEnd("ide");
  609. messageSends: ["collect:", "allTestSelectors", "selector:"]
  610. }),
  611. $globals.TestCase.a$cls);
  612. $core.addMethod(
  613. $core.method({
  614. selector: "classTag",
  615. protocol: "accessing",
  616. fn: function (){
  617. var self=this,$self=this;
  618. return "test";
  619. },
  620. //>>excludeStart("ide", pragmas.excludeIdeData);
  621. args: [],
  622. source: "classTag\x0a\x09\x22Returns a tag or general category for this class.\x0a\x09Typically used to help tools do some reflection.\x0a\x09Helios, for example, uses this to decide what icon the class should display.\x22\x0a\x09\x0a\x09^ 'test'",
  623. referencedClasses: [],
  624. //>>excludeEnd("ide");
  625. messageSends: []
  626. }),
  627. $globals.TestCase.a$cls);
  628. $core.addMethod(
  629. $core.method({
  630. selector: "isAbstract",
  631. protocol: "testing",
  632. fn: function (){
  633. var self=this,$self=this;
  634. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  635. return $core.withContext(function($ctx1) {
  636. //>>excludeEnd("ctx");
  637. return $recv($self._name()).__eq("TestCase");
  638. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  639. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},$globals.TestCase.a$cls)});
  640. //>>excludeEnd("ctx");
  641. },
  642. //>>excludeStart("ide", pragmas.excludeIdeData);
  643. args: [],
  644. source: "isAbstract\x0a\x09^ self name = 'TestCase'",
  645. referencedClasses: [],
  646. //>>excludeEnd("ide");
  647. messageSends: ["=", "name"]
  648. }),
  649. $globals.TestCase.a$cls);
  650. $core.addMethod(
  651. $core.method({
  652. selector: "isTestClass",
  653. protocol: "testing",
  654. fn: function (){
  655. var self=this,$self=this;
  656. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  657. return $core.withContext(function($ctx1) {
  658. //>>excludeEnd("ctx");
  659. return $recv($self._isAbstract())._not();
  660. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  661. }, function($ctx1) {$ctx1.fill(self,"isTestClass",{},$globals.TestCase.a$cls)});
  662. //>>excludeEnd("ctx");
  663. },
  664. //>>excludeStart("ide", pragmas.excludeIdeData);
  665. args: [],
  666. source: "isTestClass\x0a\x09^ self isAbstract not",
  667. referencedClasses: [],
  668. //>>excludeEnd("ide");
  669. messageSends: ["not", "isAbstract"]
  670. }),
  671. $globals.TestCase.a$cls);
  672. $core.addMethod(
  673. $core.method({
  674. selector: "lookupHierarchyRoot",
  675. protocol: "accessing",
  676. fn: function (){
  677. var self=this,$self=this;
  678. return $globals.TestCase;
  679. },
  680. //>>excludeStart("ide", pragmas.excludeIdeData);
  681. args: [],
  682. source: "lookupHierarchyRoot\x0a\x09^ TestCase",
  683. referencedClasses: ["TestCase"],
  684. //>>excludeEnd("ide");
  685. messageSends: []
  686. }),
  687. $globals.TestCase.a$cls);
  688. $core.addMethod(
  689. $core.method({
  690. selector: "selector:",
  691. protocol: "accessing",
  692. fn: function (aSelector){
  693. var self=this,$self=this;
  694. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  695. return $core.withContext(function($ctx1) {
  696. //>>excludeEnd("ctx");
  697. var $1;
  698. $1=$self._new();
  699. $recv($1)._setTestSelector_(aSelector);
  700. return $recv($1)._yourself();
  701. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  702. }, function($ctx1) {$ctx1.fill(self,"selector:",{aSelector:aSelector},$globals.TestCase.a$cls)});
  703. //>>excludeEnd("ctx");
  704. },
  705. //>>excludeStart("ide", pragmas.excludeIdeData);
  706. args: ["aSelector"],
  707. source: "selector: aSelector\x0a\x09^ self new\x0a\x09\x09setTestSelector: aSelector;\x0a\x09\x09yourself",
  708. referencedClasses: [],
  709. //>>excludeEnd("ide");
  710. messageSends: ["setTestSelector:", "new", "yourself"]
  711. }),
  712. $globals.TestCase.a$cls);
  713. $core.addMethod(
  714. $core.method({
  715. selector: "shouldInheritSelectors",
  716. protocol: "testing",
  717. fn: function (){
  718. var self=this,$self=this;
  719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  720. return $core.withContext(function($ctx1) {
  721. //>>excludeEnd("ctx");
  722. return $self.__tild_eq($self._lookupHierarchyRoot());
  723. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  724. }, function($ctx1) {$ctx1.fill(self,"shouldInheritSelectors",{},$globals.TestCase.a$cls)});
  725. //>>excludeEnd("ctx");
  726. },
  727. //>>excludeStart("ide", pragmas.excludeIdeData);
  728. args: [],
  729. source: "shouldInheritSelectors\x0a\x09^ self ~= self lookupHierarchyRoot",
  730. referencedClasses: [],
  731. //>>excludeEnd("ide");
  732. messageSends: ["~=", "lookupHierarchyRoot"]
  733. }),
  734. $globals.TestCase.a$cls);
  735. $core.addMethod(
  736. $core.method({
  737. selector: "testSelectors",
  738. protocol: "accessing",
  739. fn: function (){
  740. var self=this,$self=this;
  741. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  742. return $core.withContext(function($ctx1) {
  743. //>>excludeEnd("ctx");
  744. return $recv($recv($self._methodDictionary())._keys())._select_((function(each){
  745. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  746. return $core.withContext(function($ctx2) {
  747. //>>excludeEnd("ctx");
  748. return $recv(each)._match_("^test");
  749. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  750. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  751. //>>excludeEnd("ctx");
  752. }));
  753. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  754. }, function($ctx1) {$ctx1.fill(self,"testSelectors",{},$globals.TestCase.a$cls)});
  755. //>>excludeEnd("ctx");
  756. },
  757. //>>excludeStart("ide", pragmas.excludeIdeData);
  758. args: [],
  759. source: "testSelectors\x0a\x09^ self methodDictionary keys select: [ :each | each match: '^test' ]",
  760. referencedClasses: [],
  761. //>>excludeEnd("ide");
  762. messageSends: ["select:", "keys", "methodDictionary", "match:"]
  763. }),
  764. $globals.TestCase.a$cls);
  765. $core.addClass("TestContext", $globals.Object, ["testCase"], "SUnit");
  766. //>>excludeStart("ide", pragmas.excludeIdeData);
  767. $globals.TestContext.comment="I govern running a particular test case.\x0a\x0aMy main added value is `#execute:` method which runs a block as a part of test case (restores context, nilling it afterwards, cleaning/calling `#tearDown` as appropriate for sync/async scenario).";
  768. //>>excludeEnd("ide");
  769. $core.addMethod(
  770. $core.method({
  771. selector: "execute:",
  772. protocol: "running",
  773. fn: function (aBlock){
  774. var self=this,$self=this;
  775. var failed;
  776. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  777. return $core.withContext(function($ctx1) {
  778. //>>excludeEnd("ctx");
  779. var $1,$2;
  780. $recv($self["@testCase"])._context_(self);
  781. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  782. $ctx1.sendIdx["context:"]=1;
  783. //>>excludeEnd("ctx");
  784. $recv((function(){
  785. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  786. return $core.withContext(function($ctx2) {
  787. //>>excludeEnd("ctx");
  788. failed=true;
  789. failed;
  790. $recv(aBlock)._value();
  791. failed=false;
  792. return failed;
  793. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  794. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  795. //>>excludeEnd("ctx");
  796. }))._ensure_((function(){
  797. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  798. return $core.withContext(function($ctx2) {
  799. //>>excludeEnd("ctx");
  800. $recv($self["@testCase"])._context_(nil);
  801. $1=$recv(failed)._and_((function(){
  802. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  803. return $core.withContext(function($ctx3) {
  804. //>>excludeEnd("ctx");
  805. return $recv($self["@testCase"])._isAsync();
  806. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  807. $ctx3.sendIdx["isAsync"]=1;
  808. //>>excludeEnd("ctx");
  809. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  810. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
  811. //>>excludeEnd("ctx");
  812. }));
  813. if($core.assert($1)){
  814. $recv($self["@testCase"])._finished();
  815. }
  816. $2=$recv($self["@testCase"])._isAsync();
  817. if(!$core.assert($2)){
  818. return $recv($self["@testCase"])._tearDown();
  819. }
  820. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  821. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  822. //>>excludeEnd("ctx");
  823. }));
  824. return self;
  825. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  826. }, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock,failed:failed},$globals.TestContext)});
  827. //>>excludeEnd("ctx");
  828. },
  829. //>>excludeStart("ide", pragmas.excludeIdeData);
  830. args: ["aBlock"],
  831. source: "execute: aBlock\x0a\x09| failed |\x0a\x09\x0a\x09testCase context: self.\x0a\x09[\x0a\x09\x09failed := true.\x0a\x09\x09aBlock value.\x0a\x09\x09failed := false\x0a\x09]\x0a\x09\x09ensure: [\x0a\x09\x09\x09testCase context: nil.\x0a\x09\x09\x09\x0a\x09\x09\x09(failed and: [ testCase isAsync ]) ifTrue: [\x0a\x09\x09\x09\x09testCase finished ].\x0a\x09\x09\x09testCase isAsync ifFalse: [\x0a\x09\x09\x09\x09testCase tearDown ] ]",
  832. referencedClasses: [],
  833. //>>excludeEnd("ide");
  834. messageSends: ["context:", "ensure:", "value", "ifTrue:", "and:", "isAsync", "finished", "ifFalse:", "tearDown"]
  835. }),
  836. $globals.TestContext);
  837. $core.addMethod(
  838. $core.method({
  839. selector: "start",
  840. protocol: "running",
  841. fn: function (){
  842. var self=this,$self=this;
  843. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  844. return $core.withContext(function($ctx1) {
  845. //>>excludeEnd("ctx");
  846. $self._execute_((function(){
  847. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  848. return $core.withContext(function($ctx2) {
  849. //>>excludeEnd("ctx");
  850. $recv($self["@testCase"])._setUp();
  851. return $recv($self["@testCase"])._performTest();
  852. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  853. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  854. //>>excludeEnd("ctx");
  855. }));
  856. return self;
  857. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  858. }, function($ctx1) {$ctx1.fill(self,"start",{},$globals.TestContext)});
  859. //>>excludeEnd("ctx");
  860. },
  861. //>>excludeStart("ide", pragmas.excludeIdeData);
  862. args: [],
  863. source: "start\x0a\x09self execute: [\x0a\x09\x09testCase setUp.\x0a\x09\x09testCase performTest ]",
  864. referencedClasses: [],
  865. //>>excludeEnd("ide");
  866. messageSends: ["execute:", "setUp", "performTest"]
  867. }),
  868. $globals.TestContext);
  869. $core.addMethod(
  870. $core.method({
  871. selector: "testCase:",
  872. protocol: "accessing",
  873. fn: function (aTestCase){
  874. var self=this,$self=this;
  875. $self["@testCase"]=aTestCase;
  876. return self;
  877. },
  878. //>>excludeStart("ide", pragmas.excludeIdeData);
  879. args: ["aTestCase"],
  880. source: "testCase: aTestCase\x0a\x09testCase := aTestCase",
  881. referencedClasses: [],
  882. //>>excludeEnd("ide");
  883. messageSends: []
  884. }),
  885. $globals.TestContext);
  886. $core.addMethod(
  887. $core.method({
  888. selector: "testCase:",
  889. protocol: "instance creation",
  890. fn: function (aTestCase){
  891. var self=this,$self=this;
  892. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  893. return $core.withContext(function($ctx1) {
  894. //>>excludeEnd("ctx");
  895. var $1;
  896. $1=$self._new();
  897. $recv($1)._testCase_(aTestCase);
  898. return $recv($1)._yourself();
  899. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  900. }, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase},$globals.TestContext.a$cls)});
  901. //>>excludeEnd("ctx");
  902. },
  903. //>>excludeStart("ide", pragmas.excludeIdeData);
  904. args: ["aTestCase"],
  905. source: "testCase: aTestCase\x0a\x09^ self new\x0a\x09\x09testCase: aTestCase;\x0a\x09\x09yourself",
  906. referencedClasses: [],
  907. //>>excludeEnd("ide");
  908. messageSends: ["testCase:", "new", "yourself"]
  909. }),
  910. $globals.TestContext.a$cls);
  911. $core.addClass("ReportingTestContext", $globals.TestContext, ["finished", "result"], "SUnit");
  912. //>>excludeStart("ide", pragmas.excludeIdeData);
  913. $globals.ReportingTestContext.comment="I add `TestResult` reporting to `TestContext`.\x0a\x0aErrors are caught and save into a `TestResult`,\x0aWhen test case is finished (which can be later for async tests), a callback block is executed; this is used by a `TestSuiteRunner`.";
  914. //>>excludeEnd("ide");
  915. $core.addMethod(
  916. $core.method({
  917. selector: "execute:",
  918. protocol: "running",
  919. fn: function (aBlock){
  920. var self=this,$self=this;
  921. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  922. return $core.withContext(function($ctx1) {
  923. //>>excludeEnd("ctx");
  924. var $1;
  925. $recv((function(){
  926. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  927. return $core.withContext(function($ctx2) {
  928. //>>excludeEnd("ctx");
  929. return $self._withErrorReporting_((function(){
  930. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  931. return $core.withContext(function($ctx3) {
  932. //>>excludeEnd("ctx");
  933. return (
  934. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  935. $ctx3.supercall = true,
  936. //>>excludeEnd("ctx");
  937. ($globals.ReportingTestContext.superclass||$boot.nilAsClass).fn.prototype._execute_.apply($self, [aBlock]));
  938. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  939. $ctx3.supercall = false;
  940. //>>excludeEnd("ctx");;
  941. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  942. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  943. //>>excludeEnd("ctx");
  944. }));
  945. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  946. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  947. //>>excludeEnd("ctx");
  948. }))._ensure_((function(){
  949. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  950. return $core.withContext(function($ctx2) {
  951. //>>excludeEnd("ctx");
  952. $1=$recv($self["@testCase"])._isAsync();
  953. if(!$core.assert($1)){
  954. $recv($self["@result"])._increaseRuns();
  955. return $recv($self["@finished"])._value();
  956. }
  957. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  958. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  959. //>>excludeEnd("ctx");
  960. }));
  961. return self;
  962. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  963. }, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock},$globals.ReportingTestContext)});
  964. //>>excludeEnd("ctx");
  965. },
  966. //>>excludeStart("ide", pragmas.excludeIdeData);
  967. args: ["aBlock"],
  968. source: "execute: aBlock\x0a\x09[\x0a\x09\x09self withErrorReporting: [ super execute: aBlock ]\x0a\x09]\x0a\x09\x09ensure: [\x0a\x09\x09\x09testCase isAsync ifFalse: [\x0a\x09\x09\x09\x09result increaseRuns. finished value ] ]",
  969. referencedClasses: [],
  970. //>>excludeEnd("ide");
  971. messageSends: ["ensure:", "withErrorReporting:", "execute:", "ifFalse:", "isAsync", "increaseRuns", "value"]
  972. }),
  973. $globals.ReportingTestContext);
  974. $core.addMethod(
  975. $core.method({
  976. selector: "finished:",
  977. protocol: "accessing",
  978. fn: function (aBlock){
  979. var self=this,$self=this;
  980. $self["@finished"]=aBlock;
  981. return self;
  982. },
  983. //>>excludeStart("ide", pragmas.excludeIdeData);
  984. args: ["aBlock"],
  985. source: "finished: aBlock\x0a\x09finished := aBlock",
  986. referencedClasses: [],
  987. //>>excludeEnd("ide");
  988. messageSends: []
  989. }),
  990. $globals.ReportingTestContext);
  991. $core.addMethod(
  992. $core.method({
  993. selector: "result:",
  994. protocol: "accessing",
  995. fn: function (aTestResult){
  996. var self=this,$self=this;
  997. $self["@result"]=aTestResult;
  998. return self;
  999. },
  1000. //>>excludeStart("ide", pragmas.excludeIdeData);
  1001. args: ["aTestResult"],
  1002. source: "result: aTestResult\x0a\x09result := aTestResult",
  1003. referencedClasses: [],
  1004. //>>excludeEnd("ide");
  1005. messageSends: []
  1006. }),
  1007. $globals.ReportingTestContext);
  1008. $core.addMethod(
  1009. $core.method({
  1010. selector: "withErrorReporting:",
  1011. protocol: "private",
  1012. fn: function (aBlock){
  1013. var self=this,$self=this;
  1014. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1015. return $core.withContext(function($ctx1) {
  1016. //>>excludeEnd("ctx");
  1017. $recv((function(){
  1018. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1019. return $core.withContext(function($ctx2) {
  1020. //>>excludeEnd("ctx");
  1021. return $recv(aBlock)._on_do_($globals.TestFailure,(function(ex){
  1022. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1023. return $core.withContext(function($ctx3) {
  1024. //>>excludeEnd("ctx");
  1025. return $recv($self["@result"])._addFailure_($self["@testCase"]);
  1026. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1027. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx2,2)});
  1028. //>>excludeEnd("ctx");
  1029. }));
  1030. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1031. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1032. //>>excludeEnd("ctx");
  1033. }))._on_do_($globals.Error,(function(ex){
  1034. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1035. return $core.withContext(function($ctx2) {
  1036. //>>excludeEnd("ctx");
  1037. return $recv($self["@result"])._addError_($self["@testCase"]);
  1038. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1039. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,3)});
  1040. //>>excludeEnd("ctx");
  1041. }));
  1042. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1043. $ctx1.sendIdx["on:do:"]=1;
  1044. //>>excludeEnd("ctx");
  1045. return self;
  1046. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1047. }, function($ctx1) {$ctx1.fill(self,"withErrorReporting:",{aBlock:aBlock},$globals.ReportingTestContext)});
  1048. //>>excludeEnd("ctx");
  1049. },
  1050. //>>excludeStart("ide", pragmas.excludeIdeData);
  1051. args: ["aBlock"],
  1052. source: "withErrorReporting: aBlock\x0a\x09[ aBlock\x0a\x09\x09on: TestFailure\x0a\x09\x09do: [ :ex | result addFailure: testCase ]\x0a\x09]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :ex | result addError: testCase ]",
  1053. referencedClasses: ["TestFailure", "Error"],
  1054. //>>excludeEnd("ide");
  1055. messageSends: ["on:do:", "addFailure:", "addError:"]
  1056. }),
  1057. $globals.ReportingTestContext);
  1058. $core.addMethod(
  1059. $core.method({
  1060. selector: "testCase:result:finished:",
  1061. protocol: "instance creation",
  1062. fn: function (aTestCase,aTestResult,aBlock){
  1063. var self=this,$self=this;
  1064. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1065. return $core.withContext(function($ctx1) {
  1066. //>>excludeEnd("ctx");
  1067. var $1;
  1068. $1=(
  1069. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1070. $ctx1.supercall = true,
  1071. //>>excludeEnd("ctx");
  1072. ($globals.ReportingTestContext.a$cls.superclass||$boot.nilAsClass).fn.prototype._testCase_.apply($self, [aTestCase]));
  1073. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1074. $ctx1.supercall = false;
  1075. //>>excludeEnd("ctx");;
  1076. $recv($1)._result_(aTestResult);
  1077. $recv($1)._finished_(aBlock);
  1078. return $recv($1)._yourself();
  1079. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1080. }, function($ctx1) {$ctx1.fill(self,"testCase:result:finished:",{aTestCase:aTestCase,aTestResult:aTestResult,aBlock:aBlock},$globals.ReportingTestContext.a$cls)});
  1081. //>>excludeEnd("ctx");
  1082. },
  1083. //>>excludeStart("ide", pragmas.excludeIdeData);
  1084. args: ["aTestCase", "aTestResult", "aBlock"],
  1085. source: "testCase: aTestCase result: aTestResult finished: aBlock\x0a\x09^ (super testCase: aTestCase)\x0a\x09\x09result: aTestResult;\x0a\x09\x09finished: aBlock;\x0a\x09\x09yourself",
  1086. referencedClasses: [],
  1087. //>>excludeEnd("ide");
  1088. messageSends: ["result:", "testCase:", "finished:", "yourself"]
  1089. }),
  1090. $globals.ReportingTestContext.a$cls);
  1091. $core.addClass("TestFailure", $globals.Error, [], "SUnit");
  1092. //>>excludeStart("ide", pragmas.excludeIdeData);
  1093. $globals.TestFailure.comment="I am raised when the boolean parameter of an #`assert:` or `#deny:` call is the opposite of what the assertion claims.\x0a\x0aThe test framework distinguishes between failures and errors.\x0aA failure is an event whose possibiity is explicitly anticipated and checked for in an assertion,\x0awhereas an error is an unanticipated problem like a division by 0 or an index out of bounds.";
  1094. //>>excludeEnd("ide");
  1095. $core.addClass("TestResult", $globals.Object, ["timestamp", "runs", "errors", "failures", "total"], "SUnit");
  1096. //>>excludeStart("ide", pragmas.excludeIdeData);
  1097. $globals.TestResult.comment="I implement the collecting parameter pattern for running a bunch of tests.\x0a\x0aMy instances hold tests that have run, sorted into the result categories of passed, failures and errors.\x0a\x0a`TestResult` is an interesting object to subclass or substitute. `#runCase:` is the external protocol you need to reproduce";
  1098. //>>excludeEnd("ide");
  1099. $core.addMethod(
  1100. $core.method({
  1101. selector: "addError:",
  1102. protocol: "accessing",
  1103. fn: function (anError){
  1104. var self=this,$self=this;
  1105. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1106. return $core.withContext(function($ctx1) {
  1107. //>>excludeEnd("ctx");
  1108. $recv($self._errors())._add_(anError);
  1109. return self;
  1110. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1111. }, function($ctx1) {$ctx1.fill(self,"addError:",{anError:anError},$globals.TestResult)});
  1112. //>>excludeEnd("ctx");
  1113. },
  1114. //>>excludeStart("ide", pragmas.excludeIdeData);
  1115. args: ["anError"],
  1116. source: "addError: anError\x0a\x09self errors add: anError",
  1117. referencedClasses: [],
  1118. //>>excludeEnd("ide");
  1119. messageSends: ["add:", "errors"]
  1120. }),
  1121. $globals.TestResult);
  1122. $core.addMethod(
  1123. $core.method({
  1124. selector: "addFailure:",
  1125. protocol: "accessing",
  1126. fn: function (aFailure){
  1127. var self=this,$self=this;
  1128. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1129. return $core.withContext(function($ctx1) {
  1130. //>>excludeEnd("ctx");
  1131. $recv($self._failures())._add_(aFailure);
  1132. return self;
  1133. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1134. }, function($ctx1) {$ctx1.fill(self,"addFailure:",{aFailure:aFailure},$globals.TestResult)});
  1135. //>>excludeEnd("ctx");
  1136. },
  1137. //>>excludeStart("ide", pragmas.excludeIdeData);
  1138. args: ["aFailure"],
  1139. source: "addFailure: aFailure\x0a\x09self failures add: aFailure",
  1140. referencedClasses: [],
  1141. //>>excludeEnd("ide");
  1142. messageSends: ["add:", "failures"]
  1143. }),
  1144. $globals.TestResult);
  1145. $core.addMethod(
  1146. $core.method({
  1147. selector: "errors",
  1148. protocol: "accessing",
  1149. fn: function (){
  1150. var self=this,$self=this;
  1151. return $self["@errors"];
  1152. },
  1153. //>>excludeStart("ide", pragmas.excludeIdeData);
  1154. args: [],
  1155. source: "errors\x0a\x09^ errors",
  1156. referencedClasses: [],
  1157. //>>excludeEnd("ide");
  1158. messageSends: []
  1159. }),
  1160. $globals.TestResult);
  1161. $core.addMethod(
  1162. $core.method({
  1163. selector: "failures",
  1164. protocol: "accessing",
  1165. fn: function (){
  1166. var self=this,$self=this;
  1167. return $self["@failures"];
  1168. },
  1169. //>>excludeStart("ide", pragmas.excludeIdeData);
  1170. args: [],
  1171. source: "failures\x0a\x09^ failures",
  1172. referencedClasses: [],
  1173. //>>excludeEnd("ide");
  1174. messageSends: []
  1175. }),
  1176. $globals.TestResult);
  1177. $core.addMethod(
  1178. $core.method({
  1179. selector: "increaseRuns",
  1180. protocol: "accessing",
  1181. fn: function (){
  1182. var self=this,$self=this;
  1183. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1184. return $core.withContext(function($ctx1) {
  1185. //>>excludeEnd("ctx");
  1186. $self["@runs"]=$recv($self["@runs"]).__plus((1));
  1187. return self;
  1188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1189. }, function($ctx1) {$ctx1.fill(self,"increaseRuns",{},$globals.TestResult)});
  1190. //>>excludeEnd("ctx");
  1191. },
  1192. //>>excludeStart("ide", pragmas.excludeIdeData);
  1193. args: [],
  1194. source: "increaseRuns\x0a\x09runs := runs + 1",
  1195. referencedClasses: [],
  1196. //>>excludeEnd("ide");
  1197. messageSends: ["+"]
  1198. }),
  1199. $globals.TestResult);
  1200. $core.addMethod(
  1201. $core.method({
  1202. selector: "initialize",
  1203. protocol: "initialization",
  1204. fn: function (){
  1205. var self=this,$self=this;
  1206. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1207. return $core.withContext(function($ctx1) {
  1208. //>>excludeEnd("ctx");
  1209. (
  1210. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1211. $ctx1.supercall = true,
  1212. //>>excludeEnd("ctx");
  1213. ($globals.TestResult.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  1214. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1215. $ctx1.supercall = false;
  1216. //>>excludeEnd("ctx");;
  1217. $self["@timestamp"]=$recv($globals.Date)._now();
  1218. $self["@runs"]=(0);
  1219. $self["@errors"]=$recv($globals.Array)._new();
  1220. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1221. $ctx1.sendIdx["new"]=1;
  1222. //>>excludeEnd("ctx");
  1223. $self["@failures"]=$recv($globals.Array)._new();
  1224. $self["@total"]=(0);
  1225. return self;
  1226. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1227. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.TestResult)});
  1228. //>>excludeEnd("ctx");
  1229. },
  1230. //>>excludeStart("ide", pragmas.excludeIdeData);
  1231. args: [],
  1232. source: "initialize\x0a\x09super initialize.\x0a\x09timestamp := Date now.\x0a\x09runs := 0.\x0a\x09errors := Array new.\x0a\x09failures := Array new.\x0a\x09total := 0",
  1233. referencedClasses: ["Date", "Array"],
  1234. //>>excludeEnd("ide");
  1235. messageSends: ["initialize", "now", "new"]
  1236. }),
  1237. $globals.TestResult);
  1238. $core.addMethod(
  1239. $core.method({
  1240. selector: "nextRunDo:",
  1241. protocol: "running",
  1242. fn: function (aBlock){
  1243. var self=this,$self=this;
  1244. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1245. return $core.withContext(function($ctx1) {
  1246. //>>excludeEnd("ctx");
  1247. var $2,$1;
  1248. $2=$self._runs();
  1249. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1250. $ctx1.sendIdx["runs"]=1;
  1251. //>>excludeEnd("ctx");
  1252. $1=$recv($2).__eq_eq($self._total());
  1253. if(!$core.assert($1)){
  1254. return $recv(aBlock)._value_($recv($self._runs()).__plus((1)));
  1255. }
  1256. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1257. }, function($ctx1) {$ctx1.fill(self,"nextRunDo:",{aBlock:aBlock},$globals.TestResult)});
  1258. //>>excludeEnd("ctx");
  1259. },
  1260. //>>excludeStart("ide", pragmas.excludeIdeData);
  1261. args: ["aBlock"],
  1262. source: "nextRunDo: aBlock\x0a\x09\x22Runs aBlock with index of next run or does nothing if no more runs\x22\x0a\x09^ self runs == self total\x0a\x09\x09ifFalse: [ aBlock value: self runs + 1 ]",
  1263. referencedClasses: [],
  1264. //>>excludeEnd("ide");
  1265. messageSends: ["ifFalse:", "==", "runs", "total", "value:", "+"]
  1266. }),
  1267. $globals.TestResult);
  1268. $core.addMethod(
  1269. $core.method({
  1270. selector: "runCase:",
  1271. protocol: "running",
  1272. fn: function (aTestCase){
  1273. var self=this,$self=this;
  1274. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1275. return $core.withContext(function($ctx1) {
  1276. //>>excludeEnd("ctx");
  1277. $recv((function(){
  1278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1279. return $core.withContext(function($ctx2) {
  1280. //>>excludeEnd("ctx");
  1281. return $recv((function(){
  1282. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1283. return $core.withContext(function($ctx3) {
  1284. //>>excludeEnd("ctx");
  1285. $self._increaseRuns();
  1286. return $recv(aTestCase)._runCase();
  1287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1288. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  1289. //>>excludeEnd("ctx");
  1290. }))._on_do_($globals.TestFailure,(function(ex){
  1291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1292. return $core.withContext(function($ctx3) {
  1293. //>>excludeEnd("ctx");
  1294. return $self._addFailure_(aTestCase);
  1295. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1296. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx2,3)});
  1297. //>>excludeEnd("ctx");
  1298. }));
  1299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1300. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1301. //>>excludeEnd("ctx");
  1302. }))._on_do_($globals.Error,(function(ex){
  1303. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1304. return $core.withContext(function($ctx2) {
  1305. //>>excludeEnd("ctx");
  1306. return $self._addError_(aTestCase);
  1307. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1308. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,4)});
  1309. //>>excludeEnd("ctx");
  1310. }));
  1311. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1312. $ctx1.sendIdx["on:do:"]=1;
  1313. //>>excludeEnd("ctx");
  1314. return self;
  1315. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1316. }, function($ctx1) {$ctx1.fill(self,"runCase:",{aTestCase:aTestCase},$globals.TestResult)});
  1317. //>>excludeEnd("ctx");
  1318. },
  1319. //>>excludeStart("ide", pragmas.excludeIdeData);
  1320. args: ["aTestCase"],
  1321. source: "runCase: aTestCase\x0a\x09[ [ self increaseRuns.\x0a\x09\x09aTestCase runCase ]\x0a\x09on: TestFailure do: [ :ex | self addFailure: aTestCase ]]\x0a\x09on: Error do: [ :ex | self addError: aTestCase ]",
  1322. referencedClasses: ["TestFailure", "Error"],
  1323. //>>excludeEnd("ide");
  1324. messageSends: ["on:do:", "increaseRuns", "runCase", "addFailure:", "addError:"]
  1325. }),
  1326. $globals.TestResult);
  1327. $core.addMethod(
  1328. $core.method({
  1329. selector: "runs",
  1330. protocol: "accessing",
  1331. fn: function (){
  1332. var self=this,$self=this;
  1333. return $self["@runs"];
  1334. },
  1335. //>>excludeStart("ide", pragmas.excludeIdeData);
  1336. args: [],
  1337. source: "runs\x0a\x09^ runs",
  1338. referencedClasses: [],
  1339. //>>excludeEnd("ide");
  1340. messageSends: []
  1341. }),
  1342. $globals.TestResult);
  1343. $core.addMethod(
  1344. $core.method({
  1345. selector: "status",
  1346. protocol: "accessing",
  1347. fn: function (){
  1348. var self=this,$self=this;
  1349. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1350. return $core.withContext(function($ctx1) {
  1351. //>>excludeEnd("ctx");
  1352. var $1;
  1353. $1=$recv($self._errors())._ifNotEmpty_ifEmpty_((function(){
  1354. return "error";
  1355. }),(function(){
  1356. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1357. return $core.withContext(function($ctx2) {
  1358. //>>excludeEnd("ctx");
  1359. return $recv($self._failures())._ifNotEmpty_ifEmpty_((function(){
  1360. return "failure";
  1361. }),(function(){
  1362. return "success";
  1363. }));
  1364. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1365. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1366. //>>excludeEnd("ctx");
  1367. }));
  1368. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1369. $ctx1.sendIdx["ifNotEmpty:ifEmpty:"]=1;
  1370. //>>excludeEnd("ctx");
  1371. return $1;
  1372. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1373. }, function($ctx1) {$ctx1.fill(self,"status",{},$globals.TestResult)});
  1374. //>>excludeEnd("ctx");
  1375. },
  1376. //>>excludeStart("ide", pragmas.excludeIdeData);
  1377. args: [],
  1378. source: "status\x0a\x09^ self errors ifNotEmpty: [ 'error' ] ifEmpty: [\x0a\x09\x09self failures ifNotEmpty: [ 'failure' ] ifEmpty: [\x0a\x09\x09\x09'success' ]]",
  1379. referencedClasses: [],
  1380. //>>excludeEnd("ide");
  1381. messageSends: ["ifNotEmpty:ifEmpty:", "errors", "failures"]
  1382. }),
  1383. $globals.TestResult);
  1384. $core.addMethod(
  1385. $core.method({
  1386. selector: "timestamp",
  1387. protocol: "accessing",
  1388. fn: function (){
  1389. var self=this,$self=this;
  1390. return $self["@timestamp"];
  1391. },
  1392. //>>excludeStart("ide", pragmas.excludeIdeData);
  1393. args: [],
  1394. source: "timestamp\x0a\x09^ timestamp",
  1395. referencedClasses: [],
  1396. //>>excludeEnd("ide");
  1397. messageSends: []
  1398. }),
  1399. $globals.TestResult);
  1400. $core.addMethod(
  1401. $core.method({
  1402. selector: "total",
  1403. protocol: "accessing",
  1404. fn: function (){
  1405. var self=this,$self=this;
  1406. return $self["@total"];
  1407. },
  1408. //>>excludeStart("ide", pragmas.excludeIdeData);
  1409. args: [],
  1410. source: "total\x0a\x09^ total",
  1411. referencedClasses: [],
  1412. //>>excludeEnd("ide");
  1413. messageSends: []
  1414. }),
  1415. $globals.TestResult);
  1416. $core.addMethod(
  1417. $core.method({
  1418. selector: "total:",
  1419. protocol: "accessing",
  1420. fn: function (aNumber){
  1421. var self=this,$self=this;
  1422. $self["@total"]=aNumber;
  1423. return self;
  1424. },
  1425. //>>excludeStart("ide", pragmas.excludeIdeData);
  1426. args: ["aNumber"],
  1427. source: "total: aNumber\x0a\x09total := aNumber",
  1428. referencedClasses: [],
  1429. //>>excludeEnd("ide");
  1430. messageSends: []
  1431. }),
  1432. $globals.TestResult);
  1433. $core.addClass("TestSuiteRunner", $globals.Object, ["suite", "result", "announcer", "runNextTest"], "SUnit");
  1434. //>>excludeStart("ide", pragmas.excludeIdeData);
  1435. $globals.TestSuiteRunner.comment="I am responsible for running a collection (`suite`) of tests.\x0a\x0a## API\x0a\x0aInstances should be created using the class-side `#on:` method, taking a collection of tests to run as parameter.\x0aTo run the test suite, use `#run`.";
  1436. //>>excludeEnd("ide");
  1437. $core.addMethod(
  1438. $core.method({
  1439. selector: "announcer",
  1440. protocol: "accessing",
  1441. fn: function (){
  1442. var self=this,$self=this;
  1443. return $self["@announcer"];
  1444. },
  1445. //>>excludeStart("ide", pragmas.excludeIdeData);
  1446. args: [],
  1447. source: "announcer\x0a\x09^ announcer",
  1448. referencedClasses: [],
  1449. //>>excludeEnd("ide");
  1450. messageSends: []
  1451. }),
  1452. $globals.TestSuiteRunner);
  1453. $core.addMethod(
  1454. $core.method({
  1455. selector: "contextOf:",
  1456. protocol: "private",
  1457. fn: function (anInteger){
  1458. var self=this,$self=this;
  1459. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1460. return $core.withContext(function($ctx1) {
  1461. //>>excludeEnd("ctx");
  1462. return $recv($globals.ReportingTestContext)._testCase_result_finished_($recv($self["@suite"])._at_(anInteger),$self["@result"],(function(){
  1463. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1464. return $core.withContext(function($ctx2) {
  1465. //>>excludeEnd("ctx");
  1466. return $self._resume();
  1467. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1468. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1469. //>>excludeEnd("ctx");
  1470. }));
  1471. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1472. }, function($ctx1) {$ctx1.fill(self,"contextOf:",{anInteger:anInteger},$globals.TestSuiteRunner)});
  1473. //>>excludeEnd("ctx");
  1474. },
  1475. //>>excludeStart("ide", pragmas.excludeIdeData);
  1476. args: ["anInteger"],
  1477. source: "contextOf: anInteger\x0a\x09^ ReportingTestContext testCase: (suite at: anInteger) result: result finished: [ self resume ]",
  1478. referencedClasses: ["ReportingTestContext"],
  1479. //>>excludeEnd("ide");
  1480. messageSends: ["testCase:result:finished:", "at:", "resume"]
  1481. }),
  1482. $globals.TestSuiteRunner);
  1483. $core.addMethod(
  1484. $core.method({
  1485. selector: "initialize",
  1486. protocol: "initialization",
  1487. fn: function (){
  1488. var self=this,$self=this;
  1489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1490. return $core.withContext(function($ctx1) {
  1491. //>>excludeEnd("ctx");
  1492. var $1;
  1493. (
  1494. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1495. $ctx1.supercall = true,
  1496. //>>excludeEnd("ctx");
  1497. ($globals.TestSuiteRunner.superclass||$boot.nilAsClass).fn.prototype._initialize.apply($self, []));
  1498. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1499. $ctx1.supercall = false;
  1500. //>>excludeEnd("ctx");;
  1501. $self["@announcer"]=$recv($globals.Announcer)._new();
  1502. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1503. $ctx1.sendIdx["new"]=1;
  1504. //>>excludeEnd("ctx");
  1505. $self["@result"]=$recv($globals.TestResult)._new();
  1506. $self["@runNextTest"]=(function(){
  1507. var runs;
  1508. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1509. return $core.withContext(function($ctx2) {
  1510. //>>excludeEnd("ctx");
  1511. runs=$recv($self["@result"])._runs();
  1512. runs;
  1513. $1=$recv(runs).__lt($recv($self["@result"])._total());
  1514. if($core.assert($1)){
  1515. return $recv($self._contextOf_($recv(runs).__plus((1))))._start();
  1516. }
  1517. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1518. }, function($ctx2) {$ctx2.fillBlock({runs:runs},$ctx1,1)});
  1519. //>>excludeEnd("ctx");
  1520. });
  1521. return self;
  1522. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1523. }, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.TestSuiteRunner)});
  1524. //>>excludeEnd("ctx");
  1525. },
  1526. //>>excludeStart("ide", pragmas.excludeIdeData);
  1527. args: [],
  1528. source: "initialize\x0a\x09super initialize.\x0a\x09announcer := Announcer new.\x0a\x09result := TestResult new.\x0a\x09runNextTest := [ | runs | runs := result runs. runs < result total ifTrue: [ (self contextOf: runs + 1) start ] ].",
  1529. referencedClasses: ["Announcer", "TestResult"],
  1530. //>>excludeEnd("ide");
  1531. messageSends: ["initialize", "new", "runs", "ifTrue:", "<", "total", "start", "contextOf:", "+"]
  1532. }),
  1533. $globals.TestSuiteRunner);
  1534. $core.addMethod(
  1535. $core.method({
  1536. selector: "result",
  1537. protocol: "accessing",
  1538. fn: function (){
  1539. var self=this,$self=this;
  1540. return $self["@result"];
  1541. },
  1542. //>>excludeStart("ide", pragmas.excludeIdeData);
  1543. args: [],
  1544. source: "result\x0a\x09^ result",
  1545. referencedClasses: [],
  1546. //>>excludeEnd("ide");
  1547. messageSends: []
  1548. }),
  1549. $globals.TestSuiteRunner);
  1550. $core.addMethod(
  1551. $core.method({
  1552. selector: "resume",
  1553. protocol: "actions",
  1554. fn: function (){
  1555. var self=this,$self=this;
  1556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1557. return $core.withContext(function($ctx1) {
  1558. //>>excludeEnd("ctx");
  1559. $recv($self["@runNextTest"])._fork();
  1560. $recv($self["@announcer"])._announce_($recv($recv($globals.ResultAnnouncement)._new())._result_($self["@result"]));
  1561. return self;
  1562. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1563. }, function($ctx1) {$ctx1.fill(self,"resume",{},$globals.TestSuiteRunner)});
  1564. //>>excludeEnd("ctx");
  1565. },
  1566. //>>excludeStart("ide", pragmas.excludeIdeData);
  1567. args: [],
  1568. source: "resume\x0a\x09runNextTest fork.\x0a\x09announcer announce: (ResultAnnouncement new result: result)",
  1569. referencedClasses: ["ResultAnnouncement"],
  1570. //>>excludeEnd("ide");
  1571. messageSends: ["fork", "announce:", "result:", "new"]
  1572. }),
  1573. $globals.TestSuiteRunner);
  1574. $core.addMethod(
  1575. $core.method({
  1576. selector: "run",
  1577. protocol: "actions",
  1578. fn: function (){
  1579. var self=this,$self=this;
  1580. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1581. return $core.withContext(function($ctx1) {
  1582. //>>excludeEnd("ctx");
  1583. $recv($self["@result"])._total_($recv($self["@suite"])._size());
  1584. $self._resume();
  1585. return self;
  1586. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1587. }, function($ctx1) {$ctx1.fill(self,"run",{},$globals.TestSuiteRunner)});
  1588. //>>excludeEnd("ctx");
  1589. },
  1590. //>>excludeStart("ide", pragmas.excludeIdeData);
  1591. args: [],
  1592. source: "run\x0a\x09result total: suite size.\x0a\x09self resume",
  1593. referencedClasses: [],
  1594. //>>excludeEnd("ide");
  1595. messageSends: ["total:", "size", "resume"]
  1596. }),
  1597. $globals.TestSuiteRunner);
  1598. $core.addMethod(
  1599. $core.method({
  1600. selector: "suite:",
  1601. protocol: "accessing",
  1602. fn: function (aCollection){
  1603. var self=this,$self=this;
  1604. $self["@suite"]=aCollection;
  1605. return self;
  1606. },
  1607. //>>excludeStart("ide", pragmas.excludeIdeData);
  1608. args: ["aCollection"],
  1609. source: "suite: aCollection\x0a\x09suite := aCollection",
  1610. referencedClasses: [],
  1611. //>>excludeEnd("ide");
  1612. messageSends: []
  1613. }),
  1614. $globals.TestSuiteRunner);
  1615. $core.addMethod(
  1616. $core.method({
  1617. selector: "new",
  1618. protocol: "instance creation",
  1619. fn: function (){
  1620. var self=this,$self=this;
  1621. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1622. return $core.withContext(function($ctx1) {
  1623. //>>excludeEnd("ctx");
  1624. $self._shouldNotImplement();
  1625. return self;
  1626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1627. }, function($ctx1) {$ctx1.fill(self,"new",{},$globals.TestSuiteRunner.a$cls)});
  1628. //>>excludeEnd("ctx");
  1629. },
  1630. //>>excludeStart("ide", pragmas.excludeIdeData);
  1631. args: [],
  1632. source: "new\x0a\x09self shouldNotImplement",
  1633. referencedClasses: [],
  1634. //>>excludeEnd("ide");
  1635. messageSends: ["shouldNotImplement"]
  1636. }),
  1637. $globals.TestSuiteRunner.a$cls);
  1638. $core.addMethod(
  1639. $core.method({
  1640. selector: "on:",
  1641. protocol: "instance creation",
  1642. fn: function (aCollection){
  1643. var self=this,$self=this;
  1644. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1645. return $core.withContext(function($ctx1) {
  1646. //>>excludeEnd("ctx");
  1647. var $1;
  1648. $1=(
  1649. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1650. $ctx1.supercall = true,
  1651. //>>excludeEnd("ctx");
  1652. ($globals.TestSuiteRunner.a$cls.superclass||$boot.nilAsClass).fn.prototype._new.apply($self, []));
  1653. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1654. $ctx1.supercall = false;
  1655. //>>excludeEnd("ctx");;
  1656. return $recv($1)._suite_(aCollection);
  1657. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1658. }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection},$globals.TestSuiteRunner.a$cls)});
  1659. //>>excludeEnd("ctx");
  1660. },
  1661. //>>excludeStart("ide", pragmas.excludeIdeData);
  1662. args: ["aCollection"],
  1663. source: "on: aCollection\x0a\x09^ super new suite: aCollection",
  1664. referencedClasses: [],
  1665. //>>excludeEnd("ide");
  1666. messageSends: ["suite:", "new"]
  1667. }),
  1668. $globals.TestSuiteRunner.a$cls);
  1669. $core.addMethod(
  1670. $core.method({
  1671. selector: "isTestPackage",
  1672. protocol: "*SUnit",
  1673. fn: function (){
  1674. var self=this,$self=this;
  1675. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1676. return $core.withContext(function($ctx1) {
  1677. //>>excludeEnd("ctx");
  1678. return $recv($self._classes())._anySatisfy_((function(each){
  1679. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1680. return $core.withContext(function($ctx2) {
  1681. //>>excludeEnd("ctx");
  1682. return $recv(each)._isTestClass();
  1683. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1684. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1685. //>>excludeEnd("ctx");
  1686. }));
  1687. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1688. }, function($ctx1) {$ctx1.fill(self,"isTestPackage",{},$globals.Package)});
  1689. //>>excludeEnd("ctx");
  1690. },
  1691. //>>excludeStart("ide", pragmas.excludeIdeData);
  1692. args: [],
  1693. source: "isTestPackage\x0a\x09^ self classes anySatisfy: [ :each | each isTestClass ]",
  1694. referencedClasses: [],
  1695. //>>excludeEnd("ide");
  1696. messageSends: ["anySatisfy:", "classes", "isTestClass"]
  1697. }),
  1698. $globals.Package);
  1699. $core.addMethod(
  1700. $core.method({
  1701. selector: "isTestClass",
  1702. protocol: "*SUnit",
  1703. fn: function (){
  1704. var self=this,$self=this;
  1705. return false;
  1706. },
  1707. //>>excludeStart("ide", pragmas.excludeIdeData);
  1708. args: [],
  1709. source: "isTestClass\x0a\x09^ false",
  1710. referencedClasses: [],
  1711. //>>excludeEnd("ide");
  1712. messageSends: []
  1713. }),
  1714. $globals.TBehaviorDefaults);
  1715. });