SUnit.js 42 KB

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