SUnit-Tests.deploy.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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}, function($ctx1) {$ctx1.fill(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}, function($ctx1) {$ctx1.fill(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}, function($ctx1) {$ctx1.fill(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. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(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. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
  48. return self}, function($ctx1) {$ctx1.fill(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}, function($ctx1) {$ctx1.fill(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}, function($ctx1) {$ctx1.fill(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}, function($ctx1) {$ctx1.fill(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. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((5));
  101. return self}, function($ctx1) {$ctx1.fill(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. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((5));
  115. return self}, function($ctx1) {$ctx1.fill(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. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((5));
  131. return self}, function($ctx1) {$ctx1.fill(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. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})})))._valueWithTimeout_((10));
  146. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((5));
  147. return self}, function($ctx1) {$ctx1.fill(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. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})})))._valueWithTimeout_((10));
  162. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((5));
  163. return self}, function($ctx1) {$ctx1.fill(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. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((5));
  176. return self}, function($ctx1) {$ctx1.fill(self,"fakeTimeout",{}, smalltalk.SUnitAsyncTest)})}
  177. }),
  178. smalltalk.SUnitAsyncTest);
  179. smalltalk.addMethod(
  180. "_selectorSetOf_",
  181. smalltalk.method({
  182. selector: "selectorSetOf:",
  183. fn: function (aCollection){
  184. var self=this;
  185. return smalltalk.withContext(function($ctx1) { var $1;
  186. $1=_st(_st(aCollection)._collect_((function(each){
  187. return smalltalk.withContext(function($ctx2) { return _st(each)._selector();
  188. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})))._asSet();
  189. return $1;
  190. }, function($ctx1) {$ctx1.fill(self,"selectorSetOf:",{aCollection:aCollection}, smalltalk.SUnitAsyncTest)})}
  191. }),
  192. smalltalk.SUnitAsyncTest);
  193. smalltalk.addMethod(
  194. "_setUp",
  195. smalltalk.method({
  196. selector: "setUp",
  197. fn: function (){
  198. var self=this;
  199. return smalltalk.withContext(function($ctx1) { self["@flag"]="ok";
  200. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, 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}, function($ctx1) {$ctx1.fill(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. var suite,runner,result,assertBlock;
  220. return smalltalk.withContext(function($ctx1) { var $1,$2;
  221. suite=_st(["fakeError", "fakeErrorFailingInTearDown", "fakeFailure", "testPass"])._collect_((function(each){
  222. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._class())._selector_(each);
  223. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  224. runner=_st((smalltalk.TestSuiteRunner || TestSuiteRunner))._on_(suite);
  225. _st(self)._timeout_((200));
  226. result=_st(runner)._result();
  227. assertBlock=_st(self)._async_((function(){
  228. return smalltalk.withContext(function($ctx2) { _st(self)._assert_equals_(_st(["fakeError"])._asSet(),_st(self)._selectorSetOf_(_st(result)._errors()));
  229. _st(self)._assert_equals_(_st(["fakeErrorFailingInTearDown", "fakeFailure"])._asSet(),_st(self)._selectorSetOf_(_st(result)._failures()));
  230. return _st(self)._finished();
  231. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  232. _st(_st(runner)._announcer())._on_do_((smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
  233. return smalltalk.withContext(function($ctx2) { $1=_st(_st(ann)._result()).__eq_eq(result);
  234. if(smalltalk.assert($1)){
  235. $2=_st(_st(result)._runs()).__eq(_st(result)._total());
  236. return _st($2)._ifTrue_(assertBlock);
  237. };
  238. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1)})}));
  239. _st(runner)._run();
  240. return self}, function($ctx1) {$ctx1.fill(self,"testAsyncErrorsAndFailures",{suite:suite,runner:runner,result:result,assertBlock:assertBlock}, smalltalk.SUnitAsyncTest)})}
  241. }),
  242. smalltalk.SUnitAsyncTest);
  243. smalltalk.addMethod(
  244. "_testAsyncNeedsTimeout",
  245. smalltalk.method({
  246. selector: "testAsyncNeedsTimeout",
  247. fn: function (){
  248. var self=this;
  249. return smalltalk.withContext(function($ctx1) { _st(self)._should_raise_((function(){
  250. return smalltalk.withContext(function($ctx2) { return _st(self)._async_((function(){
  251. return smalltalk.withContext(function($ctx3) { }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  252. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
  253. _st(self)._timeout_((0));
  254. _st(self)._shouldnt_raise_((function(){
  255. return smalltalk.withContext(function($ctx2) { return _st(self)._async_((function(){
  256. return smalltalk.withContext(function($ctx3) { }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  257. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
  258. _st(self)._finished();
  259. return self}, function($ctx1) {$ctx1.fill(self,"testAsyncNeedsTimeout",{}, smalltalk.SUnitAsyncTest)})}
  260. }),
  261. smalltalk.SUnitAsyncTest);
  262. smalltalk.addMethod(
  263. "_testFinishedNeedsTimeout",
  264. smalltalk.method({
  265. selector: "testFinishedNeedsTimeout",
  266. fn: function (){
  267. var self=this;
  268. return smalltalk.withContext(function($ctx1) { _st(self)._should_raise_((function(){
  269. return smalltalk.withContext(function($ctx2) { return _st(self)._finished();
  270. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
  271. _st(self)._timeout_((0));
  272. _st(self)._shouldnt_raise_((function(){
  273. return smalltalk.withContext(function($ctx2) { return _st(self)._finished();
  274. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.Error || Error));
  275. return self}, function($ctx1) {$ctx1.fill(self,"testFinishedNeedsTimeout",{}, smalltalk.SUnitAsyncTest)})}
  276. }),
  277. smalltalk.SUnitAsyncTest);
  278. smalltalk.addMethod(
  279. "_testIsAsyncReturnsCorrectValues",
  280. smalltalk.method({
  281. selector: "testIsAsyncReturnsCorrectValues",
  282. fn: function (){
  283. var self=this;
  284. return smalltalk.withContext(function($ctx1) { _st(self)._deny_(_st(self)._isAsync());
  285. _st(self)._timeout_((0));
  286. _st(self)._assert_(_st(self)._isAsync());
  287. _st(self)._finished();
  288. _st(self)._deny_(_st(self)._isAsync());
  289. return self}, function($ctx1) {$ctx1.fill(self,"testIsAsyncReturnsCorrectValues",{}, smalltalk.SUnitAsyncTest)})}
  290. }),
  291. smalltalk.SUnitAsyncTest);
  292. smalltalk.addMethod(
  293. "_testPass",
  294. smalltalk.method({
  295. selector: "testPass",
  296. fn: function (){
  297. var self=this;
  298. return smalltalk.withContext(function($ctx1) { self["@flag"]="bad";
  299. _st(self)._timeout_((10));
  300. self["@flag"]=_st(_st(self)._async_((function(){
  301. return smalltalk.withContext(function($ctx2) { _st(self)._assert_(true);
  302. _st(self)._finished();
  303. self["@flag"]="ok";
  304. return self["@flag"];
  305. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((5));
  306. return self}, function($ctx1) {$ctx1.fill(self,"testPass",{}, smalltalk.SUnitAsyncTest)})}
  307. }),
  308. smalltalk.SUnitAsyncTest);
  309. smalltalk.addMethod(
  310. "_testTimeouts",
  311. smalltalk.method({
  312. selector: "testTimeouts",
  313. fn: function (){
  314. var self=this;
  315. var suite,runner,result,assertBlock;
  316. return smalltalk.withContext(function($ctx1) { var $1,$2;
  317. suite=_st(["fakeTimeout", "fakeMultipleTimeoutFailing", "fakeMultipleTimeoutPassing", "testPass"])._collect_((function(each){
  318. return smalltalk.withContext(function($ctx2) { return _st(_st(self)._class())._selector_(each);
  319. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  320. runner=_st((smalltalk.TestSuiteRunner || TestSuiteRunner))._on_(suite);
  321. _st(self)._timeout_((200));
  322. result=_st(runner)._result();
  323. assertBlock=_st(self)._async_((function(){
  324. return smalltalk.withContext(function($ctx2) { _st(self)._assert_equals_(_st((smalltalk.Set || Set))._new(),_st(self)._selectorSetOf_(_st(result)._errors()));
  325. _st(self)._assert_equals_(_st(["fakeMultipleTimeoutFailing", "fakeTimeout"])._asSet(),_st(self)._selectorSetOf_(_st(result)._failures()));
  326. return _st(self)._finished();
  327. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  328. _st(_st(runner)._announcer())._on_do_((smalltalk.ResultAnnouncement || ResultAnnouncement),(function(ann){
  329. return smalltalk.withContext(function($ctx2) { $1=_st(_st(ann)._result()).__eq_eq(result);
  330. if(smalltalk.assert($1)){
  331. $2=_st(_st(result)._runs()).__eq(_st(result)._total());
  332. return _st($2)._ifTrue_(assertBlock);
  333. };
  334. }, function($ctx2) {$ctx2.fillBlock({ann:ann},$ctx1)})}));
  335. _st(runner)._run();
  336. return self}, function($ctx1) {$ctx1.fill(self,"testTimeouts",{suite:suite,runner:runner,result:result,assertBlock:assertBlock}, smalltalk.SUnitAsyncTest)})}
  337. }),
  338. smalltalk.SUnitAsyncTest);
  339. smalltalk.addMethod(
  340. "_testTwoAsyncPassesWithFinishedOnlyOneIsRun",
  341. smalltalk.method({
  342. selector: "testTwoAsyncPassesWithFinishedOnlyOneIsRun",
  343. fn: function (){
  344. var self=this;
  345. var x;
  346. return smalltalk.withContext(function($ctx1) { self["@flag"]="bad";
  347. _st(self)._timeout_((10));
  348. x=(0);
  349. self["@flag"]=_st(_st(self)._async_((function(){
  350. return smalltalk.withContext(function($ctx2) { _st(self)._finished();
  351. self["@flag"]="ok";
  352. self["@flag"];
  353. x=_st(x).__plus((1));
  354. x;
  355. return _st(self)._assert_equals_((1),x);
  356. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((0));
  357. self["@flag"]=_st(_st(self)._async_((function(){
  358. return smalltalk.withContext(function($ctx2) { _st(self)._finished();
  359. self["@flag"]="ok";
  360. self["@flag"];
  361. x=_st(x).__plus((1));
  362. x;
  363. return _st(self)._assert_equals_((1),x);
  364. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((0));
  365. return self}, function($ctx1) {$ctx1.fill(self,"testTwoAsyncPassesWithFinishedOnlyOneIsRun",{x:x}, smalltalk.SUnitAsyncTest)})}
  366. }),
  367. smalltalk.SUnitAsyncTest);