SUnit.js 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. smalltalk.addPackage('SUnit');
  2. smalltalk.addClass('ResultAnnouncement', smalltalk.Object, ['result'], 'SUnit');
  3. smalltalk.addMethod(
  4. "_result",
  5. smalltalk.method({
  6. selector: "result",
  7. category: 'accessing',
  8. fn: function (){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx1) {
  11. var $1;
  12. $1=self["@result"];
  13. return $1;
  14. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.ResultAnnouncement)})},
  15. args: [],
  16. source: "result\x0a\x09^result",
  17. messageSends: [],
  18. referencedClasses: []
  19. }),
  20. smalltalk.ResultAnnouncement);
  21. smalltalk.addMethod(
  22. "_result_",
  23. smalltalk.method({
  24. selector: "result:",
  25. category: 'accessing',
  26. fn: function (aTestResult){
  27. var self=this;
  28. return smalltalk.withContext(function($ctx1) {
  29. self["@result"]=aTestResult;
  30. return self}, function($ctx1) {$ctx1.fill(self,"result:",{aTestResult:aTestResult},smalltalk.ResultAnnouncement)})},
  31. args: ["aTestResult"],
  32. source: "result: aTestResult\x0a\x09result := aTestResult",
  33. messageSends: [],
  34. referencedClasses: []
  35. }),
  36. smalltalk.ResultAnnouncement);
  37. smalltalk.addClass('TestCase', smalltalk.Object, ['testSelector', 'asyncTimeout', 'context'], 'SUnit');
  38. smalltalk.TestCase.comment="A TestCase is an implementation of the command pattern to run a test.\x0a\x0a`TestCase` 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."
  39. smalltalk.addMethod(
  40. "_assert_",
  41. smalltalk.method({
  42. selector: "assert:",
  43. category: 'testing',
  44. fn: function (aBoolean){
  45. var self=this;
  46. return smalltalk.withContext(function($ctx1) {
  47. _st(self)._assert_description_(aBoolean,"Assertion failed");
  48. return self}, function($ctx1) {$ctx1.fill(self,"assert:",{aBoolean:aBoolean},smalltalk.TestCase)})},
  49. args: ["aBoolean"],
  50. source: "assert: aBoolean\x0a\x09self assert: aBoolean description: 'Assertion failed'",
  51. messageSends: ["assert:description:"],
  52. referencedClasses: []
  53. }),
  54. smalltalk.TestCase);
  55. smalltalk.addMethod(
  56. "_assert_description_",
  57. smalltalk.method({
  58. selector: "assert:description:",
  59. category: 'testing',
  60. fn: function (aBoolean,aString){
  61. var self=this;
  62. return smalltalk.withContext(function($ctx1) {
  63. var $1;
  64. $1=aBoolean;
  65. if(! smalltalk.assert($1)){
  66. _st(self)._signalFailure_(aString);
  67. };
  68. return self}, function($ctx1) {$ctx1.fill(self,"assert:description:",{aBoolean:aBoolean,aString:aString},smalltalk.TestCase)})},
  69. args: ["aBoolean", "aString"],
  70. source: "assert: aBoolean description: aString\x0a\x09aBoolean ifFalse: [self signalFailure: aString]",
  71. messageSends: ["ifFalse:", "signalFailure:"],
  72. referencedClasses: []
  73. }),
  74. smalltalk.TestCase);
  75. smalltalk.addMethod(
  76. "_assert_equals_",
  77. smalltalk.method({
  78. selector: "assert:equals:",
  79. category: 'testing',
  80. fn: function (actual,expected){
  81. var self=this;
  82. return smalltalk.withContext(function($ctx1) {
  83. var $1;
  84. $1=_st(self)._assert_description_(_st(actual).__eq(expected),_st(_st(_st("Expected: ").__comma(_st(expected)._asString())).__comma(" but was: ")).__comma(_st(actual)._asString()));
  85. return $1;
  86. }, function($ctx1) {$ctx1.fill(self,"assert:equals:",{actual:actual,expected:expected},smalltalk.TestCase)})},
  87. args: ["actual", "expected"],
  88. source: "assert: actual equals: expected\x0a\x09^ self assert: (actual = expected) description: 'Expected: ', expected asString, ' but was: ', actual asString",
  89. messageSends: ["assert:description:", "=", ",", "asString"],
  90. referencedClasses: []
  91. }),
  92. smalltalk.TestCase);
  93. smalltalk.addMethod(
  94. "_async_",
  95. smalltalk.method({
  96. selector: "async:",
  97. category: 'async',
  98. fn: function (aBlock){
  99. var self=this;
  100. var c;
  101. return smalltalk.withContext(function($ctx1) {
  102. var $2,$1;
  103. _st(self)._errorIfNotAsync_("#async");
  104. c=self["@context"];
  105. $1=(function(){
  106. return smalltalk.withContext(function($ctx2) {
  107. $2=_st(self)._isAsync();
  108. if(smalltalk.assert($2)){
  109. return _st(c)._execute_(aBlock);
  110. };
  111. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  112. return $1;
  113. }, function($ctx1) {$ctx1.fill(self,"async:",{aBlock:aBlock,c:c},smalltalk.TestCase)})},
  114. args: ["aBlock"],
  115. source: "async: aBlock\x0a\x09| c |\x0a\x09self errorIfNotAsync: '#async'.\x0a\x09c := context.\x0a\x09^ [ self isAsync ifTrue: [ c execute: aBlock ] ]",
  116. messageSends: ["errorIfNotAsync:", "ifTrue:", "execute:", "isAsync"],
  117. referencedClasses: []
  118. }),
  119. smalltalk.TestCase);
  120. smalltalk.addMethod(
  121. "_context_",
  122. smalltalk.method({
  123. selector: "context:",
  124. category: 'accessing',
  125. fn: function (aRunningTestContext){
  126. var self=this;
  127. return smalltalk.withContext(function($ctx1) {
  128. self["@context"]=aRunningTestContext;
  129. return self}, function($ctx1) {$ctx1.fill(self,"context:",{aRunningTestContext:aRunningTestContext},smalltalk.TestCase)})},
  130. args: ["aRunningTestContext"],
  131. source: "context: aRunningTestContext\x0a\x09context := aRunningTestContext",
  132. messageSends: [],
  133. referencedClasses: []
  134. }),
  135. smalltalk.TestCase);
  136. smalltalk.addMethod(
  137. "_deny_",
  138. smalltalk.method({
  139. selector: "deny:",
  140. category: 'testing',
  141. fn: function (aBoolean){
  142. var self=this;
  143. return smalltalk.withContext(function($ctx1) {
  144. _st(self)._assert_(_st(aBoolean)._not());
  145. return self}, function($ctx1) {$ctx1.fill(self,"deny:",{aBoolean:aBoolean},smalltalk.TestCase)})},
  146. args: ["aBoolean"],
  147. source: "deny: aBoolean\x0a\x09self assert: aBoolean not",
  148. messageSends: ["assert:", "not"],
  149. referencedClasses: []
  150. }),
  151. smalltalk.TestCase);
  152. smalltalk.addMethod(
  153. "_errorIfNotAsync_",
  154. smalltalk.method({
  155. selector: "errorIfNotAsync:",
  156. category: 'error handling',
  157. fn: function (aString){
  158. var self=this;
  159. return smalltalk.withContext(function($ctx1) {
  160. var $1;
  161. $1=_st(self)._isAsync();
  162. if(! smalltalk.assert($1)){
  163. _st(self)._error_(_st(aString).__comma(" used without prior #timeout:"));
  164. };
  165. return self}, function($ctx1) {$ctx1.fill(self,"errorIfNotAsync:",{aString:aString},smalltalk.TestCase)})},
  166. args: ["aString"],
  167. source: "errorIfNotAsync: aString\x0a\x09self isAsync ifFalse: [\x0a\x09\x09self error: aString, ' used without prior #timeout:' ]",
  168. messageSends: ["ifFalse:", "error:", ",", "isAsync"],
  169. referencedClasses: []
  170. }),
  171. smalltalk.TestCase);
  172. smalltalk.addMethod(
  173. "_finished",
  174. smalltalk.method({
  175. selector: "finished",
  176. category: 'async',
  177. fn: function (){
  178. var self=this;
  179. return smalltalk.withContext(function($ctx1) {
  180. _st(self)._errorIfNotAsync_("#finished");
  181. self["@asyncTimeout"]=nil;
  182. return self}, function($ctx1) {$ctx1.fill(self,"finished",{},smalltalk.TestCase)})},
  183. args: [],
  184. source: "finished\x0a\x09self errorIfNotAsync: '#finished'.\x0a\x09asyncTimeout := nil",
  185. messageSends: ["errorIfNotAsync:"],
  186. referencedClasses: []
  187. }),
  188. smalltalk.TestCase);
  189. smalltalk.addMethod(
  190. "_isAsync",
  191. smalltalk.method({
  192. selector: "isAsync",
  193. category: 'testing',
  194. fn: function (){
  195. var self=this;
  196. return smalltalk.withContext(function($ctx1) {
  197. var $1;
  198. $1=_st(self["@asyncTimeout"])._notNil();
  199. return $1;
  200. }, function($ctx1) {$ctx1.fill(self,"isAsync",{},smalltalk.TestCase)})},
  201. args: [],
  202. source: "isAsync\x0a\x09^asyncTimeout notNil",
  203. messageSends: ["notNil"],
  204. referencedClasses: []
  205. }),
  206. smalltalk.TestCase);
  207. smalltalk.addMethod(
  208. "_performTest",
  209. smalltalk.method({
  210. selector: "performTest",
  211. category: 'running',
  212. fn: function (){
  213. var self=this;
  214. return smalltalk.withContext(function($ctx1) {
  215. self["@asyncTimeout"]=nil;
  216. _st(self)._perform_(_st(self)._selector());
  217. return self}, function($ctx1) {$ctx1.fill(self,"performTest",{},smalltalk.TestCase)})},
  218. args: [],
  219. source: "performTest\x0a\x09asyncTimeout := nil.\x0a\x09self perform: self selector",
  220. messageSends: ["perform:", "selector"],
  221. referencedClasses: []
  222. }),
  223. smalltalk.TestCase);
  224. smalltalk.addMethod(
  225. "_runCase",
  226. smalltalk.method({
  227. selector: "runCase",
  228. category: 'running',
  229. fn: function (){
  230. var self=this;
  231. function $TestContext(){return smalltalk.TestContext||(typeof TestContext=="undefined"?nil:TestContext)}
  232. return smalltalk.withContext(function($ctx1) {
  233. _st(_st($TestContext())._testCase_(self))._start();
  234. return self}, function($ctx1) {$ctx1.fill(self,"runCase",{},smalltalk.TestCase)})},
  235. args: [],
  236. source: "runCase\x0a\x09\x22Runs a test case in isolated context, leaking all errors.\x22\x0a\x0a\x09(TestContext testCase: self) start",
  237. messageSends: ["start", "testCase:"],
  238. referencedClasses: ["TestContext"]
  239. }),
  240. smalltalk.TestCase);
  241. smalltalk.addMethod(
  242. "_selector",
  243. smalltalk.method({
  244. selector: "selector",
  245. category: 'accessing',
  246. fn: function (){
  247. var self=this;
  248. return smalltalk.withContext(function($ctx1) {
  249. var $1;
  250. $1=self["@testSelector"];
  251. return $1;
  252. }, function($ctx1) {$ctx1.fill(self,"selector",{},smalltalk.TestCase)})},
  253. args: [],
  254. source: "selector\x0a\x09^testSelector",
  255. messageSends: [],
  256. referencedClasses: []
  257. }),
  258. smalltalk.TestCase);
  259. smalltalk.addMethod(
  260. "_setTestSelector_",
  261. smalltalk.method({
  262. selector: "setTestSelector:",
  263. category: 'accessing',
  264. fn: function (aSelector){
  265. var self=this;
  266. return smalltalk.withContext(function($ctx1) {
  267. self["@testSelector"]=aSelector;
  268. return self}, function($ctx1) {$ctx1.fill(self,"setTestSelector:",{aSelector:aSelector},smalltalk.TestCase)})},
  269. args: ["aSelector"],
  270. source: "setTestSelector: aSelector\x0a\x09testSelector := aSelector",
  271. messageSends: [],
  272. referencedClasses: []
  273. }),
  274. smalltalk.TestCase);
  275. smalltalk.addMethod(
  276. "_setUp",
  277. smalltalk.method({
  278. selector: "setUp",
  279. category: 'running',
  280. fn: function (){
  281. var self=this;
  282. return smalltalk.withContext(function($ctx1) {
  283. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.TestCase)})},
  284. args: [],
  285. source: "setUp",
  286. messageSends: [],
  287. referencedClasses: []
  288. }),
  289. smalltalk.TestCase);
  290. smalltalk.addMethod(
  291. "_should_",
  292. smalltalk.method({
  293. selector: "should:",
  294. category: 'testing',
  295. fn: function (aBlock){
  296. var self=this;
  297. return smalltalk.withContext(function($ctx1) {
  298. _st(self)._assert_(_st(aBlock)._value());
  299. return self}, function($ctx1) {$ctx1.fill(self,"should:",{aBlock:aBlock},smalltalk.TestCase)})},
  300. args: ["aBlock"],
  301. source: "should: aBlock\x0a\x09self assert: aBlock value",
  302. messageSends: ["assert:", "value"],
  303. referencedClasses: []
  304. }),
  305. smalltalk.TestCase);
  306. smalltalk.addMethod(
  307. "_should_raise_",
  308. smalltalk.method({
  309. selector: "should:raise:",
  310. category: 'testing',
  311. fn: function (aBlock,anExceptionClass){
  312. var self=this;
  313. return smalltalk.withContext(function($ctx1) {
  314. _st(self)._assert_(_st((function(){
  315. return smalltalk.withContext(function($ctx2) {
  316. _st(aBlock)._value();
  317. return false;
  318. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_(anExceptionClass,(function(ex){
  319. return smalltalk.withContext(function($ctx2) {
  320. return true;
  321. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})})));
  322. return self}, function($ctx1) {$ctx1.fill(self,"should:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass},smalltalk.TestCase)})},
  323. args: ["aBlock", "anExceptionClass"],
  324. source: "should: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. false]\x0a\x09\x09on: anExceptionClass\x0a\x09\x09do: [:ex | true])",
  325. messageSends: ["assert:", "on:do:", "value"],
  326. referencedClasses: []
  327. }),
  328. smalltalk.TestCase);
  329. smalltalk.addMethod(
  330. "_shouldnt_raise_",
  331. smalltalk.method({
  332. selector: "shouldnt:raise:",
  333. category: 'testing',
  334. fn: function (aBlock,anExceptionClass){
  335. var self=this;
  336. return smalltalk.withContext(function($ctx1) {
  337. _st(self)._assert_(_st((function(){
  338. return smalltalk.withContext(function($ctx2) {
  339. _st(aBlock)._value();
  340. return true;
  341. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_(anExceptionClass,(function(ex){
  342. return smalltalk.withContext(function($ctx2) {
  343. return false;
  344. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})})));
  345. return self}, function($ctx1) {$ctx1.fill(self,"shouldnt:raise:",{aBlock:aBlock,anExceptionClass:anExceptionClass},smalltalk.TestCase)})},
  346. args: ["aBlock", "anExceptionClass"],
  347. source: "shouldnt: aBlock raise: anExceptionClass\x0a\x09self assert: ([aBlock value. true]\x0a\x09\x09on: anExceptionClass\x0a\x09\x09do: [:ex | false])",
  348. messageSends: ["assert:", "on:do:", "value"],
  349. referencedClasses: []
  350. }),
  351. smalltalk.TestCase);
  352. smalltalk.addMethod(
  353. "_signalFailure_",
  354. smalltalk.method({
  355. selector: "signalFailure:",
  356. category: 'private',
  357. fn: function (aString){
  358. var self=this;
  359. function $TestFailure(){return smalltalk.TestFailure||(typeof TestFailure=="undefined"?nil:TestFailure)}
  360. return smalltalk.withContext(function($ctx1) {
  361. var $1,$2;
  362. $1=_st($TestFailure())._new();
  363. _st($1)._messageText_(aString);
  364. $2=_st($1)._signal();
  365. return self}, function($ctx1) {$ctx1.fill(self,"signalFailure:",{aString:aString},smalltalk.TestCase)})},
  366. args: ["aString"],
  367. source: "signalFailure: aString\x0a\x09TestFailure new\x0a\x09\x09messageText: aString;\x0a\x09\x09signal",
  368. messageSends: ["messageText:", "new", "signal"],
  369. referencedClasses: ["TestFailure"]
  370. }),
  371. smalltalk.TestCase);
  372. smalltalk.addMethod(
  373. "_tearDown",
  374. smalltalk.method({
  375. selector: "tearDown",
  376. category: 'running',
  377. fn: function (){
  378. var self=this;
  379. return smalltalk.withContext(function($ctx1) {
  380. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.TestCase)})},
  381. args: [],
  382. source: "tearDown",
  383. messageSends: [],
  384. referencedClasses: []
  385. }),
  386. smalltalk.TestCase);
  387. smalltalk.addMethod(
  388. "_timeout_",
  389. smalltalk.method({
  390. selector: "timeout:",
  391. category: 'async',
  392. fn: function (aNumber){
  393. var self=this;
  394. return smalltalk.withContext(function($ctx1) {
  395. var $1;
  396. $1=self["@asyncTimeout"];
  397. if(($receiver = $1) == nil || $receiver == undefined){
  398. $1;
  399. } else {
  400. _st(self["@asyncTimeout"])._clearTimeout();
  401. };
  402. self["@asyncTimeout"]=(0);
  403. self["@asyncTimeout"]=_st(_st(self)._async_((function(){
  404. return smalltalk.withContext(function($ctx2) {
  405. return _st(self)._assert_description_(false,"SUnit grace time exhausted");
  406. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_(aNumber);
  407. return self}, function($ctx1) {$ctx1.fill(self,"timeout:",{aNumber:aNumber},smalltalk.TestCase)})},
  408. args: ["aNumber"],
  409. 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",
  410. messageSends: ["ifNotNil:", "clearTimeout", "valueWithTimeout:", "async:", "assert:description:"],
  411. referencedClasses: []
  412. }),
  413. smalltalk.TestCase);
  414. smalltalk.addMethod(
  415. "_allTestSelectors",
  416. smalltalk.method({
  417. selector: "allTestSelectors",
  418. category: 'accessing',
  419. fn: function (){
  420. var self=this;
  421. var selectors;
  422. return smalltalk.withContext(function($ctx1) {
  423. var $1,$2;
  424. selectors=_st(self)._testSelectors();
  425. $1=_st(self)._shouldInheritSelectors();
  426. if(smalltalk.assert($1)){
  427. _st(selectors)._addAll_(_st(_st(self)._superclass())._allTestSelectors());
  428. };
  429. $2=selectors;
  430. return $2;
  431. }, function($ctx1) {$ctx1.fill(self,"allTestSelectors",{selectors:selectors},smalltalk.TestCase.klass)})},
  432. args: [],
  433. source: "allTestSelectors\x0a\x09| selectors |\x0a\x09selectors := self testSelectors.\x0a\x09self shouldInheritSelectors ifTrue: [\x0a\x09\x09selectors addAll: self superclass allTestSelectors].\x0a\x09^selectors",
  434. messageSends: ["testSelectors", "ifTrue:", "addAll:", "allTestSelectors", "superclass", "shouldInheritSelectors"],
  435. referencedClasses: []
  436. }),
  437. smalltalk.TestCase.klass);
  438. smalltalk.addMethod(
  439. "_buildSuite",
  440. smalltalk.method({
  441. selector: "buildSuite",
  442. category: 'accessing',
  443. fn: function (){
  444. var self=this;
  445. return smalltalk.withContext(function($ctx1) {
  446. var $1;
  447. $1=_st(_st(self)._allTestSelectors())._collect_((function(each){
  448. return smalltalk.withContext(function($ctx2) {
  449. return _st(self)._selector_(each);
  450. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  451. return $1;
  452. }, function($ctx1) {$ctx1.fill(self,"buildSuite",{},smalltalk.TestCase.klass)})},
  453. args: [],
  454. source: "buildSuite\x0a\x09^self allTestSelectors collect: [:each | self selector: each]",
  455. messageSends: ["collect:", "selector:", "allTestSelectors"],
  456. referencedClasses: []
  457. }),
  458. smalltalk.TestCase.klass);
  459. smalltalk.addMethod(
  460. "_isAbstract",
  461. smalltalk.method({
  462. selector: "isAbstract",
  463. category: 'testing',
  464. fn: function (){
  465. var self=this;
  466. return smalltalk.withContext(function($ctx1) {
  467. var $1;
  468. $1=_st(_st(self)._name()).__eq("TestCase");
  469. return $1;
  470. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.TestCase.klass)})},
  471. args: [],
  472. source: "isAbstract\x0a\x09^ self name = 'TestCase'",
  473. messageSends: ["=", "name"],
  474. referencedClasses: []
  475. }),
  476. smalltalk.TestCase.klass);
  477. smalltalk.addMethod(
  478. "_lookupHierarchyRoot",
  479. smalltalk.method({
  480. selector: "lookupHierarchyRoot",
  481. category: 'accessing',
  482. fn: function (){
  483. var self=this;
  484. function $TestCase(){return smalltalk.TestCase||(typeof TestCase=="undefined"?nil:TestCase)}
  485. return smalltalk.withContext(function($ctx1) {
  486. var $1;
  487. $1=$TestCase();
  488. return $1;
  489. }, function($ctx1) {$ctx1.fill(self,"lookupHierarchyRoot",{},smalltalk.TestCase.klass)})},
  490. args: [],
  491. source: "lookupHierarchyRoot\x0a\x09^TestCase",
  492. messageSends: [],
  493. referencedClasses: ["TestCase"]
  494. }),
  495. smalltalk.TestCase.klass);
  496. smalltalk.addMethod(
  497. "_selector_",
  498. smalltalk.method({
  499. selector: "selector:",
  500. category: 'accessing',
  501. fn: function (aSelector){
  502. var self=this;
  503. return smalltalk.withContext(function($ctx1) {
  504. var $2,$3,$1;
  505. $2=_st(self)._new();
  506. _st($2)._setTestSelector_(aSelector);
  507. $3=_st($2)._yourself();
  508. $1=$3;
  509. return $1;
  510. }, function($ctx1) {$ctx1.fill(self,"selector:",{aSelector:aSelector},smalltalk.TestCase.klass)})},
  511. args: ["aSelector"],
  512. source: "selector: aSelector\x0a\x09^self new\x0a\x09\x09setTestSelector: aSelector;\x0a\x09\x09yourself",
  513. messageSends: ["setTestSelector:", "new", "yourself"],
  514. referencedClasses: []
  515. }),
  516. smalltalk.TestCase.klass);
  517. smalltalk.addMethod(
  518. "_shouldInheritSelectors",
  519. smalltalk.method({
  520. selector: "shouldInheritSelectors",
  521. category: 'testing',
  522. fn: function (){
  523. var self=this;
  524. return smalltalk.withContext(function($ctx1) {
  525. var $1;
  526. $1=_st(self).__tild_eq(_st(self)._lookupHierarchyRoot());
  527. return $1;
  528. }, function($ctx1) {$ctx1.fill(self,"shouldInheritSelectors",{},smalltalk.TestCase.klass)})},
  529. args: [],
  530. source: "shouldInheritSelectors\x0a\x09^self ~= self lookupHierarchyRoot",
  531. messageSends: ["~=", "lookupHierarchyRoot"],
  532. referencedClasses: []
  533. }),
  534. smalltalk.TestCase.klass);
  535. smalltalk.addMethod(
  536. "_testSelectors",
  537. smalltalk.method({
  538. selector: "testSelectors",
  539. category: 'accessing',
  540. fn: function (){
  541. var self=this;
  542. return smalltalk.withContext(function($ctx1) {
  543. var $1;
  544. $1=_st(_st(_st(self)._methodDictionary())._keys())._select_((function(each){
  545. return smalltalk.withContext(function($ctx2) {
  546. return _st(each)._match_("^test");
  547. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  548. return $1;
  549. }, function($ctx1) {$ctx1.fill(self,"testSelectors",{},smalltalk.TestCase.klass)})},
  550. args: [],
  551. source: "testSelectors\x0a\x09^self methodDictionary keys select: [:each | each match: '^test']",
  552. messageSends: ["select:", "match:", "keys", "methodDictionary"],
  553. referencedClasses: []
  554. }),
  555. smalltalk.TestCase.klass);
  556. smalltalk.addClass('TestContext', smalltalk.Object, ['testCase'], 'SUnit');
  557. smalltalk.TestContext.comment="TestContext governs running a particular test case.\x0a\x0aIt's main added value is `#execute:` method which runs a block\x0aas a part of test case (restores context, nilling it afterwards,\x0acleaning/calling tearDown as appropriate for sync/async scenario)."
  558. smalltalk.addMethod(
  559. "_execute_",
  560. smalltalk.method({
  561. selector: "execute:",
  562. category: 'running',
  563. fn: function (aBlock){
  564. var self=this;
  565. var failed;
  566. return smalltalk.withContext(function($ctx1) {
  567. var $1,$2;
  568. _st(self["@testCase"])._context_(self);
  569. _st((function(){
  570. return smalltalk.withContext(function($ctx2) {
  571. failed=true;
  572. failed;
  573. _st(aBlock)._value();
  574. failed=false;
  575. return failed;
  576. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  577. return smalltalk.withContext(function($ctx2) {
  578. _st(self["@testCase"])._context_(nil);
  579. $1=_st(failed)._and_((function(){
  580. return smalltalk.withContext(function($ctx3) {
  581. return _st(self["@testCase"])._isAsync();
  582. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  583. if(smalltalk.assert($1)){
  584. _st(self["@testCase"])._finished();
  585. };
  586. $2=_st(self["@testCase"])._isAsync();
  587. if(! smalltalk.assert($2)){
  588. return _st(self["@testCase"])._tearDown();
  589. };
  590. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  591. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock,failed:failed},smalltalk.TestContext)})},
  592. args: ["aBlock"],
  593. 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 ] ]",
  594. messageSends: ["context:", "ensure:", "ifTrue:", "finished", "and:", "isAsync", "ifFalse:", "tearDown", "value"],
  595. referencedClasses: []
  596. }),
  597. smalltalk.TestContext);
  598. smalltalk.addMethod(
  599. "_start",
  600. smalltalk.method({
  601. selector: "start",
  602. category: 'running',
  603. fn: function (){
  604. var self=this;
  605. return smalltalk.withContext(function($ctx1) {
  606. _st(self)._execute_((function(){
  607. return smalltalk.withContext(function($ctx2) {
  608. _st(self["@testCase"])._setUp();
  609. return _st(self["@testCase"])._performTest();
  610. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  611. return self}, function($ctx1) {$ctx1.fill(self,"start",{},smalltalk.TestContext)})},
  612. args: [],
  613. source: "start\x0a\x09self execute: [\x0a\x09\x09testCase setUp.\x0a\x09\x09testCase performTest ]",
  614. messageSends: ["execute:", "setUp", "performTest"],
  615. referencedClasses: []
  616. }),
  617. smalltalk.TestContext);
  618. smalltalk.addMethod(
  619. "_testCase_",
  620. smalltalk.method({
  621. selector: "testCase:",
  622. category: 'accessing',
  623. fn: function (aTestCase){
  624. var self=this;
  625. return smalltalk.withContext(function($ctx1) {
  626. self["@testCase"]=aTestCase;
  627. return self}, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase},smalltalk.TestContext)})},
  628. args: ["aTestCase"],
  629. source: "testCase: aTestCase\x0a\x09testCase := aTestCase",
  630. messageSends: [],
  631. referencedClasses: []
  632. }),
  633. smalltalk.TestContext);
  634. smalltalk.addMethod(
  635. "_testCase_",
  636. smalltalk.method({
  637. selector: "testCase:",
  638. category: 'instance creation',
  639. fn: function (aTestCase){
  640. var self=this;
  641. return smalltalk.withContext(function($ctx1) {
  642. var $2,$3,$1;
  643. $2=_st(self)._new();
  644. _st($2)._testCase_(aTestCase);
  645. $3=_st($2)._yourself();
  646. $1=$3;
  647. return $1;
  648. }, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase},smalltalk.TestContext.klass)})},
  649. args: ["aTestCase"],
  650. source: "testCase: aTestCase\x0a\x09^self new\x0a\x09\x09testCase: aTestCase;\x0a\x09\x09yourself",
  651. messageSends: ["testCase:", "new", "yourself"],
  652. referencedClasses: []
  653. }),
  654. smalltalk.TestContext.klass);
  655. smalltalk.addClass('ReportingTestContext', smalltalk.TestContext, ['finished', 'result'], 'SUnit');
  656. smalltalk.ReportingTestContext.comment="ReportingTestContext adds `TestResult` reporting\x0ato `TestContext`.\x0a\x0aErrors are caught and save into a `TestResult`,\x0aWhen test case is finished (which can be later for async tests),\x0aa callback block is executed; this is used by a `TestSuiteRunner`."
  657. smalltalk.addMethod(
  658. "_execute_",
  659. smalltalk.method({
  660. selector: "execute:",
  661. category: 'running',
  662. fn: function (aBlock){
  663. var self=this;
  664. return smalltalk.withContext(function($ctx1) {
  665. var $1;
  666. _st((function(){
  667. return smalltalk.withContext(function($ctx2) {
  668. return _st(self)._withErrorReporting_((function(){
  669. return smalltalk.withContext(function($ctx3) {
  670. return smalltalk.TestContext.fn.prototype._execute_.apply(_st(self), [aBlock]);
  671. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  672. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  673. return smalltalk.withContext(function($ctx2) {
  674. $1=_st(self["@testCase"])._isAsync();
  675. if(! smalltalk.assert($1)){
  676. _st(self["@result"])._increaseRuns();
  677. return _st(self["@finished"])._value();
  678. };
  679. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  680. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock},smalltalk.ReportingTestContext)})},
  681. args: ["aBlock"],
  682. 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 ] ]",
  683. messageSends: ["ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "withErrorReporting:", "execute:"],
  684. referencedClasses: []
  685. }),
  686. smalltalk.ReportingTestContext);
  687. smalltalk.addMethod(
  688. "_finished_",
  689. smalltalk.method({
  690. selector: "finished:",
  691. category: 'accessing',
  692. fn: function (aBlock){
  693. var self=this;
  694. return smalltalk.withContext(function($ctx1) {
  695. self["@finished"]=aBlock;
  696. return self}, function($ctx1) {$ctx1.fill(self,"finished:",{aBlock:aBlock},smalltalk.ReportingTestContext)})},
  697. args: ["aBlock"],
  698. source: "finished: aBlock\x0a\x09finished := aBlock",
  699. messageSends: [],
  700. referencedClasses: []
  701. }),
  702. smalltalk.ReportingTestContext);
  703. smalltalk.addMethod(
  704. "_result_",
  705. smalltalk.method({
  706. selector: "result:",
  707. category: 'accessing',
  708. fn: function (aTestResult){
  709. var self=this;
  710. return smalltalk.withContext(function($ctx1) {
  711. self["@result"]=aTestResult;
  712. return self}, function($ctx1) {$ctx1.fill(self,"result:",{aTestResult:aTestResult},smalltalk.ReportingTestContext)})},
  713. args: ["aTestResult"],
  714. source: "result: aTestResult\x0a\x09result := aTestResult",
  715. messageSends: [],
  716. referencedClasses: []
  717. }),
  718. smalltalk.ReportingTestContext);
  719. smalltalk.addMethod(
  720. "_withErrorReporting_",
  721. smalltalk.method({
  722. selector: "withErrorReporting:",
  723. category: 'private',
  724. fn: function (aBlock){
  725. var self=this;
  726. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  727. function $TestFailure(){return smalltalk.TestFailure||(typeof TestFailure=="undefined"?nil:TestFailure)}
  728. return smalltalk.withContext(function($ctx1) {
  729. _st((function(){
  730. return smalltalk.withContext(function($ctx2) {
  731. return _st(aBlock)._on_do_($TestFailure(),(function(ex){
  732. return smalltalk.withContext(function($ctx3) {
  733. return _st(self["@result"])._addFailure_(self["@testCase"]);
  734. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  735. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(ex){
  736. return smalltalk.withContext(function($ctx2) {
  737. return _st(self["@result"])._addError_(self["@testCase"]);
  738. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  739. return self}, function($ctx1) {$ctx1.fill(self,"withErrorReporting:",{aBlock:aBlock},smalltalk.ReportingTestContext)})},
  740. args: ["aBlock"],
  741. 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 ]",
  742. messageSends: ["on:do:", "addError:", "addFailure:"],
  743. referencedClasses: ["Error", "TestFailure"]
  744. }),
  745. smalltalk.ReportingTestContext);
  746. smalltalk.addMethod(
  747. "_testCase_result_finished_",
  748. smalltalk.method({
  749. selector: "testCase:result:finished:",
  750. category: 'instance creation',
  751. fn: function (aTestCase,aTestResult,aBlock){
  752. var self=this;
  753. return smalltalk.withContext(function($ctx1) {
  754. var $2,$3,$1;
  755. $2=smalltalk.TestContext.klass.fn.prototype._testCase_.apply(_st(self), [aTestCase]);
  756. _st($2)._result_(aTestResult);
  757. _st($2)._finished_(aBlock);
  758. $3=_st($2)._yourself();
  759. $1=$3;
  760. return $1;
  761. }, function($ctx1) {$ctx1.fill(self,"testCase:result:finished:",{aTestCase:aTestCase,aTestResult:aTestResult,aBlock:aBlock},smalltalk.ReportingTestContext.klass)})},
  762. args: ["aTestCase", "aTestResult", "aBlock"],
  763. source: "testCase: aTestCase result: aTestResult finished: aBlock\x0a\x09^(super testCase: aTestCase)\x0a\x09\x09result: aTestResult;\x0a\x09\x09finished: aBlock;\x0a\x09\x09yourself",
  764. messageSends: ["result:", "testCase:", "finished:", "yourself"],
  765. referencedClasses: []
  766. }),
  767. smalltalk.ReportingTestContext.klass);
  768. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  769. smalltalk.TestFailure.comment="The 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.\x0a\x0aTestFailure is raised when the boolean parameter of an #`assert:` or `#deny:` call is the opposite of what the assertion claims."
  770. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  771. smalltalk.TestResult.comment="A TestResult implements the collecting parameter pattern for running a bunch of tests.\x0a\x0aA TestResult holds tests that have run, sorted into the result categories of passed, failures and errors.\x0a\x0aTestResult is an interesting object to subclass or substitute. `#runCase:` is the external protocol you need to reproduce"
  772. smalltalk.addMethod(
  773. "_addError_",
  774. smalltalk.method({
  775. selector: "addError:",
  776. category: 'accessing',
  777. fn: function (anError){
  778. var self=this;
  779. return smalltalk.withContext(function($ctx1) {
  780. _st(_st(self)._errors())._add_(anError);
  781. return self}, function($ctx1) {$ctx1.fill(self,"addError:",{anError:anError},smalltalk.TestResult)})},
  782. args: ["anError"],
  783. source: "addError: anError\x0a\x09self errors add: anError",
  784. messageSends: ["add:", "errors"],
  785. referencedClasses: []
  786. }),
  787. smalltalk.TestResult);
  788. smalltalk.addMethod(
  789. "_addFailure_",
  790. smalltalk.method({
  791. selector: "addFailure:",
  792. category: 'accessing',
  793. fn: function (aFailure){
  794. var self=this;
  795. return smalltalk.withContext(function($ctx1) {
  796. _st(_st(self)._failures())._add_(aFailure);
  797. return self}, function($ctx1) {$ctx1.fill(self,"addFailure:",{aFailure:aFailure},smalltalk.TestResult)})},
  798. args: ["aFailure"],
  799. source: "addFailure: aFailure\x0a\x09self failures add: aFailure",
  800. messageSends: ["add:", "failures"],
  801. referencedClasses: []
  802. }),
  803. smalltalk.TestResult);
  804. smalltalk.addMethod(
  805. "_errors",
  806. smalltalk.method({
  807. selector: "errors",
  808. category: 'accessing',
  809. fn: function (){
  810. var self=this;
  811. return smalltalk.withContext(function($ctx1) {
  812. var $1;
  813. $1=self["@errors"];
  814. return $1;
  815. }, function($ctx1) {$ctx1.fill(self,"errors",{},smalltalk.TestResult)})},
  816. args: [],
  817. source: "errors\x0a\x09^errors",
  818. messageSends: [],
  819. referencedClasses: []
  820. }),
  821. smalltalk.TestResult);
  822. smalltalk.addMethod(
  823. "_failures",
  824. smalltalk.method({
  825. selector: "failures",
  826. category: 'accessing',
  827. fn: function (){
  828. var self=this;
  829. return smalltalk.withContext(function($ctx1) {
  830. var $1;
  831. $1=self["@failures"];
  832. return $1;
  833. }, function($ctx1) {$ctx1.fill(self,"failures",{},smalltalk.TestResult)})},
  834. args: [],
  835. source: "failures\x0a\x09^failures",
  836. messageSends: [],
  837. referencedClasses: []
  838. }),
  839. smalltalk.TestResult);
  840. smalltalk.addMethod(
  841. "_increaseRuns",
  842. smalltalk.method({
  843. selector: "increaseRuns",
  844. category: 'accessing',
  845. fn: function (){
  846. var self=this;
  847. return smalltalk.withContext(function($ctx1) {
  848. self["@runs"]=_st(self["@runs"]).__plus((1));
  849. return self}, function($ctx1) {$ctx1.fill(self,"increaseRuns",{},smalltalk.TestResult)})},
  850. args: [],
  851. source: "increaseRuns\x0a\x09runs := runs + 1",
  852. messageSends: ["+"],
  853. referencedClasses: []
  854. }),
  855. smalltalk.TestResult);
  856. smalltalk.addMethod(
  857. "_initialize",
  858. smalltalk.method({
  859. selector: "initialize",
  860. category: 'initialization',
  861. fn: function (){
  862. var self=this;
  863. function $Date(){return smalltalk.Date||(typeof Date=="undefined"?nil:Date)}
  864. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  865. return smalltalk.withContext(function($ctx1) {
  866. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  867. self["@timestamp"]=_st($Date())._now();
  868. self["@runs"]=(0);
  869. self["@errors"]=_st($Array())._new();
  870. self["@failures"]=_st($Array())._new();
  871. self["@total"]=(0);
  872. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TestResult)})},
  873. args: [],
  874. source: "initialize\x0a\x09super initialize.\x0a\x09timestamp := Date now.\x0a\x09runs := 0.\x0a\x09errors := Array new.\x0a\x09failures := Array new.\x0a\x09total := 0",
  875. messageSends: ["initialize", "now", "new"],
  876. referencedClasses: ["Date", "Array"]
  877. }),
  878. smalltalk.TestResult);
  879. smalltalk.addMethod(
  880. "_nextRunDo_",
  881. smalltalk.method({
  882. selector: "nextRunDo:",
  883. category: 'running',
  884. fn: function (aBlock){
  885. var self=this;
  886. return smalltalk.withContext(function($ctx1) {
  887. var $2,$1;
  888. $2=_st(_st(self)._runs()).__eq_eq(_st(self)._total());
  889. if(! smalltalk.assert($2)){
  890. $1=_st(aBlock)._value_(_st(_st(self)._runs()).__plus((1)));
  891. };
  892. return $1;
  893. }, function($ctx1) {$ctx1.fill(self,"nextRunDo:",{aBlock:aBlock},smalltalk.TestResult)})},
  894. args: ["aBlock"],
  895. source: "nextRunDo: aBlock\x0a\x22Runs aBlock with index of next run\x0aor does nothing if no more runs\x22\x0a^self runs == self total\x0a\x09ifFalse: [ aBlock value: self runs + 1 ]",
  896. messageSends: ["ifFalse:", "value:", "+", "runs", "==", "total"],
  897. referencedClasses: []
  898. }),
  899. smalltalk.TestResult);
  900. smalltalk.addMethod(
  901. "_runCase_",
  902. smalltalk.method({
  903. selector: "runCase:",
  904. category: 'running',
  905. fn: function (aTestCase){
  906. var self=this;
  907. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  908. function $TestFailure(){return smalltalk.TestFailure||(typeof TestFailure=="undefined"?nil:TestFailure)}
  909. return smalltalk.withContext(function($ctx1) {
  910. _st((function(){
  911. return smalltalk.withContext(function($ctx2) {
  912. return _st((function(){
  913. return smalltalk.withContext(function($ctx3) {
  914. _st(self)._increaseRuns();
  915. return _st(aTestCase)._runCase();
  916. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_($TestFailure(),(function(ex){
  917. return smalltalk.withContext(function($ctx3) {
  918. return _st(self)._addFailure_(aTestCase);
  919. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  920. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(ex){
  921. return smalltalk.withContext(function($ctx2) {
  922. return _st(self)._addError_(aTestCase);
  923. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  924. return self}, function($ctx1) {$ctx1.fill(self,"runCase:",{aTestCase:aTestCase},smalltalk.TestResult)})},
  925. args: ["aTestCase"],
  926. 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]",
  927. messageSends: ["on:do:", "addError:", "addFailure:", "increaseRuns", "runCase"],
  928. referencedClasses: ["Error", "TestFailure"]
  929. }),
  930. smalltalk.TestResult);
  931. smalltalk.addMethod(
  932. "_runs",
  933. smalltalk.method({
  934. selector: "runs",
  935. category: 'accessing',
  936. fn: function (){
  937. var self=this;
  938. return smalltalk.withContext(function($ctx1) {
  939. var $1;
  940. $1=self["@runs"];
  941. return $1;
  942. }, function($ctx1) {$ctx1.fill(self,"runs",{},smalltalk.TestResult)})},
  943. args: [],
  944. source: "runs\x0a\x09^runs",
  945. messageSends: [],
  946. referencedClasses: []
  947. }),
  948. smalltalk.TestResult);
  949. smalltalk.addMethod(
  950. "_status",
  951. smalltalk.method({
  952. selector: "status",
  953. category: 'accessing',
  954. fn: function (){
  955. var self=this;
  956. return smalltalk.withContext(function($ctx1) {
  957. var $2,$3,$1;
  958. $2=_st(_st(self)._errors())._isEmpty();
  959. if(smalltalk.assert($2)){
  960. $3=_st(_st(self)._failures())._isEmpty();
  961. if(smalltalk.assert($3)){
  962. $1="success";
  963. } else {
  964. $1="failure";
  965. };
  966. } else {
  967. $1="error";
  968. };
  969. return $1;
  970. }, function($ctx1) {$ctx1.fill(self,"status",{},smalltalk.TestResult)})},
  971. args: [],
  972. source: "status\x0a\x09^self errors isEmpty\x0a\x09\x09ifTrue: [\x0a\x09\x09\x09self failures isEmpty\x0a\x09\x09\x09\x09ifTrue: ['success']\x0a\x09\x09\x09\x09ifFalse: ['failure']]\x0a\x09\x09ifFalse: ['error']",
  973. messageSends: ["ifTrue:ifFalse:", "isEmpty", "failures", "errors"],
  974. referencedClasses: []
  975. }),
  976. smalltalk.TestResult);
  977. smalltalk.addMethod(
  978. "_timestamp",
  979. smalltalk.method({
  980. selector: "timestamp",
  981. category: 'accessing',
  982. fn: function (){
  983. var self=this;
  984. return smalltalk.withContext(function($ctx1) {
  985. var $1;
  986. $1=self["@timestamp"];
  987. return $1;
  988. }, function($ctx1) {$ctx1.fill(self,"timestamp",{},smalltalk.TestResult)})},
  989. args: [],
  990. source: "timestamp\x0a\x09^timestamp",
  991. messageSends: [],
  992. referencedClasses: []
  993. }),
  994. smalltalk.TestResult);
  995. smalltalk.addMethod(
  996. "_total",
  997. smalltalk.method({
  998. selector: "total",
  999. category: 'accessing',
  1000. fn: function (){
  1001. var self=this;
  1002. return smalltalk.withContext(function($ctx1) {
  1003. var $1;
  1004. $1=self["@total"];
  1005. return $1;
  1006. }, function($ctx1) {$ctx1.fill(self,"total",{},smalltalk.TestResult)})},
  1007. args: [],
  1008. source: "total\x0a\x09^total",
  1009. messageSends: [],
  1010. referencedClasses: []
  1011. }),
  1012. smalltalk.TestResult);
  1013. smalltalk.addMethod(
  1014. "_total_",
  1015. smalltalk.method({
  1016. selector: "total:",
  1017. category: 'accessing',
  1018. fn: function (aNumber){
  1019. var self=this;
  1020. return smalltalk.withContext(function($ctx1) {
  1021. self["@total"]=aNumber;
  1022. return self}, function($ctx1) {$ctx1.fill(self,"total:",{aNumber:aNumber},smalltalk.TestResult)})},
  1023. args: ["aNumber"],
  1024. source: "total: aNumber\x0a\x09total := aNumber",
  1025. messageSends: [],
  1026. referencedClasses: []
  1027. }),
  1028. smalltalk.TestResult);
  1029. smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer', 'runNextTest'], 'SUnit');
  1030. smalltalk.addMethod(
  1031. "_announcer",
  1032. smalltalk.method({
  1033. selector: "announcer",
  1034. category: 'accessing',
  1035. fn: function (){
  1036. var self=this;
  1037. return smalltalk.withContext(function($ctx1) {
  1038. var $1;
  1039. $1=self["@announcer"];
  1040. return $1;
  1041. }, function($ctx1) {$ctx1.fill(self,"announcer",{},smalltalk.TestSuiteRunner)})},
  1042. args: [],
  1043. source: "announcer\x0a\x09^announcer",
  1044. messageSends: [],
  1045. referencedClasses: []
  1046. }),
  1047. smalltalk.TestSuiteRunner);
  1048. smalltalk.addMethod(
  1049. "_contextOf_",
  1050. smalltalk.method({
  1051. selector: "contextOf:",
  1052. category: 'private',
  1053. fn: function (anInteger){
  1054. var self=this;
  1055. function $ReportingTestContext(){return smalltalk.ReportingTestContext||(typeof ReportingTestContext=="undefined"?nil:ReportingTestContext)}
  1056. return smalltalk.withContext(function($ctx1) {
  1057. var $1;
  1058. $1=_st($ReportingTestContext())._testCase_result_finished_(_st(self["@suite"])._at_(anInteger),self["@result"],(function(){
  1059. return smalltalk.withContext(function($ctx2) {
  1060. return _st(self)._resume();
  1061. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1062. return $1;
  1063. }, function($ctx1) {$ctx1.fill(self,"contextOf:",{anInteger:anInteger},smalltalk.TestSuiteRunner)})},
  1064. args: ["anInteger"],
  1065. source: "contextOf: anInteger\x0a\x09^ReportingTestContext testCase: (suite at: anInteger) result: result finished: [ self resume ]",
  1066. messageSends: ["testCase:result:finished:", "at:", "resume"],
  1067. referencedClasses: ["ReportingTestContext"]
  1068. }),
  1069. smalltalk.TestSuiteRunner);
  1070. smalltalk.addMethod(
  1071. "_initialize",
  1072. smalltalk.method({
  1073. selector: "initialize",
  1074. category: 'initialization',
  1075. fn: function (){
  1076. var self=this;
  1077. function $Announcer(){return smalltalk.Announcer||(typeof Announcer=="undefined"?nil:Announcer)}
  1078. function $TestResult(){return smalltalk.TestResult||(typeof TestResult=="undefined"?nil:TestResult)}
  1079. return smalltalk.withContext(function($ctx1) {
  1080. var $1;
  1081. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  1082. self["@announcer"]=_st($Announcer())._new();
  1083. self["@result"]=_st($TestResult())._new();
  1084. self["@runNextTest"]=(function(){
  1085. var runs;
  1086. return smalltalk.withContext(function($ctx2) {
  1087. runs=_st(self["@result"])._runs();
  1088. runs;
  1089. $1=_st(runs).__lt(_st(self["@result"])._total());
  1090. if(smalltalk.assert($1)){
  1091. return _st(_st(self)._contextOf_(_st(runs).__plus((1))))._start();
  1092. };
  1093. }, function($ctx2) {$ctx2.fillBlock({runs:runs},$ctx1)})});
  1094. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},smalltalk.TestSuiteRunner)})},
  1095. args: [],
  1096. 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 ]].",
  1097. messageSends: ["initialize", "new", "runs", "ifTrue:", "start", "contextOf:", "+", "<", "total"],
  1098. referencedClasses: ["Announcer", "TestResult"]
  1099. }),
  1100. smalltalk.TestSuiteRunner);
  1101. smalltalk.addMethod(
  1102. "_result",
  1103. smalltalk.method({
  1104. selector: "result",
  1105. category: 'accessing',
  1106. fn: function (){
  1107. var self=this;
  1108. return smalltalk.withContext(function($ctx1) {
  1109. var $1;
  1110. $1=self["@result"];
  1111. return $1;
  1112. }, function($ctx1) {$ctx1.fill(self,"result",{},smalltalk.TestSuiteRunner)})},
  1113. args: [],
  1114. source: "result\x0a\x09^result",
  1115. messageSends: [],
  1116. referencedClasses: []
  1117. }),
  1118. smalltalk.TestSuiteRunner);
  1119. smalltalk.addMethod(
  1120. "_resume",
  1121. smalltalk.method({
  1122. selector: "resume",
  1123. category: 'actions',
  1124. fn: function (){
  1125. var self=this;
  1126. function $ResultAnnouncement(){return smalltalk.ResultAnnouncement||(typeof ResultAnnouncement=="undefined"?nil:ResultAnnouncement)}
  1127. return smalltalk.withContext(function($ctx1) {
  1128. _st(self["@runNextTest"])._fork();
  1129. _st(self["@announcer"])._announce_(_st(_st($ResultAnnouncement())._new())._result_(self["@result"]));
  1130. return self}, function($ctx1) {$ctx1.fill(self,"resume",{},smalltalk.TestSuiteRunner)})},
  1131. args: [],
  1132. source: "resume\x0a\x09runNextTest fork.\x0a\x09announcer announce: (ResultAnnouncement new result: result)",
  1133. messageSends: ["fork", "announce:", "result:", "new"],
  1134. referencedClasses: ["ResultAnnouncement"]
  1135. }),
  1136. smalltalk.TestSuiteRunner);
  1137. smalltalk.addMethod(
  1138. "_run",
  1139. smalltalk.method({
  1140. selector: "run",
  1141. category: 'actions',
  1142. fn: function (){
  1143. var self=this;
  1144. return smalltalk.withContext(function($ctx1) {
  1145. _st(self["@result"])._total_(_st(self["@suite"])._size());
  1146. _st(self)._resume();
  1147. return self}, function($ctx1) {$ctx1.fill(self,"run",{},smalltalk.TestSuiteRunner)})},
  1148. args: [],
  1149. source: "run\x0a\x09result total: suite size.\x0a\x09self resume",
  1150. messageSends: ["total:", "size", "resume"],
  1151. referencedClasses: []
  1152. }),
  1153. smalltalk.TestSuiteRunner);
  1154. smalltalk.addMethod(
  1155. "_suite_",
  1156. smalltalk.method({
  1157. selector: "suite:",
  1158. category: 'accessing',
  1159. fn: function (aCollection){
  1160. var self=this;
  1161. return smalltalk.withContext(function($ctx1) {
  1162. self["@suite"]=aCollection;
  1163. return self}, function($ctx1) {$ctx1.fill(self,"suite:",{aCollection:aCollection},smalltalk.TestSuiteRunner)})},
  1164. args: ["aCollection"],
  1165. source: "suite: aCollection\x0a\x09suite := aCollection",
  1166. messageSends: [],
  1167. referencedClasses: []
  1168. }),
  1169. smalltalk.TestSuiteRunner);
  1170. smalltalk.addMethod(
  1171. "_new",
  1172. smalltalk.method({
  1173. selector: "new",
  1174. category: 'instance creation',
  1175. fn: function (){
  1176. var self=this;
  1177. return smalltalk.withContext(function($ctx1) {
  1178. _st(self)._shouldNotImplement();
  1179. return self}, function($ctx1) {$ctx1.fill(self,"new",{},smalltalk.TestSuiteRunner.klass)})},
  1180. args: [],
  1181. source: "new\x0a\x09self shouldNotImplement",
  1182. messageSends: ["shouldNotImplement"],
  1183. referencedClasses: []
  1184. }),
  1185. smalltalk.TestSuiteRunner.klass);
  1186. smalltalk.addMethod(
  1187. "_on_",
  1188. smalltalk.method({
  1189. selector: "on:",
  1190. category: 'instance creation',
  1191. fn: function (aCollection){
  1192. var self=this;
  1193. return smalltalk.withContext(function($ctx1) {
  1194. var $1;
  1195. $1=_st(smalltalk.Object.klass.fn.prototype._new.apply(_st(self), []))._suite_(aCollection);
  1196. return $1;
  1197. }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection},smalltalk.TestSuiteRunner.klass)})},
  1198. args: ["aCollection"],
  1199. source: "on: aCollection\x0a\x09^super new suite: aCollection",
  1200. messageSends: ["suite:", "new"],
  1201. referencedClasses: []
  1202. }),
  1203. smalltalk.TestSuiteRunner.klass);