2
0

SUnit-Tests.deploy.js 17 KB

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