2
0

SUnit.js 41 KB

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