2
0

SUnit-Tests.deploy.js 17 KB

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