Kernel-Tests.deploy.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. smalltalk.addClass('StringTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2. smalltalk.addMethod(
  3. '_testJoin',
  4. smalltalk.method({
  5. selector: 'testJoin',
  6. fn: function (){
  7. var self=this;
  8. smalltalk.send(self, "_assert_equals_", [unescape("hello%2Cworld"), smalltalk.send(unescape("%2C"), "_join_", [["hello", "world"]])]);
  9. return self;}
  10. }),
  11. smalltalk.StringTest);
  12. smalltalk.addMethod(
  13. '_testStreamContents',
  14. smalltalk.method({
  15. selector: 'testStreamContents',
  16. fn: function (){
  17. var self=this;
  18. smalltalk.send(self, "_assert_equals_", ["hello world", smalltalk.send((smalltalk.String || String), "_streamContents_", [(function(aStream){return (function($rec){smalltalk.send($rec, "_nextPutAll_", ["hello"]);smalltalk.send($rec, "_space", []);return smalltalk.send($rec, "_nextPutAll_", ["world"]);})(aStream);})])]);
  19. return self;}
  20. }),
  21. smalltalk.StringTest);
  22. smalltalk.addMethod(
  23. '_testIncludesSubString',
  24. smalltalk.method({
  25. selector: 'testIncludesSubString',
  26. fn: function (){
  27. var self=this;
  28. smalltalk.send(self, "_assert_", [smalltalk.send("jtalk", "_includesSubString_", ["alk"])]);
  29. smalltalk.send(self, "_deny_", [smalltalk.send("jtalk", "_includesSubString_", ["zork"])]);
  30. return self;}
  31. }),
  32. smalltalk.StringTest);
  33. smalltalk.addMethod(
  34. '_testEquality',
  35. smalltalk.method({
  36. selector: 'testEquality',
  37. fn: function (){
  38. var self=this;
  39. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", ["hello"])]);
  40. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq", ["world"])]);
  41. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", [smalltalk.send("hello", "_yourself", [])])]);
  42. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_yourself", []), "__eq", ["hello"])]);
  43. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  44. return self;}
  45. }),
  46. smalltalk.StringTest);
  47. smalltalk.addClass('DictionaryTest', smalltalk.TestCase, [], 'Kernel-Tests');
  48. smalltalk.addMethod(
  49. '_testPrintString',
  50. smalltalk.method({
  51. selector: 'testPrintString',
  52. fn: function (){
  53. var self=this;
  54. smalltalk.send(self, "_assert_equals_", [unescape("a%20Dictionary%28%27firstname%27%20-%3E%20%27James%27%20%2C%20%27lastname%27%20-%3E%20%27Bond%27%29"), (function($rec){smalltalk.send($rec, "_at_put_", ["firstname", "James"]);smalltalk.send($rec, "_at_put_", ["lastname", "Bond"]);return smalltalk.send($rec, "_printString", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []))]);
  55. return self;}
  56. }),
  57. smalltalk.DictionaryTest);
  58. smalltalk.addMethod(
  59. '_testEquality',
  60. smalltalk.method({
  61. selector: 'testEquality',
  62. fn: function (){
  63. var self=this;
  64. var d1=nil;
  65. var d2=nil;
  66. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []), "__eq", [smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])])]);
  67. d1=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  68. d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  69. smalltalk.send(self, "_assert_", [smalltalk.send(d1, "__eq", [d2])]);
  70. d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (3)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  71. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  72. d2=(function($rec){smalltalk.send($rec, "_at_put_", [(2), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  73. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  74. d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);smalltalk.send($rec, "_at_put_", [(3), (4)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  75. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  76. return self;}
  77. }),
  78. smalltalk.DictionaryTest);
  79. smalltalk.addMethod(
  80. '_testDynamicDictionaries',
  81. smalltalk.method({
  82. selector: 'testDynamicDictionaries',
  83. fn: function (){
  84. var self=this;
  85. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.Dictionary._fromPairs_([smalltalk.send((1), "__minus_gt", ["hello"]),smalltalk.send((2), "__minus_gt", ["world"])]), "__eq", [smalltalk.send((smalltalk.Dictionary || Dictionary), "_with_with_", [smalltalk.send((1), "__minus_gt", ["hello"]), smalltalk.send((2), "__minus_gt", ["world"])])])]);
  86. return self;}
  87. }),
  88. smalltalk.DictionaryTest);
  89. smalltalk.addClass('BooleanTest', smalltalk.TestCase, [], 'Kernel-Tests');
  90. smalltalk.addMethod(
  91. '_testLogic',
  92. smalltalk.method({
  93. selector: 'testLogic',
  94. fn: function (){
  95. var self=this;
  96. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_&", [true])]);smalltalk.send($rec, "_deny_", [smalltalk.send(true, "_&", [false])]);smalltalk.send($rec, "_deny_", [smalltalk.send(false, "_&", [true])]);return smalltalk.send($rec, "_deny_", [smalltalk.send(false, "_&", [false])]);})(self);
  97. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_|", [true])]);smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_|", [false])]);smalltalk.send($rec, "_assert_", [smalltalk.send(false, "_|", [true])]);return smalltalk.send($rec, "_deny_", [smalltalk.send(false, "_|", [false])]);})(self);
  98. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_&", [(1) > (0)])]);smalltalk.send($rec, "_deny_", [smalltalk.send((1) > (0), "_&", [false])]);return smalltalk.send($rec, "_deny_", [smalltalk.send((1) > (0), "_&", [(1) > (2)])]);})(self);
  99. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(false, "_|", [(1) > (0)])]);smalltalk.send($rec, "_assert_", [smalltalk.send((1) > (0), "_|", [false])]);return smalltalk.send($rec, "_assert_", [smalltalk.send((1) > (0), "_|", [(1) > (2)])]);})(self);
  100. return self;}
  101. }),
  102. smalltalk.BooleanTest);
  103. smalltalk.addMethod(
  104. '_testEquality',
  105. smalltalk.method({
  106. selector: 'testEquality',
  107. fn: function (){
  108. var self=this;
  109. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [false])]);
  110. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [(0)])]);
  111. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [false])]);
  112. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [""])]);
  113. smalltalk.send(self, "_assert_", [smalltalk.send(true, "__eq", [true])]);
  114. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [true])]);
  115. smalltalk.send(self, "_deny_", [smalltalk.send(true, "__eq", [false])]);
  116. smalltalk.send(self, "_assert_", [smalltalk.send(false, "__eq", [false])]);
  117. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq", [true])]);
  118. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq", [smalltalk.send(true, "_yourself", [])])]);
  119. return self;}
  120. }),
  121. smalltalk.BooleanTest);
  122. smalltalk.addMethod(
  123. '_testLogicKeywords',
  124. smalltalk.method({
  125. selector: 'testLogicKeywords',
  126. fn: function (){
  127. var self=this;
  128. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_and_", [(function(){return true;})])]);smalltalk.send($rec, "_deny_", [smalltalk.send(true, "_and_", [(function(){return false;})])]);smalltalk.send($rec, "_deny_", [smalltalk.send(false, "_and_", [(function(){return true;})])]);return smalltalk.send($rec, "_deny_", [smalltalk.send(false, "_and_", [(function(){return false;})])]);})(self);
  129. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_or_", [(function(){return true;})])]);smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_or_", [(function(){return false;})])]);smalltalk.send($rec, "_assert_", [smalltalk.send(false, "_or_", [(function(){return true;})])]);return smalltalk.send($rec, "_deny_", [smalltalk.send(false, "_or_", [(function(){return false;})])]);})(self);
  130. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(true, "_and_", [(function(){return (1) > (0);})])]);smalltalk.send($rec, "_deny_", [smalltalk.send((1) > (0), "_and_", [(function(){return false;})])]);return smalltalk.send($rec, "_deny_", [smalltalk.send((1) > (0), "_and_", [(function(){return (1) > (2);})])]);})(self);
  131. (function($rec){smalltalk.send($rec, "_assert_", [smalltalk.send(false, "_or_", [(function(){return (1) > (0);})])]);smalltalk.send($rec, "_assert_", [smalltalk.send((1) > (0), "_or_", [(function(){return false;})])]);return smalltalk.send($rec, "_assert_", [smalltalk.send((1) > (0), "_or_", [(function(){return (1) > (2);})])]);})(self);
  132. return self;}
  133. }),
  134. smalltalk.BooleanTest);
  135. smalltalk.addMethod(
  136. '_testIfTrueIfFalse',
  137. smalltalk.method({
  138. selector: 'testIfTrueIfFalse',
  139. fn: function (){
  140. var self=this;
  141. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = true).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return "alternative block";})]), "__eq", ["alternative block"])]);
  142. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = true).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return "alternative block";})]), "__eq", [nil])]);
  143. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = false).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return "alternative block";})]), "__eq", [nil])]);
  144. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = false).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return "alternative block";})]), "__eq", ["alternative block"])]);
  145. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = false).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "alternative block";})() : (function(){return "alternative block2";})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return "alternative block";}), (function(){return "alternative block2";})]), "__eq", ["alternative block2"])]);
  146. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = false).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return "alternative block";})() : (function(){return "alternative block2";})()) : smalltalk.send($receiver, "_ifFalse_ifTrue_", [(function(){return "alternative block";}), (function(){return "alternative block2";})]), "__eq", ["alternative block"])]);
  147. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = true).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "alternative block";})() : (function(){return "alternative block2";})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return "alternative block";}), (function(){return "alternative block2";})]), "__eq", ["alternative block"])]);
  148. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = true).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return "alternative block";})() : (function(){return "alternative block2";})()) : smalltalk.send($receiver, "_ifFalse_ifTrue_", [(function(){return "alternative block";}), (function(){return "alternative block2";})]), "__eq", ["alternative block2"])]);
  149. return self;}
  150. }),
  151. smalltalk.BooleanTest);
  152. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  153. smalltalk.addMethod(
  154. '_testEquality',
  155. smalltalk.method({
  156. selector: 'testEquality',
  157. fn: function (){
  158. var self=this;
  159. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [(1)])]);
  160. smalltalk.send(self, "_assert_", [smalltalk.send((0), "__eq", [(0)])]);
  161. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq", [(0)])]);
  162. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [(1)])]);
  163. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  164. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  165. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [false])]);
  166. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [(0)])]);
  167. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  168. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [""])]);
  169. return self;}
  170. }),
  171. smalltalk.NumberTest);
  172. smalltalk.addMethod(
  173. '_testArithmetic',
  174. smalltalk.method({
  175. selector: 'testArithmetic',
  176. fn: function (){
  177. var self=this;
  178. smalltalk.send(self, "_assert_", [smalltalk.send((1.5) + (1), "__eq", [(2.5)])]);
  179. smalltalk.send(self, "_assert_", [smalltalk.send((2) - (1), "__eq", [(1)])]);
  180. smalltalk.send(self, "_assert_", [smalltalk.send((-2) - (1), "__eq", [(-3)])]);
  181. smalltalk.send(self, "_assert_", [smalltalk.send((12) / (2), "__eq", [(6)])]);
  182. smalltalk.send(self, "_assert_", [smalltalk.send((3) * (4), "__eq", [(12)])]);
  183. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = (1) + (2)).klass === smalltalk.Number) ? $receiver *(3) : smalltalk.send($receiver, "__star", [(3)]), "__eq", [(9)])]);
  184. smalltalk.send(self, "_assert_", [smalltalk.send((1) + (2) * (3), "__eq", [(7)])]);
  185. return self;}
  186. }),
  187. smalltalk.NumberTest);
  188. smalltalk.addMethod(
  189. '_testRounded',
  190. smalltalk.method({
  191. selector: 'testRounded',
  192. fn: function (){
  193. var self=this;
  194. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_rounded", []), "__eq", [(3)])]);
  195. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_rounded", []), "__eq", [(3)])]);
  196. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_rounded", []), "__eq", [(4)])]);
  197. return self;}
  198. }),
  199. smalltalk.NumberTest);
  200. smalltalk.addMethod(
  201. '_testNegated',
  202. smalltalk.method({
  203. selector: 'testNegated',
  204. fn: function (){
  205. var self=this;
  206. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_negated", []), "__eq", [(-3)])]);
  207. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((-3), "_negated", []), "__eq", [(3)])]);
  208. return self;}
  209. }),
  210. smalltalk.NumberTest);
  211. smalltalk.addMethod(
  212. '_testComparison',
  213. smalltalk.method({
  214. selector: 'testComparison',
  215. fn: function (){
  216. var self=this;
  217. smalltalk.send(self, "_assert_", [(3) > (2)]);
  218. smalltalk.send(self, "_assert_", [(2) < (3)]);
  219. smalltalk.send(self, "_deny_", [(3) < (2)]);
  220. smalltalk.send(self, "_deny_", [(2) > (3)]);
  221. smalltalk.send(self, "_assert_", [(3) >= (3)]);
  222. smalltalk.send(self, "_assert_", [(3.1) >= (3)]);
  223. smalltalk.send(self, "_assert_", [(3) <= (3)]);
  224. smalltalk.send(self, "_assert_", [(3) <= (3.1)]);
  225. return self;}
  226. }),
  227. smalltalk.NumberTest);
  228. smalltalk.addMethod(
  229. '_testTruncated',
  230. smalltalk.method({
  231. selector: 'testTruncated',
  232. fn: function (){
  233. var self=this;
  234. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_truncated", []), "__eq", [(3)])]);
  235. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_truncated", []), "__eq", [(3)])]);
  236. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_truncated", []), "__eq", [(3)])]);
  237. return self;}
  238. }),
  239. smalltalk.NumberTest);
  240. smalltalk.addMethod(
  241. '_testPrintShowingDecimalPlaces',
  242. smalltalk.method({
  243. selector: 'testPrintShowingDecimalPlaces',
  244. fn: function (){
  245. var self=this;
  246. smalltalk.send(self, "_assert_equals_", ["23.00", smalltalk.send((23), "_printShowingDecimalPlaces_", [(2)])]);
  247. smalltalk.send(self, "_assert_equals_", ["23.57", smalltalk.send((23.5698), "_printShowingDecimalPlaces_", [(2)])]);
  248. smalltalk.send(self, "_assert_equals_", [unescape("-234.56700"), smalltalk.send(smalltalk.send((234.567), "_negated", []), "_printShowingDecimalPlaces_", [(5)])]);
  249. smalltalk.send(self, "_assert_equals_", ["23", smalltalk.send((23.4567), "_printShowingDecimalPlaces_", [(0)])]);
  250. smalltalk.send(self, "_assert_equals_", ["24", smalltalk.send((23.5567), "_printShowingDecimalPlaces_", [(0)])]);
  251. smalltalk.send(self, "_assert_equals_", [unescape("-23"), smalltalk.send(smalltalk.send((23.4567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  252. smalltalk.send(self, "_assert_equals_", [unescape("-24"), smalltalk.send(smalltalk.send((23.5567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  253. smalltalk.send(self, "_assert_equals_", ["100000000.0", smalltalk.send((100000000), "_printShowingDecimalPlaces_", [(1)])]);
  254. smalltalk.send(self, "_assert_equals_", ["0.98000", smalltalk.send((0.98), "_printShowingDecimalPlaces_", [(5)])]);
  255. smalltalk.send(self, "_assert_equals_", [unescape("-0.98"), smalltalk.send(smalltalk.send((0.98), "_negated", []), "_printShowingDecimalPlaces_", [(2)])]);
  256. smalltalk.send(self, "_assert_equals_", ["2.57", smalltalk.send((2.567), "_printShowingDecimalPlaces_", [(2)])]);
  257. smalltalk.send(self, "_assert_equals_", [unescape("-2.57"), smalltalk.send((-2.567), "_printShowingDecimalPlaces_", [(2)])]);
  258. smalltalk.send(self, "_assert_equals_", ["0.00", smalltalk.send((0), "_printShowingDecimalPlaces_", [(2)])]);
  259. return self;}
  260. }),
  261. smalltalk.NumberTest);