1
0

SUnit.js 42 KB

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