SUnit-Tests.deploy.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. smalltalk.addPackage('SUnit-Tests', {});
  2. smalltalk.addClass('ExampleSetTest', smalltalk.TestCase, ['empty', 'full'], 'SUnit-Tests');
  3. smalltalk.addMethod(
  4. "_setUp",
  5. smalltalk.method({
  6. selector: "setUp",
  7. fn: function (){
  8. var self=this;
  9. return smalltalk.withContext(function($ctx1) { self["@empty"]=_st((smalltalk.Set || Set))._new();
  10. self["@full"]=_st((smalltalk.Set || Set))._with_with_((5),smalltalk.symbolFor("abc"));
  11. return self}, self, "setUp", [], smalltalk.ExampleSetTest)}
  12. }),
  13. smalltalk.ExampleSetTest);
  14. smalltalk.addMethod(
  15. "_testAdd",
  16. smalltalk.method({
  17. selector: "testAdd",
  18. fn: function (){
  19. var self=this;
  20. return smalltalk.withContext(function($ctx1) { _st(self["@empty"])._add_((5));
  21. _st(self)._assert_(_st(self["@empty"])._includes_((5)));
  22. return self}, self, "testAdd", [], smalltalk.ExampleSetTest)}
  23. }),
  24. smalltalk.ExampleSetTest);
  25. smalltalk.addMethod(
  26. "_testGrow",
  27. smalltalk.method({
  28. selector: "testGrow",
  29. fn: function (){
  30. var self=this;
  31. return smalltalk.withContext(function($ctx1) { _st(self["@empty"])._addAll_(_st((1))._to_((100)));
  32. _st(self)._assert_(_st(_st(self["@empty"])._size()).__eq((100)));
  33. return self}, self, "testGrow", [], smalltalk.ExampleSetTest)}
  34. }),
  35. smalltalk.ExampleSetTest);
  36. smalltalk.addMethod(
  37. "_testIllegal",
  38. smalltalk.method({
  39. selector: "testIllegal",
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) { _st(self)._should_raise_((function(){
  43. return smalltalk.withContext(function($ctx2) { return _st(self["@empty"])._at_((5));
  44. })}),(smalltalk.Error || Error));
  45. _st(self)._should_raise_((function(){
  46. return smalltalk.withContext(function($ctx2) { return _st(self["@empty"])._at_put_((5),smalltalk.symbolFor("abc"));
  47. })}),(smalltalk.Error || Error));
  48. return self}, self, "testIllegal", [], smalltalk.ExampleSetTest)}
  49. }),
  50. smalltalk.ExampleSetTest);
  51. smalltalk.addMethod(
  52. "_testIncludes",
  53. smalltalk.method({
  54. selector: "testIncludes",
  55. fn: function (){
  56. var self=this;
  57. return smalltalk.withContext(function($ctx1) { _st(self)._assert_(_st(self["@full"])._includes_((5)));
  58. _st(self)._assert_(_st(self["@full"])._includes_(smalltalk.symbolFor("abc")));
  59. return self}, self, "testIncludes", [], smalltalk.ExampleSetTest)}
  60. }),
  61. smalltalk.ExampleSetTest);
  62. smalltalk.addMethod(
  63. "_testOccurrences",
  64. smalltalk.method({
  65. selector: "testOccurrences",
  66. fn: function (){
  67. var self=this;
  68. return smalltalk.withContext(function($ctx1) { _st(self)._assert_(_st(_st(self["@empty"])._occurrencesOf_((0))).__eq((0)));
  69. _st(self)._assert_(_st(_st(self["@full"])._occurrencesOf_((5))).__eq((1)));
  70. _st(self["@full"])._add_((5));
  71. _st(self)._assert_(_st(_st(self["@full"])._occurrencesOf_((5))).__eq((1)));
  72. return self}, self, "testOccurrences", [], smalltalk.ExampleSetTest)}
  73. }),
  74. smalltalk.ExampleSetTest);
  75. smalltalk.addMethod(
  76. "_testRemove",
  77. smalltalk.method({
  78. selector: "testRemove",
  79. fn: function (){
  80. var self=this;
  81. return smalltalk.withContext(function($ctx1) { _st(self["@full"])._remove_((5));
  82. _st(self)._assert_(_st(self["@full"])._includes_(smalltalk.symbolFor("abc")));
  83. _st(self)._deny_(_st(self["@full"])._includes_((5)));
  84. return self}, self, "testRemove", [], smalltalk.ExampleSetTest)}
  85. }),
  86. smalltalk.ExampleSetTest);
  87. smalltalk.addClass('SUnitAsyncTest', smalltalk.TestCase, ['flag'], 'SUnit-Tests');
  88. smalltalk.addMethod(
  89. "_fakeError",
  90. smalltalk.method({
  91. selector: "fakeError",
  92. fn: function (){
  93. var self=this;
  94. return smalltalk.withContext(function($ctx1) { self["@flag"]="bad";
  95. _st(self)._timeout_((10));
  96. self["@flag"]=_st(_st(self)._async_((function(){
  97. return smalltalk.withContext(function($ctx2) { self["@flag"]="ok";
  98. self["@flag"];
  99. return _st(self)._error_("Intentional");
  100. })})))._valueWithTimeout_((5));
  101. return self}, self, "fakeError", [], smalltalk.SUnitAsyncTest)}
  102. }),
  103. smalltalk.SUnitAsyncTest);
  104. smalltalk.addMethod(
  105. "_fakeErrorFailingInTearDown",
  106. smalltalk.method({
  107. selector: "fakeErrorFailingInTearDown",
  108. fn: function (){
  109. var self=this;
  110. return smalltalk.withContext(function($ctx1) { self["@flag"]="bad";
  111. _st(self)._timeout_((10));
  112. self["@flag"]=_st(_st(self)._async_((function(){
  113. return smalltalk.withContext(function($ctx2) { return _st(self)._error_("Intentional");
  114. })})))._valueWithTimeout_((5));
  115. return self}, self, "fakeErrorFailingInTearDown", [], smalltalk.SUnitAsyncTest)}
  116. }),
  117. smalltalk.SUnitAsyncTest);
  118. smalltalk.addMethod(
  119. "_fakeFailure",
  120. smalltalk.method({
  121. selector: "fakeFailure",
  122. fn: function (){
  123. var self=this;
  124. return smalltalk.withContext(function($ctx1) { self["@flag"]="bad";
  125. _st(self)._timeout_((10));
  126. self["@flag"]=_st(_st(self)._async_((function(){
  127. return smalltalk.withContext(function($ctx2) { self["@flag"]="ok";
  128. self["@flag"];
  129. return _st(self)._assert_(false);
  130. })})))._valueWithTimeout_((5));
  131. return self}, self, "fakeFailure", [], smalltalk.SUnitAsyncTest)}
  132. }),
  133. smalltalk.SUnitAsyncTest);
  134. smalltalk.addMethod(
  135. "_fakeMultipleTimeoutFailing",
  136. smalltalk.method({
  137. selector: "fakeMultipleTimeoutFailing",
  138. fn: function (){
  139. var self=this;
  140. return smalltalk.withContext(function($ctx1) { _st(self)._timeout_((100));
  141. _st(_st(self)._async_((function(){
  142. return smalltalk.withContext(function($ctx2) { _st(self)._timeout_((5));
  143. return _st(_st(self)._async_((function(){
  144. return smalltalk.withContext(function($ctx3) { return _st(self)._finished();
  145. })})))._valueWithTimeout_((10));
  146. })})))._valueWithTimeout_((5));
  147. return self}, self, "fakeMultipleTimeoutFailing", [], smalltalk.SUnitAsyncTest)}
  148. }),
  149. smalltalk.SUnitAsyncTest);
  150. smalltalk.addMethod(
  151. "_fakeMultipleTimeoutPassing",
  152. smalltalk.method({
  153. selector: "fakeMultipleTimeoutPassing",
  154. fn: function (){
  155. var self=this;
  156. return smalltalk.withContext(function($ctx1) { _st(self)._timeout_((10));
  157. _st(_st(self)._async_((function(){
  158. return smalltalk.withContext(function($ctx2) { _st(self)._timeout_((20));
  159. return _st(_st(self)._async_((function(){
  160. return smalltalk.withContext(function($ctx3) { return _st(self)._finished();
  161. })})))._valueWithTimeout_((10));
  162. })})))._valueWithTimeout_((5));
  163. return self}, self, "fakeMultipleTimeoutPassing", [], smalltalk.SUnitAsyncTest)}
  164. }),
  165. smalltalk.SUnitAsyncTest);
  166. smalltalk.addMethod(
  167. "_fakeTimeout",
  168. smalltalk.method({
  169. selector: "fakeTimeout",
  170. fn: function (){
  171. var self=this;
  172. return smalltalk.withContext(function($ctx1) { _st(self)._timeout_((4));
  173. _st(_st(self)._async_((function(){
  174. return smalltalk.withContext(function($ctx2) { return _st(self)._finished();
  175. })})))._valueWithTimeout_((5));
  176. return self}, self, "fakeTimeout", [], smalltalk.SUnitAsyncTest)}
  177. }),
  178. smalltalk.SUnitAsyncTest);
  179. smalltalk.addMethod(
  180. "_setUp",
  181. smalltalk.method({
  182. selector: "setUp",
  183. fn: function (){
  184. var self=this;
  185. return smalltalk.withContext(function($ctx1) { self["@flag"]="ok";
  186. return self}, self, "setUp", [], smalltalk.SUnitAsyncTest)}
  187. }),
  188. smalltalk.SUnitAsyncTest);
  189. smalltalk.addMethod(
  190. "_sortedSelectors_",
  191. smalltalk.method({
  192. selector: "sortedSelectors:",
  193. fn: function (aCollection){
  194. var self=this;
  195. return smalltalk.withContext(function($ctx1) { var $1;
  196. $1=_st(_st(aCollection)._collect_((function(each){
  197. return smalltalk.withContext(function($ctx2) { return _st(each)._selector();
  198. })})))._sorted();
  199. return $1;
  200. }, self, "sortedSelectors:", [aCollection], smalltalk.SUnitAsyncTest)}
  201. }),
  202. smalltalk.SUnitAsyncTest);
  203. smalltalk.addMethod(
  204. "_tearDown",
  205. smalltalk.method({
  206. selector: "tearDown",
  207. fn: function (){
  208. var self=this;
  209. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_("ok",self["@flag"]);
  210. return self}, self, "tearDown", [], smalltalk.SUnitAsyncTest)}
  211. }),
  212. smalltalk.SUnitAsyncTest);
  213. smalltalk.addMethod(
  214. "_testAsyncErrorsAndFailures",
  215. smalltalk.method({
  216. selector: "testAsyncErrorsAndFailures",
  217. fn: function (){
  218. var self=this;
  219. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$6,$5,$3;
  220. $ctx1.locals.suite=nil;
  221. $ctx1.locals.runner=nil;
  222. $ctx1.locals.result=nil;
  223. $ctx1.locals.assertBlock=nil;
  224. $ctx1.locals.suite=_st(["fakeError", "fakeErrorFailingInTearDown", "fakeFailure", "testPass"])._collect_((function(each){
  225. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._class())._selector_(each);
  226. })}));
  227. $ctx1.locals.runner=_st((smalltalk.TestSuiteRunner || TestSuiteRunner))._on_($ctx1.locals.suite);
  228. _st(self)._timeout_((200));
  229. $ctx1.locals.result=_st($ctx1.locals.runner)._result();
  230. $ctx1.locals.assertBlock=_st(self)._async_((function(){
  231. return smalltalk.withContext(function($ctx2) { _st(self)._assert_equals_(["fakeError"],_st(self)._sortedSelectors_(_st($ctx1.locals.result)._errors()));
  232. _st(self)._assert_equals_(["fakeErrorFailingInTearDown", "fakeFailure"],_st(self)._sortedSelectors_(_st($ctx1.locals.result)._failures()));
  233. return _st(self)._finished();
  234. })}));
  235. $1=_st($ctx1.locals.runner)._announcer();
  236. $2=(smalltalk.ResultAnnouncement || ResultAnnouncement);
  237. $3=(function(ann){
  238. return smalltalk.withContext(function($ctx2) { $4=_st(_st(ann)._result()).__eq_eq($ctx1.locals.result);
  239. $5=(function(){
  240. return smalltalk.withContext(function($ctx3) { $6=_st(_st($ctx1.locals.result)._runs()).__eq(_st($ctx1.locals.result)._total());
  241. return _st($6)._ifTrue_($ctx1.locals.assertBlock);
  242. })});
  243. return _st($4)._ifTrue_($5);
  244. })});
  245. _st($1)._on_do_($2,$3);
  246. _st($ctx1.locals.runner)._run();
  247. return self}, self, "testAsyncErrorsAndFailures", [], smalltalk.SUnitAsyncTest)}
  248. }),
  249. smalltalk.SUnitAsyncTest);
  250. smalltalk.addMethod(
  251. "_testAsyncNeedsTimeout",
  252. smalltalk.method({
  253. selector: "testAsyncNeedsTimeout",
  254. fn: function (){
  255. var self=this;
  256. return smalltalk.withContext(function($ctx1) { _st(self)._should_raise_((function(){
  257. return smalltalk.withContext(function($ctx2) { return _st(self)._async_((function(){
  258. return smalltalk.withContext(function($ctx3) { })}));
  259. })}),(smalltalk.Error || Error));
  260. _st(self)._timeout_((0));
  261. _st(self)._shouldnt_raise_((function(){
  262. return smalltalk.withContext(function($ctx2) { return _st(self)._async_((function(){
  263. return smalltalk.withContext(function($ctx3) { })}));
  264. })}),(smalltalk.Error || Error));
  265. _st(self)._finished();
  266. return self}, self, "testAsyncNeedsTimeout", [], smalltalk.SUnitAsyncTest)}
  267. }),
  268. smalltalk.SUnitAsyncTest);
  269. smalltalk.addMethod(
  270. "_testFinishedNeedsTimeout",
  271. smalltalk.method({
  272. selector: "testFinishedNeedsTimeout",
  273. fn: function (){
  274. var self=this;
  275. return smalltalk.withContext(function($ctx1) { _st(self)._should_raise_((function(){
  276. return smalltalk.withContext(function($ctx2) { return _st(self)._finished();
  277. })}),(smalltalk.Error || Error));
  278. _st(self)._timeout_((0));
  279. _st(self)._shouldnt_raise_((function(){
  280. return smalltalk.withContext(function($ctx2) { return _st(self)._finished();
  281. })}),(smalltalk.Error || Error));
  282. return self}, self, "testFinishedNeedsTimeout", [], smalltalk.SUnitAsyncTest)}
  283. }),
  284. smalltalk.SUnitAsyncTest);
  285. smalltalk.addMethod(
  286. "_testIsAsyncReturnsCorrectValues",
  287. smalltalk.method({
  288. selector: "testIsAsyncReturnsCorrectValues",
  289. fn: function (){
  290. var self=this;
  291. return smalltalk.withContext(function($ctx1) { _st(self)._deny_(_st(self)._isAsync());
  292. _st(self)._timeout_((0));
  293. _st(self)._assert_(_st(self)._isAsync());
  294. _st(self)._finished();
  295. _st(self)._deny_(_st(self)._isAsync());
  296. return self}, self, "testIsAsyncReturnsCorrectValues", [], smalltalk.SUnitAsyncTest)}
  297. }),
  298. smalltalk.SUnitAsyncTest);
  299. smalltalk.addMethod(
  300. "_testPass",
  301. smalltalk.method({
  302. selector: "testPass",
  303. fn: function (){
  304. var self=this;
  305. return smalltalk.withContext(function($ctx1) { self["@flag"]="bad";
  306. _st(self)._timeout_((10));
  307. self["@flag"]=_st(_st(self)._async_((function(){
  308. return smalltalk.withContext(function($ctx2) { _st(self)._assert_(true);
  309. _st(self)._finished();
  310. self["@flag"]="ok";
  311. return self["@flag"];
  312. })})))._valueWithTimeout_((5));
  313. return self}, self, "testPass", [], smalltalk.SUnitAsyncTest)}
  314. }),
  315. smalltalk.SUnitAsyncTest);
  316. smalltalk.addMethod(
  317. "_testTimeouts",
  318. smalltalk.method({
  319. selector: "testTimeouts",
  320. fn: function (){
  321. var self=this;
  322. return smalltalk.withContext(function($ctx1) { var $1,$2,$4,$6,$5,$3;
  323. $ctx1.locals.suite=nil;
  324. $ctx1.locals.runner=nil;
  325. $ctx1.locals.result=nil;
  326. $ctx1.locals.assertBlock=nil;
  327. $ctx1.locals.suite=_st(["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"])._collect_((function(each){
  328. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._class())._selector_(each);
  329. })}));
  330. $ctx1.locals.runner=_st((smalltalk.TestSuiteRunner || TestSuiteRunner))._on_($ctx1.locals.suite);
  331. _st(self)._timeout_((200));
  332. $ctx1.locals.result=_st($ctx1.locals.runner)._result();
  333. $ctx1.locals.assertBlock=_st(self)._async_((function(){
  334. return smalltalk.withContext(function($ctx2) { _st(self)._assert_(_st(_st($ctx1.locals.result)._errors())._isEmpty());
  335. _st(self)._assert_equals_(["fakeMultipleTimeoutFailing", "fakeTimeout"],_st(self)._sortedSelectors_(_st($ctx1.locals.result)._failures()));
  336. return _st(self)._finished();
  337. })}));
  338. $1=_st($ctx1.locals.runner)._announcer();
  339. $2=(smalltalk.ResultAnnouncement || ResultAnnouncement);
  340. $3=(function(ann){
  341. return smalltalk.withContext(function($ctx2) { $4=_st(_st(ann)._result()).__eq_eq($ctx1.locals.result);
  342. $5=(function(){
  343. return smalltalk.withContext(function($ctx3) { $6=_st(_st($ctx1.locals.result)._runs()).__eq(_st($ctx1.locals.result)._total());
  344. return _st($6)._ifTrue_($ctx1.locals.assertBlock);
  345. })});
  346. return _st($4)._ifTrue_($5);
  347. })});
  348. _st($1)._on_do_($2,$3);
  349. _st($ctx1.locals.runner)._run();
  350. return self}, self, "testTimeouts", [], smalltalk.SUnitAsyncTest)}
  351. }),
  352. smalltalk.SUnitAsyncTest);
  353. smalltalk.addMethod(
  354. "_testTwoAsyncPassesWithFinishedOnlyOneIsRun",
  355. smalltalk.method({
  356. selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
  357. fn: function (){
  358. var self=this;
  359. return smalltalk.withContext(function($ctx1) { $ctx1.locals.x=nil;
  360. self["@flag"]="bad";
  361. _st(self)._timeout_((10));
  362. $ctx1.locals.x=(0);
  363. self["@flag"]=_st(_st(self)._async_((function(){
  364. return smalltalk.withContext(function($ctx2) { _st(self)._finished();
  365. self["@flag"]="ok";
  366. self["@flag"];
  367. $ctx1.locals.x=_st($ctx1.locals.x).__plus((1));
  368. $ctx1.locals.x;
  369. return _st(self)._assert_equals_((1),$ctx1.locals.x);
  370. })})))._valueWithTimeout_((0));
  371. self["@flag"]=_st(_st(self)._async_((function(){
  372. return smalltalk.withContext(function($ctx2) { _st(self)._finished();
  373. self["@flag"]="ok";
  374. self["@flag"];
  375. $ctx1.locals.x=_st($ctx1.locals.x).__plus((1));
  376. $ctx1.locals.x;
  377. return _st(self)._assert_equals_((1),$ctx1.locals.x);
  378. })})))._valueWithTimeout_((0));
  379. return self}, self, "testTwoAsyncPassesWithFinishedOnlyOneIsRun", [], smalltalk.SUnitAsyncTest)}
  380. }),
  381. smalltalk.SUnitAsyncTest);