SUnit.js 41 KB

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