SUnit.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  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,$3,$4,$2;
  527. _st(self["@testCase"])._context_(self);
  528. $1=(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)})});
  535. $2=(function(){
  536. return smalltalk.withContext(function($ctx2) { _st(self["@testCase"])._context_(nil);
  537. $3=_st(failed)._and_((function(){
  538. return smalltalk.withContext(function($ctx3) { return _st(self["@testCase"])._isAsync();
  539. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  540. if(smalltalk.assert($3)){
  541. _st(self["@testCase"])._finished();
  542. };
  543. $4=_st(self["@testCase"])._isAsync();
  544. if(! smalltalk.assert($4)){
  545. return _st(self["@testCase"])._tearDown();
  546. };
  547. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  548. _st($1)._ensure_($2);
  549. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock,failed:failed}, smalltalk.TestContext)})},
  550. args: ["aBlock"],
  551. 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 ] ]",
  552. messageSends: ["context:", "ensure:", "ifTrue:", "finished", "and:", "isAsync", "ifFalse:", "tearDown", "value"],
  553. referencedClasses: []
  554. }),
  555. smalltalk.TestContext);
  556. smalltalk.addMethod(
  557. "_start",
  558. smalltalk.method({
  559. selector: "start",
  560. category: 'running',
  561. fn: function (){
  562. var self=this;
  563. return smalltalk.withContext(function($ctx1) { _st(self)._execute_((function(){
  564. return smalltalk.withContext(function($ctx2) { _st(self["@testCase"])._setUp();
  565. return _st(self["@testCase"])._performTest();
  566. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  567. return self}, function($ctx1) {$ctx1.fill(self,"start",{}, smalltalk.TestContext)})},
  568. args: [],
  569. source: "start\x0a\x09self execute: [ \x0a \x09testCase setUp. \x0a testCase performTest ]",
  570. messageSends: ["execute:", "setUp", "performTest"],
  571. referencedClasses: []
  572. }),
  573. smalltalk.TestContext);
  574. smalltalk.addMethod(
  575. "_testCase_",
  576. smalltalk.method({
  577. selector: "testCase:",
  578. category: 'accessing',
  579. fn: function (aTestCase){
  580. var self=this;
  581. return smalltalk.withContext(function($ctx1) { self["@testCase"]=aTestCase;
  582. return self}, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase}, smalltalk.TestContext)})},
  583. args: ["aTestCase"],
  584. source: "testCase: aTestCase\x0a\x09testCase := aTestCase",
  585. messageSends: [],
  586. referencedClasses: []
  587. }),
  588. smalltalk.TestContext);
  589. smalltalk.addMethod(
  590. "_testCase_",
  591. smalltalk.method({
  592. selector: "testCase:",
  593. category: 'instance creation',
  594. fn: function (aTestCase){
  595. var self=this;
  596. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  597. $2=_st(self)._new();
  598. _st($2)._testCase_(aTestCase);
  599. $3=_st($2)._yourself();
  600. $1=$3;
  601. return $1;
  602. }, function($ctx1) {$ctx1.fill(self,"testCase:",{aTestCase:aTestCase}, smalltalk.TestContext.klass)})},
  603. args: ["aTestCase"],
  604. source: "testCase: aTestCase\x0a\x09^self new\x0a testCase: aTestCase;\x0a yourself",
  605. messageSends: ["testCase:", "new", "yourself"],
  606. referencedClasses: []
  607. }),
  608. smalltalk.TestContext.klass);
  609. smalltalk.addClass('ReportingTestContext', smalltalk.TestContext, ['finished', 'result'], 'SUnit');
  610. 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`."
  611. smalltalk.addMethod(
  612. "_execute_",
  613. smalltalk.method({
  614. selector: "execute:",
  615. category: 'running',
  616. fn: function (aBlock){
  617. var self=this;
  618. return smalltalk.withContext(function($ctx1) { var $1,$3,$2;
  619. $1=(function(){
  620. return smalltalk.withContext(function($ctx2) { return _st(self)._withErrorReporting_((function(){
  621. return smalltalk.withContext(function($ctx3) { return smalltalk.TestContext.fn.prototype._execute_.apply(_st(self), [aBlock]);
  622. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  623. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  624. $2=(function(){
  625. return smalltalk.withContext(function($ctx2) { $3=_st(self["@testCase"])._isAsync();
  626. if(! smalltalk.assert($3)){
  627. _st(self["@result"])._increaseRuns();
  628. return _st(self["@finished"])._value();
  629. };
  630. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  631. _st($1)._ensure_($2);
  632. return self}, function($ctx1) {$ctx1.fill(self,"execute:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
  633. args: ["aBlock"],
  634. source: "execute: aBlock\x0a [ \x0a \x09self withErrorReporting: [ super execute: aBlock ] \x0a\x09]\x0a \x09ensure: [ \x0a \x09testCase isAsync ifFalse: [ \x0a \x09result increaseRuns. finished value ] ]",
  635. messageSends: ["ensure:", "ifFalse:", "increaseRuns", "value", "isAsync", "withErrorReporting:", "execute:"],
  636. referencedClasses: []
  637. }),
  638. smalltalk.ReportingTestContext);
  639. smalltalk.addMethod(
  640. "_finished_",
  641. smalltalk.method({
  642. selector: "finished:",
  643. category: 'accessing',
  644. fn: function (aBlock){
  645. var self=this;
  646. return smalltalk.withContext(function($ctx1) { self["@finished"]=aBlock;
  647. return self}, function($ctx1) {$ctx1.fill(self,"finished:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
  648. args: ["aBlock"],
  649. source: "finished: aBlock\x0a\x09finished := aBlock",
  650. messageSends: [],
  651. referencedClasses: []
  652. }),
  653. smalltalk.ReportingTestContext);
  654. smalltalk.addMethod(
  655. "_result_",
  656. smalltalk.method({
  657. selector: "result:",
  658. category: 'accessing',
  659. fn: function (aTestResult){
  660. var self=this;
  661. return smalltalk.withContext(function($ctx1) { self["@result"]=aTestResult;
  662. return self}, function($ctx1) {$ctx1.fill(self,"result:",{aTestResult:aTestResult}, smalltalk.ReportingTestContext)})},
  663. args: ["aTestResult"],
  664. source: "result: aTestResult\x0a\x09result := aTestResult",
  665. messageSends: [],
  666. referencedClasses: []
  667. }),
  668. smalltalk.ReportingTestContext);
  669. smalltalk.addMethod(
  670. "_withErrorReporting_",
  671. smalltalk.method({
  672. selector: "withErrorReporting:",
  673. category: 'private',
  674. fn: function (aBlock){
  675. var self=this;
  676. return smalltalk.withContext(function($ctx1) { _st((function(){
  677. return smalltalk.withContext(function($ctx2) { return _st(aBlock)._on_do_((smalltalk.TestFailure || TestFailure),(function(ex){
  678. return smalltalk.withContext(function($ctx3) { return _st(self["@result"])._addFailure_(self["@testCase"]);
  679. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  680. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
  681. return smalltalk.withContext(function($ctx2) { return _st(self["@result"])._addError_(self["@testCase"]);
  682. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  683. return self}, function($ctx1) {$ctx1.fill(self,"withErrorReporting:",{aBlock:aBlock}, smalltalk.ReportingTestContext)})},
  684. args: ["aBlock"],
  685. 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 ]",
  686. messageSends: ["on:do:", "addError:", "addFailure:"],
  687. referencedClasses: ["Error", "TestFailure"]
  688. }),
  689. smalltalk.ReportingTestContext);
  690. smalltalk.addMethod(
  691. "_testCase_result_finished_",
  692. smalltalk.method({
  693. selector: "testCase:result:finished:",
  694. category: 'instance creation',
  695. fn: function (aTestCase,aTestResult,aBlock){
  696. var self=this;
  697. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  698. $2=smalltalk.TestContext.klass.fn.prototype._testCase_.apply(_st(self), [aTestCase]);
  699. _st($2)._result_(aTestResult);
  700. _st($2)._finished_(aBlock);
  701. $3=_st($2)._yourself();
  702. $1=$3;
  703. return $1;
  704. }, function($ctx1) {$ctx1.fill(self,"testCase:result:finished:",{aTestCase:aTestCase,aTestResult:aTestResult,aBlock:aBlock}, smalltalk.ReportingTestContext.klass)})},
  705. args: ["aTestCase", "aTestResult", "aBlock"],
  706. source: "testCase: aTestCase result: aTestResult finished: aBlock\x0a\x09^(super testCase: aTestCase)\x0a result: aTestResult;\x0a finished: aBlock;\x0a yourself",
  707. messageSends: ["result:", "testCase:", "finished:", "yourself"],
  708. referencedClasses: []
  709. }),
  710. smalltalk.ReportingTestContext.klass);
  711. smalltalk.addClass('TestFailure', smalltalk.Error, [], 'SUnit');
  712. 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."
  713. smalltalk.addClass('TestResult', smalltalk.Object, ['timestamp', 'runs', 'errors', 'failures', 'total'], 'SUnit');
  714. 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"
  715. smalltalk.addMethod(
  716. "_addError_",
  717. smalltalk.method({
  718. selector: "addError:",
  719. category: 'accessing',
  720. fn: function (anError){
  721. var self=this;
  722. return smalltalk.withContext(function($ctx1) { _st(_st(self)._errors())._add_(anError);
  723. return self}, function($ctx1) {$ctx1.fill(self,"addError:",{anError:anError}, smalltalk.TestResult)})},
  724. args: ["anError"],
  725. source: "addError: anError\x0a\x09self errors add: anError",
  726. messageSends: ["add:", "errors"],
  727. referencedClasses: []
  728. }),
  729. smalltalk.TestResult);
  730. smalltalk.addMethod(
  731. "_addFailure_",
  732. smalltalk.method({
  733. selector: "addFailure:",
  734. category: 'accessing',
  735. fn: function (aFailure){
  736. var self=this;
  737. return smalltalk.withContext(function($ctx1) { _st(_st(self)._failures())._add_(aFailure);
  738. return self}, function($ctx1) {$ctx1.fill(self,"addFailure:",{aFailure:aFailure}, smalltalk.TestResult)})},
  739. args: ["aFailure"],
  740. source: "addFailure: aFailure\x0a\x09self failures add: aFailure",
  741. messageSends: ["add:", "failures"],
  742. referencedClasses: []
  743. }),
  744. smalltalk.TestResult);
  745. smalltalk.addMethod(
  746. "_errors",
  747. smalltalk.method({
  748. selector: "errors",
  749. category: 'accessing',
  750. fn: function (){
  751. var self=this;
  752. return smalltalk.withContext(function($ctx1) { var $1;
  753. $1=self["@errors"];
  754. return $1;
  755. }, function($ctx1) {$ctx1.fill(self,"errors",{}, smalltalk.TestResult)})},
  756. args: [],
  757. source: "errors\x0a\x09^errors",
  758. messageSends: [],
  759. referencedClasses: []
  760. }),
  761. smalltalk.TestResult);
  762. smalltalk.addMethod(
  763. "_failures",
  764. smalltalk.method({
  765. selector: "failures",
  766. category: 'accessing',
  767. fn: function (){
  768. var self=this;
  769. return smalltalk.withContext(function($ctx1) { var $1;
  770. $1=self["@failures"];
  771. return $1;
  772. }, function($ctx1) {$ctx1.fill(self,"failures",{}, smalltalk.TestResult)})},
  773. args: [],
  774. source: "failures\x0a\x09^failures",
  775. messageSends: [],
  776. referencedClasses: []
  777. }),
  778. smalltalk.TestResult);
  779. smalltalk.addMethod(
  780. "_increaseRuns",
  781. smalltalk.method({
  782. selector: "increaseRuns",
  783. category: 'accessing',
  784. fn: function (){
  785. var self=this;
  786. return smalltalk.withContext(function($ctx1) { self["@runs"]=_st(self["@runs"]).__plus((1));
  787. return self}, function($ctx1) {$ctx1.fill(self,"increaseRuns",{}, smalltalk.TestResult)})},
  788. args: [],
  789. source: "increaseRuns\x0a\x09runs := runs + 1",
  790. messageSends: ["+"],
  791. referencedClasses: []
  792. }),
  793. smalltalk.TestResult);
  794. smalltalk.addMethod(
  795. "_initialize",
  796. smalltalk.method({
  797. selector: "initialize",
  798. category: 'initialization',
  799. fn: function (){
  800. var self=this;
  801. return smalltalk.withContext(function($ctx1) { smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  802. self["@timestamp"]=_st((smalltalk.Date || Date))._now();
  803. self["@runs"]=(0);
  804. self["@errors"]=_st((smalltalk.Array || Array))._new();
  805. self["@failures"]=_st((smalltalk.Array || Array))._new();
  806. self["@total"]=(0);
  807. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TestResult)})},
  808. args: [],
  809. source: "initialize\x0a\x09super initialize.\x0a\x09timestamp := Date now.\x0a\x09runs := 0.\x0a\x09errors := Array new.\x0a\x09failures := Array new.\x0a\x09total := 0",
  810. messageSends: ["initialize", "now", "new"],
  811. referencedClasses: ["Date", "Array"]
  812. }),
  813. smalltalk.TestResult);
  814. smalltalk.addMethod(
  815. "_nextRunDo_",
  816. smalltalk.method({
  817. selector: "nextRunDo:",
  818. category: 'running',
  819. fn: function (aBlock){
  820. var self=this;
  821. return smalltalk.withContext(function($ctx1) { var $2,$1;
  822. $2=_st(_st(self)._runs()).__eq_eq(_st(self)._total());
  823. if(! smalltalk.assert($2)){
  824. $1=_st(aBlock)._value_(_st(_st(self)._runs()).__plus((1)));
  825. };
  826. return $1;
  827. }, function($ctx1) {$ctx1.fill(self,"nextRunDo:",{aBlock:aBlock}, smalltalk.TestResult)})},
  828. args: ["aBlock"],
  829. 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 ]",
  830. messageSends: ["ifFalse:", "value:", "+", "runs", "==", "total"],
  831. referencedClasses: []
  832. }),
  833. smalltalk.TestResult);
  834. smalltalk.addMethod(
  835. "_runCase_",
  836. smalltalk.method({
  837. selector: "runCase:",
  838. category: 'running',
  839. fn: function (aTestCase){
  840. var self=this;
  841. return smalltalk.withContext(function($ctx1) { _st((function(){
  842. return smalltalk.withContext(function($ctx2) { return _st((function(){
  843. return smalltalk.withContext(function($ctx3) { _st(self)._increaseRuns();
  844. return _st(aTestCase)._runCase();
  845. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_((smalltalk.TestFailure || TestFailure),(function(ex){
  846. return smalltalk.withContext(function($ctx3) { return _st(self)._addFailure_(aTestCase);
  847. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  848. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_((smalltalk.Error || Error),(function(ex){
  849. return smalltalk.withContext(function($ctx2) { return _st(self)._addError_(aTestCase);
  850. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})}));
  851. return self}, function($ctx1) {$ctx1.fill(self,"runCase:",{aTestCase:aTestCase}, smalltalk.TestResult)})},
  852. args: ["aTestCase"],
  853. 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]\x0a",
  854. messageSends: ["on:do:", "addError:", "addFailure:", "increaseRuns", "runCase"],
  855. referencedClasses: ["Error", "TestFailure"]
  856. }),
  857. smalltalk.TestResult);
  858. smalltalk.addMethod(
  859. "_runs",
  860. smalltalk.method({
  861. selector: "runs",
  862. category: 'accessing',
  863. fn: function (){
  864. var self=this;
  865. return smalltalk.withContext(function($ctx1) { var $1;
  866. $1=self["@runs"];
  867. return $1;
  868. }, function($ctx1) {$ctx1.fill(self,"runs",{}, smalltalk.TestResult)})},
  869. args: [],
  870. source: "runs\x0a\x09^runs",
  871. messageSends: [],
  872. referencedClasses: []
  873. }),
  874. smalltalk.TestResult);
  875. smalltalk.addMethod(
  876. "_status",
  877. smalltalk.method({
  878. selector: "status",
  879. category: 'accessing',
  880. fn: function (){
  881. var self=this;
  882. return smalltalk.withContext(function($ctx1) { var $2,$4,$3,$1;
  883. $2=_st(_st(self)._errors())._isEmpty();
  884. $3=(function(){
  885. return smalltalk.withContext(function($ctx2) { $4=_st(_st(self)._failures())._isEmpty();
  886. if(smalltalk.assert($4)){
  887. return "success";
  888. } else {
  889. return "failure";
  890. };
  891. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})});
  892. $1=_st($2)._ifTrue_ifFalse_($3,(function(){
  893. return smalltalk.withContext(function($ctx2) { return "error";
  894. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  895. return $1;
  896. }, function($ctx1) {$ctx1.fill(self,"status",{}, smalltalk.TestResult)})},
  897. args: [],
  898. 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']",
  899. messageSends: ["ifTrue:ifFalse:", "isEmpty", "failures", "errors"],
  900. referencedClasses: []
  901. }),
  902. smalltalk.TestResult);
  903. smalltalk.addMethod(
  904. "_timestamp",
  905. smalltalk.method({
  906. selector: "timestamp",
  907. category: 'accessing',
  908. fn: function (){
  909. var self=this;
  910. return smalltalk.withContext(function($ctx1) { var $1;
  911. $1=self["@timestamp"];
  912. return $1;
  913. }, function($ctx1) {$ctx1.fill(self,"timestamp",{}, smalltalk.TestResult)})},
  914. args: [],
  915. source: "timestamp\x0a\x09^timestamp",
  916. messageSends: [],
  917. referencedClasses: []
  918. }),
  919. smalltalk.TestResult);
  920. smalltalk.addMethod(
  921. "_total",
  922. smalltalk.method({
  923. selector: "total",
  924. category: 'accessing',
  925. fn: function (){
  926. var self=this;
  927. return smalltalk.withContext(function($ctx1) { var $1;
  928. $1=self["@total"];
  929. return $1;
  930. }, function($ctx1) {$ctx1.fill(self,"total",{}, smalltalk.TestResult)})},
  931. args: [],
  932. source: "total\x0a\x09^total",
  933. messageSends: [],
  934. referencedClasses: []
  935. }),
  936. smalltalk.TestResult);
  937. smalltalk.addMethod(
  938. "_total_",
  939. smalltalk.method({
  940. selector: "total:",
  941. category: 'accessing',
  942. fn: function (aNumber){
  943. var self=this;
  944. return smalltalk.withContext(function($ctx1) { self["@total"]=aNumber;
  945. return self}, function($ctx1) {$ctx1.fill(self,"total:",{aNumber:aNumber}, smalltalk.TestResult)})},
  946. args: ["aNumber"],
  947. source: "total: aNumber\x0a\x09total := aNumber",
  948. messageSends: [],
  949. referencedClasses: []
  950. }),
  951. smalltalk.TestResult);
  952. smalltalk.addClass('TestSuiteRunner', smalltalk.Object, ['suite', 'result', 'announcer', 'runNextTest'], 'SUnit');
  953. smalltalk.addMethod(
  954. "_announcer",
  955. smalltalk.method({
  956. selector: "announcer",
  957. category: 'accessing',
  958. fn: function (){
  959. var self=this;
  960. return smalltalk.withContext(function($ctx1) { var $1;
  961. $1=self["@announcer"];
  962. return $1;
  963. }, function($ctx1) {$ctx1.fill(self,"announcer",{}, smalltalk.TestSuiteRunner)})},
  964. args: [],
  965. source: "announcer\x0a\x09^announcer",
  966. messageSends: [],
  967. referencedClasses: []
  968. }),
  969. smalltalk.TestSuiteRunner);
  970. smalltalk.addMethod(
  971. "_contextOf_",
  972. smalltalk.method({
  973. selector: "contextOf:",
  974. category: 'private',
  975. fn: function (anInteger){
  976. var self=this;
  977. return smalltalk.withContext(function($ctx1) { var $1;
  978. $1=_st((smalltalk.ReportingTestContext || ReportingTestContext))._testCase_result_finished_(_st(self["@suite"])._at_(anInteger),self["@result"],(function(){
  979. return smalltalk.withContext(function($ctx2) { return _st(self)._resume();
  980. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  981. return $1;
  982. }, function($ctx1) {$ctx1.fill(self,"contextOf:",{anInteger:anInteger}, smalltalk.TestSuiteRunner)})},
  983. args: ["anInteger"],
  984. source: "contextOf: anInteger\x0a \x09^ReportingTestContext testCase: (suite at: anInteger) result: result finished: [ self resume ]",
  985. messageSends: ["testCase:result:finished:", "at:", "resume"],
  986. referencedClasses: ["ReportingTestContext"]
  987. }),
  988. smalltalk.TestSuiteRunner);
  989. smalltalk.addMethod(
  990. "_initialize",
  991. smalltalk.method({
  992. selector: "initialize",
  993. category: 'initialization',
  994. fn: function (){
  995. var self=this;
  996. return smalltalk.withContext(function($ctx1) { var $1;
  997. smalltalk.Object.fn.prototype._initialize.apply(_st(self), []);
  998. self["@announcer"]=_st((smalltalk.Announcer || Announcer))._new();
  999. self["@result"]=_st((smalltalk.TestResult || TestResult))._new();
  1000. self["@runNextTest"]=(function(){
  1001. var runs;
  1002. return smalltalk.withContext(function($ctx2) { runs=_st(self["@result"])._runs();
  1003. runs;
  1004. $1=_st(runs).__lt(_st(self["@result"])._total());
  1005. if(smalltalk.assert($1)){
  1006. return _st(_st(self)._contextOf_(_st(runs).__plus((1))))._start();
  1007. };
  1008. }, function($ctx2) {$ctx2.fillBlock({runs:runs},$ctx1)})});
  1009. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{}, smalltalk.TestSuiteRunner)})},
  1010. args: [],
  1011. 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 ]].",
  1012. messageSends: ["initialize", "new", "runs", "ifTrue:", "start", "contextOf:", "+", "<", "total"],
  1013. referencedClasses: ["Announcer", "TestResult"]
  1014. }),
  1015. smalltalk.TestSuiteRunner);
  1016. smalltalk.addMethod(
  1017. "_result",
  1018. smalltalk.method({
  1019. selector: "result",
  1020. category: 'accessing',
  1021. fn: function (){
  1022. var self=this;
  1023. return smalltalk.withContext(function($ctx1) { var $1;
  1024. $1=self["@result"];
  1025. return $1;
  1026. }, function($ctx1) {$ctx1.fill(self,"result",{}, smalltalk.TestSuiteRunner)})},
  1027. args: [],
  1028. source: "result\x0a\x09^result",
  1029. messageSends: [],
  1030. referencedClasses: []
  1031. }),
  1032. smalltalk.TestSuiteRunner);
  1033. smalltalk.addMethod(
  1034. "_resume",
  1035. smalltalk.method({
  1036. selector: "resume",
  1037. category: 'actions',
  1038. fn: function (){
  1039. var self=this;
  1040. return smalltalk.withContext(function($ctx1) { _st(self["@runNextTest"])._fork();
  1041. _st(self["@announcer"])._announce_(_st(_st((smalltalk.ResultAnnouncement || ResultAnnouncement))._new())._result_(self["@result"]));
  1042. return self}, function($ctx1) {$ctx1.fill(self,"resume",{}, smalltalk.TestSuiteRunner)})},
  1043. args: [],
  1044. source: "resume\x0a\x09runNextTest fork.\x0a announcer announce: (ResultAnnouncement new result: result)",
  1045. messageSends: ["fork", "announce:", "result:", "new"],
  1046. referencedClasses: ["ResultAnnouncement"]
  1047. }),
  1048. smalltalk.TestSuiteRunner);
  1049. smalltalk.addMethod(
  1050. "_run",
  1051. smalltalk.method({
  1052. selector: "run",
  1053. category: 'actions',
  1054. fn: function (){
  1055. var self=this;
  1056. return smalltalk.withContext(function($ctx1) { _st(self["@result"])._total_(_st(self["@suite"])._size());
  1057. _st(self)._resume();
  1058. return self}, function($ctx1) {$ctx1.fill(self,"run",{}, smalltalk.TestSuiteRunner)})},
  1059. args: [],
  1060. source: "run\x0a\x09result total: suite size.\x0a\x09self resume",
  1061. messageSends: ["total:", "size", "resume"],
  1062. referencedClasses: []
  1063. }),
  1064. smalltalk.TestSuiteRunner);
  1065. smalltalk.addMethod(
  1066. "_suite_",
  1067. smalltalk.method({
  1068. selector: "suite:",
  1069. category: 'accessing',
  1070. fn: function (aCollection){
  1071. var self=this;
  1072. return smalltalk.withContext(function($ctx1) { self["@suite"]=aCollection;
  1073. return self}, function($ctx1) {$ctx1.fill(self,"suite:",{aCollection:aCollection}, smalltalk.TestSuiteRunner)})},
  1074. args: ["aCollection"],
  1075. source: "suite: aCollection\x0a\x09suite := aCollection",
  1076. messageSends: [],
  1077. referencedClasses: []
  1078. }),
  1079. smalltalk.TestSuiteRunner);
  1080. smalltalk.addMethod(
  1081. "_new",
  1082. smalltalk.method({
  1083. selector: "new",
  1084. category: 'instance creation',
  1085. fn: function (){
  1086. var self=this;
  1087. return smalltalk.withContext(function($ctx1) { _st(self)._shouldNotImplement();
  1088. return self}, function($ctx1) {$ctx1.fill(self,"new",{}, smalltalk.TestSuiteRunner.klass)})},
  1089. args: [],
  1090. source: "new\x0a\x09self shouldNotImplement",
  1091. messageSends: ["shouldNotImplement"],
  1092. referencedClasses: []
  1093. }),
  1094. smalltalk.TestSuiteRunner.klass);
  1095. smalltalk.addMethod(
  1096. "_on_",
  1097. smalltalk.method({
  1098. selector: "on:",
  1099. category: 'instance creation',
  1100. fn: function (aCollection){
  1101. var self=this;
  1102. return smalltalk.withContext(function($ctx1) { var $1;
  1103. $1=_st(smalltalk.Object.klass.fn.prototype._new.apply(_st(self), []))._suite_(aCollection);
  1104. return $1;
  1105. }, function($ctx1) {$ctx1.fill(self,"on:",{aCollection:aCollection}, smalltalk.TestSuiteRunner.klass)})},
  1106. args: ["aCollection"],
  1107. source: "on: aCollection\x0a\x09^super new suite: aCollection",
  1108. messageSends: ["suite:", "new"],
  1109. referencedClasses: []
  1110. }),
  1111. smalltalk.TestSuiteRunner.klass);