2
0

Kernel-Tests.js 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076
  1. smalltalk.addPackage('Kernel-Tests', {});
  2. smalltalk.addClass('ArrayTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3. smalltalk.addMethod(
  4. "_testAtIfAbsent",
  5. smalltalk.method({
  6. selector: "testAtIfAbsent",
  7. category: 'testing',
  8. fn: function () {
  9. var self=this;
  10. var array=nil;
  11. (array=["hello", "world"]);
  12. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_", [(1)]), "hello"]);
  13. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_", [(2)]), "world"]);
  14. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(2), (function(){return "not found";})]), "world"]);
  15. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(0), (function(){return "not found";})]), "not found"]);
  16. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(-10), (function(){return "not found";})]), "not found"]);
  17. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(3), (function(){return "not found";})]), "not found"]);
  18. return self;},
  19. args: [],
  20. source: "testAtIfAbsent\x0a\x09| array |\x0a\x09array := #('hello' 'world').\x0a\x09self assert: (array at: 1) equals: 'hello'.\x0a\x09self assert: (array at: 2) equals: 'world'.\x0a\x09self assert: (array at: 2 ifAbsent: ['not found']) equals: 'world'.\x0a\x09self assert: (array at: 0 ifAbsent: ['not found']) equals: 'not found'.\x0a\x09self assert: (array at: -10 ifAbsent: ['not found']) equals: 'not found'.\x0a\x09self assert: (array at: 3 ifAbsent: ['not found']) equals: 'not found'.",
  21. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  22. referencedClasses: []
  23. }),
  24. smalltalk.ArrayTest);
  25. smalltalk.addMethod(
  26. "_testFirstN",
  27. smalltalk.method({
  28. selector: "testFirstN",
  29. category: 'testing',
  30. fn: function () {
  31. var self=this;
  32. smalltalk.send(self, "_assert_equals_", [[(1),(2),(3)], smalltalk.send([(1),(2),(3),(4),(5)], "_first_", [(3)])]);
  33. return self;},
  34. args: [],
  35. source: "testFirstN\x0a\x09self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).",
  36. messageSends: ["assert:equals:", "first:"],
  37. referencedClasses: []
  38. }),
  39. smalltalk.ArrayTest);
  40. smalltalk.addMethod(
  41. "_testIfEmpty",
  42. smalltalk.method({
  43. selector: "testIfEmpty",
  44. category: 'testing',
  45. fn: function () {
  46. var self=this;
  47. smalltalk.send(self, "_assert_equals_", ["zork", smalltalk.send("", "_ifEmpty_", [(function(){return "zork";})])]);
  48. return self;},
  49. args: [],
  50. source: "testIfEmpty\x0a\x09self assert: 'zork' equals: ( '' ifEmpty: ['zork'] )",
  51. messageSends: ["assert:equals:", "ifEmpty:"],
  52. referencedClasses: []
  53. }),
  54. smalltalk.ArrayTest);
  55. smalltalk.addClass('BlockClosureTest', smalltalk.TestCase, [], 'Kernel-Tests');
  56. smalltalk.addMethod(
  57. "_testCompiledSource",
  58. smalltalk.method({
  59. selector: "testCompiledSource",
  60. category: 'tests',
  61. fn: function () {
  62. var self=this;
  63. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((function(){return (1) + (1);}), "_compiledSource", []), "_includesSubString_", ["function"])]);
  64. return self;},
  65. args: [],
  66. source: "testCompiledSource\x0a\x09self assert: ([1+1] compiledSource includesSubString: 'function')",
  67. messageSends: ["assert:", "includesSubString:", "compiledSource", "+"],
  68. referencedClasses: []
  69. }),
  70. smalltalk.BlockClosureTest);
  71. smalltalk.addMethod(
  72. "_testEnsure",
  73. smalltalk.method({
  74. selector: "testEnsure",
  75. category: 'tests',
  76. fn: function () {
  77. var self=this;
  78. smalltalk.send(self, "_assert_", [smalltalk.send((function(){return smalltalk.send((smalltalk.Error || Error), "_new", []);}), "_ensure_", [(function(){return true;})])]);
  79. return self;},
  80. args: [],
  81. source: "testEnsure\x0a\x09self assert: ([Error new] ensure: [true])",
  82. messageSends: ["assert:", "ensure:", "new"],
  83. referencedClasses: ["Error"]
  84. }),
  85. smalltalk.BlockClosureTest);
  86. smalltalk.addMethod(
  87. "_testNumArgs",
  88. smalltalk.method({
  89. selector: "testNumArgs",
  90. category: 'tests',
  91. fn: function () {
  92. var self=this;
  93. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(){return nil;}), "_numArgs", []), (0)]);
  94. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(a, b){return nil;}), "_numArgs", []), (2)]);
  95. return self;},
  96. args: [],
  97. source: "testNumArgs\x0a\x09self assert: [] numArgs equals: 0.\x0a\x09self assert: [:a :b | ] numArgs equals: 2",
  98. messageSends: ["assert:equals:", "numArgs"],
  99. referencedClasses: []
  100. }),
  101. smalltalk.BlockClosureTest);
  102. smalltalk.addMethod(
  103. "_testOnDo",
  104. smalltalk.method({
  105. selector: "testOnDo",
  106. category: 'tests',
  107. fn: function () {
  108. var self=this;
  109. smalltalk.send(self, "_assert_", [smalltalk.send((function(){return smalltalk.send(smalltalk.send((smalltalk.Error || Error), "_new", []), "_signal", []);}), "_on_do_", [(smalltalk.Error || Error), (function(ex){return true;})])]);
  110. return self;},
  111. args: [],
  112. source: "testOnDo\x0a\x09self assert: ([Error new signal] on: Error do: [:ex | true])",
  113. messageSends: ["assert:", "on:do:", "signal", "new"],
  114. referencedClasses: ["Error"]
  115. }),
  116. smalltalk.BlockClosureTest);
  117. smalltalk.addMethod(
  118. "_testValue",
  119. smalltalk.method({
  120. selector: "testValue",
  121. category: 'tests',
  122. fn: function () {
  123. var self=this;
  124. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(){return (1) + (1);}), "_value", []), (2)]);
  125. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(x){return ((($receiver = x).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]));}), "_value_", [(2)]), (3)]);
  126. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(x, y){return ((($receiver = x).klass === smalltalk.Number) ? $receiver *y : smalltalk.send($receiver, "__star", [y]));}), "_value_value_", [(2), (4)]), (8)]);
  127. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(a, b, c){return (1);}), "_value", []), (1)]);
  128. return self;},
  129. args: [],
  130. source: "testValue\x0a\x09self assert: ([1+1] value) equals: 2.\x0a\x09self assert: ([:x | x +1] value: 2) equals: 3.\x0a\x09self assert: ([:x :y | x*y] value: 2 value: 4) equals: 8. \x0a\x0a\x09\x22Arguments are optional in Amber. This isn't ANSI compliant.\x22\x0a\x0a\x09self assert: ([:a :b :c | 1] value) equals: 1",
  131. messageSends: ["assert:equals:", "value", "+", "value:", "value:value:", "*"],
  132. referencedClasses: []
  133. }),
  134. smalltalk.BlockClosureTest);
  135. smalltalk.addMethod(
  136. "_testValueWithPossibleArguments",
  137. smalltalk.method({
  138. selector: "testValueWithPossibleArguments",
  139. category: 'tests',
  140. fn: function () {
  141. var self=this;
  142. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(){return (1);}), "_valueWithPossibleArguments_", [[(3), (4)]]), (1)]);
  143. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(a){return ((($receiver = a).klass === smalltalk.Number) ? $receiver +(4) : smalltalk.send($receiver, "__plus", [(4)]));}), "_valueWithPossibleArguments_", [[(3), (4)]]), (7)]);
  144. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(a, b){return ((($receiver = a).klass === smalltalk.Number) ? $receiver +b : smalltalk.send($receiver, "__plus", [b]));}), "_valueWithPossibleArguments_", [[(3), (4), (5)]]), (7)]);
  145. return self;},
  146. args: [],
  147. source: "testValueWithPossibleArguments\x0a\x09self assert: ([1] valueWithPossibleArguments: #(3 4)) equals: 1.\x0a\x09self assert: ([:a | a + 4] valueWithPossibleArguments: #(3 4)) equals: 7.\x0a\x09self assert: ([:a :b | a + b] valueWithPossibleArguments: #(3 4 5)) equals: 7.",
  148. messageSends: ["assert:equals:", "valueWithPossibleArguments:", "+"],
  149. referencedClasses: []
  150. }),
  151. smalltalk.BlockClosureTest);
  152. smalltalk.addMethod(
  153. "_testWhileFalse",
  154. smalltalk.method({
  155. selector: "testWhileFalse",
  156. category: 'tests',
  157. fn: function () {
  158. var self=this;
  159. var i=nil;
  160. (i=(0));
  161. (function(){while(!(function(){return ((($receiver = i).klass === smalltalk.Number) ? $receiver >(5) : smalltalk.send($receiver, "__gt", [(5)]));})()) {(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})()}})();
  162. smalltalk.send(self, "_assert_equals_", [i, (6)]);
  163. (i=(0));
  164. (function(){while(!(function(){(i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));return ((($receiver = i).klass === smalltalk.Number) ? $receiver >(5) : smalltalk.send($receiver, "__gt", [(5)]));})()) {}})();
  165. smalltalk.send(self, "_assert_equals_", [i, (6)]);
  166. return self;},
  167. args: [],
  168. source: "testWhileFalse\x0a\x09| i |\x0a\x09i := 0.\x0a\x09[i > 5] whileFalse: [i := i + 1].\x0a\x09self assert: i equals: 6.\x0a\x0a\x09i := 0.\x0a\x09[i := i + 1. i > 5] whileFalse.\x0a\x09self assert: i equals: 6",
  169. messageSends: ["whileFalse:", ">", "+", "assert:equals:", "whileFalse"],
  170. referencedClasses: []
  171. }),
  172. smalltalk.BlockClosureTest);
  173. smalltalk.addMethod(
  174. "_testWhileTrue",
  175. smalltalk.method({
  176. selector: "testWhileTrue",
  177. category: 'tests',
  178. fn: function () {
  179. var self=this;
  180. var i=nil;
  181. (i=(0));
  182. (function(){while((function(){return ((($receiver = i).klass === smalltalk.Number) ? $receiver <(5) : smalltalk.send($receiver, "__lt", [(5)]));})()) {(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})()}})();
  183. smalltalk.send(self, "_assert_equals_", [i, (5)]);
  184. (i=(0));
  185. (function(){while((function(){(i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));return ((($receiver = i).klass === smalltalk.Number) ? $receiver <(5) : smalltalk.send($receiver, "__lt", [(5)]));})()) {}})();
  186. smalltalk.send(self, "_assert_equals_", [i, (5)]);
  187. return self;},
  188. args: [],
  189. source: "testWhileTrue\x0a\x09| i |\x0a\x09i := 0.\x0a\x09[i < 5] whileTrue: [i := i + 1].\x0a\x09self assert: i equals: 5.\x0a\x0a\x09i := 0.\x0a\x09[i := i + 1. i < 5] whileTrue.\x0a\x09self assert: i equals: 5",
  190. messageSends: ["whileTrue:", "<", "+", "assert:equals:", "whileTrue"],
  191. referencedClasses: []
  192. }),
  193. smalltalk.BlockClosureTest);
  194. smalltalk.addClass('BooleanTest', smalltalk.TestCase, [], 'Kernel-Tests');
  195. smalltalk.addMethod(
  196. "_testEquality",
  197. smalltalk.method({
  198. selector: "testEquality",
  199. category: 'tests',
  200. fn: function () {
  201. var self=this;
  202. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [false])]);
  203. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [(0)])]);
  204. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [false])]);
  205. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [""])]);
  206. smalltalk.send(self, "_assert_", [smalltalk.send(true, "__eq", [true])]);
  207. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [true])]);
  208. smalltalk.send(self, "_deny_", [smalltalk.send(true, "__eq", [false])]);
  209. smalltalk.send(self, "_assert_", [smalltalk.send(false, "__eq", [false])]);
  210. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq", [true])]);
  211. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq", [smalltalk.send(true, "_yourself", [])])]);
  212. return self;},
  213. args: [],
  214. source: "testEquality\x0a\x09\x22We're on top of JS...just be sure to check the basics!\x22\x0a\x0a\x09self deny: 0 = false. \x0a\x09self deny: false = 0.\x0a\x09self deny: '' = false.\x0a\x09self deny: false = ''.\x0a\x0a\x09self assert: true = true.\x0a\x09self deny: false = true.\x0a\x09self deny: true = false.\x0a\x09self assert: false = false.\x0a\x0a\x09\x22JS may do some type coercing after sending a message\x22\x0a\x09self assert: true yourself = true.\x0a\x09self assert: true yourself = true yourself",
  215. messageSends: ["deny:", "=", "assert:", "yourself"],
  216. referencedClasses: []
  217. }),
  218. smalltalk.BooleanTest);
  219. smalltalk.addMethod(
  220. "_testIfTrueIfFalse",
  221. smalltalk.method({
  222. selector: "testIfTrueIfFalse",
  223. category: 'tests',
  224. fn: function () {
  225. var self=this;
  226. 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"])]);
  227. 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])]);
  228. 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])]);
  229. 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"])]);
  230. 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"])]);
  231. 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"])]);
  232. 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"])]);
  233. 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"])]);
  234. return self;},
  235. args: [],
  236. source: "testIfTrueIfFalse\x0a \x0a\x09self assert: (true ifTrue: ['alternative block']) = 'alternative block'.\x0a\x09self assert: (true ifFalse: ['alternative block']) = nil.\x0a\x0a\x09self assert: (false ifTrue: ['alternative block']) = nil.\x0a\x09self assert: (false ifFalse: ['alternative block']) = 'alternative block'.\x0a\x0a\x09self assert: (false ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.\x0a\x09self assert: (false ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.\x0a\x0a\x09self assert: (true ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.\x0a\x09self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.",
  237. messageSends: ["assert:", "=", "ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  238. referencedClasses: []
  239. }),
  240. smalltalk.BooleanTest);
  241. smalltalk.addMethod(
  242. "_testLogic",
  243. smalltalk.method({
  244. selector: "testLogic",
  245. category: 'tests',
  246. fn: function () {
  247. var self=this;
  248. (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);
  249. (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);
  250. (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);
  251. (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);
  252. return self;},
  253. args: [],
  254. source: "testLogic\x0a \x0a\x09\x22Trivial logic table\x22\x0a\x09self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).\x0a\x09self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).\x0a \x22Checking that expressions work fine too\x22\x0a\x09self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).\x0a self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))",
  255. messageSends: ["assert:", "&", "deny:", "|", ">"],
  256. referencedClasses: []
  257. }),
  258. smalltalk.BooleanTest);
  259. smalltalk.addMethod(
  260. "_testLogicKeywords",
  261. smalltalk.method({
  262. selector: "testLogicKeywords",
  263. category: 'tests',
  264. fn: function () {
  265. var self=this;
  266. (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);
  267. (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);
  268. (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);
  269. (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);
  270. return self;},
  271. args: [],
  272. source: "testLogicKeywords\x0a \x0a\x09\x22Trivial logic table\x22\x0a\x09self \x0a\x09\x09assert: (true and: [ true]); \x0a\x09\x09deny: (true and: [ false ]); \x0a\x09\x09deny: (false and: [ true ]); \x0a\x09\x09deny: (false and: [ false ]).\x0a\x09self \x0a\x09\x09assert: (true or: [ true ]); \x0a\x09\x09assert: (true or: [ false ]); \x0a\x09\x09assert: (false or: [ true ]); \x0a\x09\x09deny: (false or: [ false ]).\x0a \x0a\x09\x22Checking that expressions work fine too\x22\x0a\x09self \x0a\x09\x09assert: (true and: [ 1 > 0 ]); \x0a\x09\x09deny: ((1 > 0) and: [ false ]); \x0a\x09\x09deny: ((1 > 0) and: [ 1 > 2 ]).\x0a self \x0a\x09\x09assert: (false or: [ 1 > 0 ]); \x0a\x09\x09assert: ((1 > 0) or: [ false ]); \x0a\x09\x09assert: ((1 > 0) or: [ 1 > 2 ])",
  273. messageSends: ["assert:", "and:", "deny:", "or:", ">"],
  274. referencedClasses: []
  275. }),
  276. smalltalk.BooleanTest);
  277. smalltalk.addClass('ClassBuilderTest', smalltalk.TestCase, ['builder', 'theClass'], 'Kernel-Tests');
  278. smalltalk.addMethod(
  279. "_setUp",
  280. smalltalk.method({
  281. selector: "setUp",
  282. category: 'running',
  283. fn: function () {
  284. var self=this;
  285. (self['@builder']=smalltalk.send((smalltalk.ClassBuilder || ClassBuilder), "_new", []));
  286. return self;},
  287. args: [],
  288. source: "setUp\x0a\x09builder := ClassBuilder new",
  289. messageSends: ["new"],
  290. referencedClasses: ["ClassBuilder"]
  291. }),
  292. smalltalk.ClassBuilderTest);
  293. smalltalk.addMethod(
  294. "_tearDown",
  295. smalltalk.method({
  296. selector: "tearDown",
  297. category: 'running',
  298. fn: function () {
  299. var self=this;
  300. (($receiver = self['@theClass']) != nil && $receiver != undefined) ? (function(){smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_removeClass_", [self['@theClass']]);return (self['@theClass']=nil);})() : nil;
  301. return self;},
  302. args: [],
  303. source: "tearDown\x0a\x09theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]",
  304. messageSends: ["ifNotNil:", "removeClass:", "current"],
  305. referencedClasses: ["Smalltalk"]
  306. }),
  307. smalltalk.ClassBuilderTest);
  308. smalltalk.addMethod(
  309. "_testClassCopy",
  310. smalltalk.method({
  311. selector: "testClassCopy",
  312. category: 'running',
  313. fn: function () {
  314. var self=this;
  315. (self['@theClass']=smalltalk.send(self['@builder'], "_copyClass_named_", [(smalltalk.ObjectMock || ObjectMock), "ObjectMock2"]));
  316. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@theClass'], "_superclass", []), "__eq_eq", [smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_superclass", [])])]);
  317. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@theClass'], "_instanceVariableNames", []), "__eq_eq", [smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_instanceVariableNames", [])])]);
  318. smalltalk.send(self, "_assert_equals_", [smalltalk.send(self['@theClass'], "_name", []), "ObjectMock2"]);
  319. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@theClass'], "_package", []), "__eq_eq", [smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_package", [])])]);
  320. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self['@theClass'], "_methodDictionary", []), "_keys", []), smalltalk.send(smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_methodDictionary", []), "_keys", [])]);
  321. return self;},
  322. args: [],
  323. source: "testClassCopy\x0a\x09theClass := builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09self assert: theClass superclass == ObjectMock superclass.\x0a\x09self assert: theClass instanceVariableNames == ObjectMock instanceVariableNames.\x0a\x09self assert: theClass name equals: 'ObjectMock2'.\x0a\x09self assert: theClass package == ObjectMock package.\x0a\x09self assert: theClass methodDictionary keys equals: ObjectMock methodDictionary keys",
  324. messageSends: ["copyClass:named:", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary"],
  325. referencedClasses: ["ObjectMock"]
  326. }),
  327. smalltalk.ClassBuilderTest);
  328. smalltalk.addMethod(
  329. "_testInstanceVariableNames",
  330. smalltalk.method({
  331. selector: "testInstanceVariableNames",
  332. category: 'running',
  333. fn: function () {
  334. var self=this;
  335. smalltalk.send(self, "_assert_equals_", [smalltalk.send(self['@builder'], "_instanceVariableNamesFor_", [" hello world "]), ["hello", "world"]]);
  336. return self;},
  337. args: [],
  338. source: "testInstanceVariableNames\x0a\x09self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')",
  339. messageSends: ["assert:equals:", "instanceVariableNamesFor:"],
  340. referencedClasses: []
  341. }),
  342. smalltalk.ClassBuilderTest);
  343. smalltalk.addClass('DictionaryTest', smalltalk.TestCase, [], 'Kernel-Tests');
  344. smalltalk.addMethod(
  345. "_testAccessing",
  346. smalltalk.method({
  347. selector: "testAccessing",
  348. category: 'tests',
  349. fn: function () {
  350. var self=this;
  351. var d=nil;
  352. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  353. smalltalk.send(d, "_at_put_", ["hello", "world"]);
  354. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", ["hello"]), "__eq", ["world"])]);
  355. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_ifAbsent_", ["hello", (function(){return nil;})]), "__eq", ["world"])]);
  356. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(d, "_at_ifAbsent_", ["foo", (function(){return nil;})]), "__eq", ["world"])]);
  357. smalltalk.send(d, "_at_put_", [(1), (2)]);
  358. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", [(1)]), "__eq", [(2)])]);
  359. smalltalk.send(d, "_at_put_", [smalltalk.send((1), "__at", [(3)]), (3)]);
  360. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", [smalltalk.send((1), "__at", [(3)])]), "__eq", [(3)])]);
  361. return self;},
  362. args: [],
  363. source: "testAccessing\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x0a\x09d at: 'hello' put: 'world'.\x0a\x09self assert: (d at: 'hello') = 'world'.\x0a\x09self assert: (d at: 'hello' ifAbsent: [nil]) = 'world'.\x0a\x09self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.\x0a\x0a\x09d at: 1 put: 2.\x0a\x09self assert: (d at: 1) = 2.\x0a\x0a\x09d at: 1@3 put: 3.\x0a\x09self assert: (d at: 1@3) = 3",
  364. messageSends: ["new", "at:put:", "assert:", "=", "at:", "at:ifAbsent:", "deny:", "@"],
  365. referencedClasses: ["Dictionary"]
  366. }),
  367. smalltalk.DictionaryTest);
  368. smalltalk.addMethod(
  369. "_testDynamicDictionaries",
  370. smalltalk.method({
  371. selector: "testDynamicDictionaries",
  372. category: 'tests',
  373. fn: function () {
  374. var self=this;
  375. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.HashedCollection._fromPairs_([smalltalk.send("hello", "__minus_gt", [(1)])]), "_asDictionary", []), "__eq", [smalltalk.send((smalltalk.Dictionary || Dictionary), "_with_", [smalltalk.send("hello", "__minus_gt", [(1)])])])]);
  376. return self;},
  377. args: [],
  378. source: "testDynamicDictionaries\x0a\x09self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)",
  379. messageSends: ["assert:", "=", "asDictionary", "->", "with:"],
  380. referencedClasses: ["Dictionary"]
  381. }),
  382. smalltalk.DictionaryTest);
  383. smalltalk.addMethod(
  384. "_testEquality",
  385. smalltalk.method({
  386. selector: "testEquality",
  387. category: 'tests',
  388. fn: function () {
  389. var self=this;
  390. var d1=nil;
  391. var d2=nil;
  392. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []), "__eq", [smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])])]);
  393. (d1=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  394. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  395. smalltalk.send(self, "_assert_", [smalltalk.send(d1, "__eq", [d2])]);
  396. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (3)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  397. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  398. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(2), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  399. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  400. (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", [])));
  401. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  402. return self;},
  403. args: [],
  404. source: "testEquality\x0a\x09| d1 d2 |\x0a\x0a\x09self assert: Dictionary new = Dictionary new.\x0a\x09\x09\x0a\x09d1 := Dictionary new at: 1 put: 2; yourself.\x0a\x09d2 := Dictionary new at: 1 put: 2; yourself.\x0a\x09self assert: d1 = d2.\x0a\x0a\x09d2 := Dictionary new at: 1 put: 3; yourself.\x0a\x09self deny: d1 = d2.\x0a\x0a\x09d2 := Dictionary new at: 2 put: 2; yourself.\x0a\x09self deny: d1 = d2.\x0a\x0a\x09d2 := Dictionary new at: 1 put: 2; at: 3 put: 4; yourself.\x0a\x09self deny: d1 = d2.",
  405. messageSends: ["assert:", "=", "new", "at:put:", "yourself", "deny:"],
  406. referencedClasses: ["Dictionary"]
  407. }),
  408. smalltalk.DictionaryTest);
  409. smalltalk.addMethod(
  410. "_testKeys",
  411. smalltalk.method({
  412. selector: "testKeys",
  413. category: 'tests',
  414. fn: function () {
  415. var self=this;
  416. var d=nil;
  417. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  418. smalltalk.send(d, "_at_put_", [(1), (2)]);
  419. smalltalk.send(d, "_at_put_", [(2), (3)]);
  420. smalltalk.send(d, "_at_put_", [(3), (4)]);
  421. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (2), (3)]])]);
  422. return self;},
  423. args: [],
  424. source: "testKeys\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x09d at: 1 put: 2.\x0a\x09d at: 2 put: 3.\x0a\x09d at: 3 put: 4.\x0a\x0a\x09self assert: d keys = #(1 2 3)",
  425. messageSends: ["new", "at:put:", "assert:", "=", "keys"],
  426. referencedClasses: ["Dictionary"]
  427. }),
  428. smalltalk.DictionaryTest);
  429. smalltalk.addMethod(
  430. "_testPrintString",
  431. smalltalk.method({
  432. selector: "testPrintString",
  433. category: 'tests',
  434. fn: function () {
  435. var self=this;
  436. 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", []))]);
  437. return self;},
  438. args: [],
  439. source: "testPrintString\x0a\x09self\x0a\x09\x09assert: 'a Dictionary(''firstname'' -> ''James'' , ''lastname'' -> ''Bond'')' \x0a\x09\x09equals: (Dictionary new \x0a \x09at:'firstname' put: 'James';\x0a \x09at:'lastname' put: 'Bond';\x0a \x09printString)",
  440. messageSends: ["assert:equals:", "at:put:", "printString", "new"],
  441. referencedClasses: ["Dictionary"]
  442. }),
  443. smalltalk.DictionaryTest);
  444. smalltalk.addMethod(
  445. "_testRemoveKey",
  446. smalltalk.method({
  447. selector: "testRemoveKey",
  448. category: 'tests',
  449. fn: function () {
  450. var self=this;
  451. var d=nil;
  452. var key=nil;
  453. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  454. smalltalk.send(d, "_at_put_", [(1), (2)]);
  455. smalltalk.send(d, "_at_put_", [(2), (3)]);
  456. smalltalk.send(d, "_at_put_", [(3), (4)]);
  457. (key=(2));
  458. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (2), (3)]])]);
  459. smalltalk.send(d, "_removeKey_", [key]);
  460. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (3)]])]);
  461. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_values", []), "__eq", [[(2), (4)]])]);
  462. smalltalk.send(self, "_deny_", [smalltalk.send(d, "_includesKey_", [(2)])]);
  463. return self;},
  464. args: [],
  465. source: "testRemoveKey\x0a | d key |\x0a\x0a d := Dictionary new.\x0a d at: 1 put: 2.\x0a d at: 2 put: 3.\x0a d at: 3 put: 4.\x0a\x0a key := 2.\x0a\x0a self assert: d keys = #(1 2 3).\x0a\x0a d removeKey: key.\x0a self assert: d keys = #(1 3).\x0a self assert: d values = #(2 4).\x0a self deny: (d includesKey: 2)",
  466. messageSends: ["new", "at:put:", "assert:", "=", "keys", "removeKey:", "values", "deny:", "includesKey:"],
  467. referencedClasses: ["Dictionary"]
  468. }),
  469. smalltalk.DictionaryTest);
  470. smalltalk.addMethod(
  471. "_testRemoveKeyIfAbsent",
  472. smalltalk.method({
  473. selector: "testRemoveKeyIfAbsent",
  474. category: 'tests',
  475. fn: function () {
  476. var self=this;
  477. var d=nil;
  478. var key=nil;
  479. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  480. smalltalk.send(d, "_at_put_", [(1), (2)]);
  481. smalltalk.send(d, "_at_put_", [(2), (3)]);
  482. smalltalk.send(d, "_at_put_", [(3), (4)]);
  483. (key=(2));
  484. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_", [key]), "__eq", [(3)])]);
  485. (key=(3));
  486. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_ifAbsent_", [key, (function(){return (42);})]), "__eq", [(4)])]);
  487. (key="why");
  488. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_ifAbsent_", [key, (function(){return (42);})]), "__eq", [(42)])]);
  489. return self;},
  490. args: [],
  491. source: "testRemoveKeyIfAbsent\x0a | d key |\x0a\x0a d := Dictionary new.\x0a d at: 1 put: 2.\x0a d at: 2 put: 3.\x0a d at: 3 put: 4.\x0a\x0a key := 2.\x0a self assert: (d removeKey: key) = 3.\x0a\x0a key := 3.\x0a self assert: (d removeKey: key ifAbsent: [42]) = 4.\x0a\x0a key := 'why'.\x0a self assert: (d removeKey: key ifAbsent: [42] ) = 42.",
  492. messageSends: ["new", "at:put:", "assert:", "=", "removeKey:", "removeKey:ifAbsent:"],
  493. referencedClasses: ["Dictionary"]
  494. }),
  495. smalltalk.DictionaryTest);
  496. smalltalk.addMethod(
  497. "_testSize",
  498. smalltalk.method({
  499. selector: "testSize",
  500. category: 'tests',
  501. fn: function () {
  502. var self=this;
  503. var d=nil;
  504. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  505. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(0)])]);
  506. smalltalk.send(d, "_at_put_", [(1), (2)]);
  507. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(1)])]);
  508. smalltalk.send(d, "_at_put_", [(2), (3)]);
  509. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(2)])]);
  510. return self;},
  511. args: [],
  512. source: "testSize\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x09self assert: d size = 0.\x0a\x0a\x09d at: 1 put: 2.\x0a\x09self assert: d size = 1.\x0a\x0a\x09d at: 2 put: 3.\x0a\x09self assert: d size = 2.",
  513. messageSends: ["new", "assert:", "=", "size", "at:put:"],
  514. referencedClasses: ["Dictionary"]
  515. }),
  516. smalltalk.DictionaryTest);
  517. smalltalk.addMethod(
  518. "_testValues",
  519. smalltalk.method({
  520. selector: "testValues",
  521. category: 'tests',
  522. fn: function () {
  523. var self=this;
  524. var d=nil;
  525. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  526. smalltalk.send(d, "_at_put_", [(1), (2)]);
  527. smalltalk.send(d, "_at_put_", [(2), (3)]);
  528. smalltalk.send(d, "_at_put_", [(3), (4)]);
  529. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_values", []), "__eq", [[(2), (3), (4)]])]);
  530. return self;},
  531. args: [],
  532. source: "testValues\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x09d at: 1 put: 2.\x0a\x09d at: 2 put: 3.\x0a\x09d at: 3 put: 4.\x0a\x0a\x09self assert: d values = #(2 3 4)",
  533. messageSends: ["new", "at:put:", "assert:", "=", "values"],
  534. referencedClasses: ["Dictionary"]
  535. }),
  536. smalltalk.DictionaryTest);
  537. smalltalk.addClass('JSObjectProxyTest', smalltalk.TestCase, [], 'Kernel-Tests');
  538. smalltalk.addMethod(
  539. "_jsObject",
  540. smalltalk.method({
  541. selector: "jsObject",
  542. category: 'accessing',
  543. fn: function () {
  544. var self=this;
  545. return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}};
  546. return self;},
  547. args: [],
  548. source: "jsObject\x0a\x09<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}}>",
  549. messageSends: [],
  550. referencedClasses: []
  551. }),
  552. smalltalk.JSObjectProxyTest);
  553. smalltalk.addMethod(
  554. "_testDNU",
  555. smalltalk.method({
  556. selector: "testDNU",
  557. category: 'tests',
  558. fn: function () {
  559. var self=this;
  560. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send(self, "_jsObject", []), "_foo", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  561. return self;},
  562. args: [],
  563. source: "testDNU\x0a\x09self should: [self jsObject foo] raise: MessageNotUnderstood",
  564. messageSends: ["should:raise:", "foo", "jsObject"],
  565. referencedClasses: ["MessageNotUnderstood"]
  566. }),
  567. smalltalk.JSObjectProxyTest);
  568. smalltalk.addMethod(
  569. "_testMessageSend",
  570. smalltalk.method({
  571. selector: "testMessageSend",
  572. category: 'tests',
  573. fn: function () {
  574. var self=this;
  575. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_a", []), (1)]);
  576. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_b", []), (2)]);
  577. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_c_", [(3)]), (3)]);
  578. return self;},
  579. args: [],
  580. source: "testMessageSend\x0a\x0a\x09self assert: self jsObject a equals: 1.\x0a\x09self assert: self jsObject b equals: 2.\x0a\x09self assert: (self jsObject c: 3) equals: 3",
  581. messageSends: ["assert:equals:", "a", "jsObject", "b", "c:"],
  582. referencedClasses: []
  583. }),
  584. smalltalk.JSObjectProxyTest);
  585. smalltalk.addMethod(
  586. "_testMethodWithArguments",
  587. smalltalk.method({
  588. selector: "testMethodWithArguments",
  589. category: 'tests',
  590. fn: function () {
  591. var self=this;
  592. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_hasClass_", ["amber"])]);
  593. smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_addClass_", ["amber"]);
  594. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_hasClass_", ["amber"])]);
  595. smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_removeClass_", ["amber"]);
  596. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_hasClass_", ["amber"])]);
  597. return self;},
  598. args: [],
  599. source: "testMethodWithArguments\x0a\x09self deny: ('body' asJQuery hasClass: 'amber').\x0a\x0a\x09'body' asJQuery addClass: 'amber'.\x0a\x09self assert: ('body' asJQuery hasClass: 'amber').\x0a\x0a\x09'body' asJQuery removeClass: 'amber'.\x0a\x09self deny: ('body' asJQuery hasClass: 'amber').",
  600. messageSends: ["deny:", "hasClass:", "asJQuery", "addClass:", "assert:", "removeClass:"],
  601. referencedClasses: []
  602. }),
  603. smalltalk.JSObjectProxyTest);
  604. smalltalk.addMethod(
  605. "_testPrinting",
  606. smalltalk.method({
  607. selector: "testPrinting",
  608. category: 'tests',
  609. fn: function () {
  610. var self=this;
  611. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_jsObject", []), "_printString", []), "__eq", [unescape("%5Bobject%20Object%5D")])]);
  612. return self;},
  613. args: [],
  614. source: "testPrinting\x0a\x09self assert: self jsObject printString = '[object Object]'",
  615. messageSends: ["assert:", "=", "printString", "jsObject"],
  616. referencedClasses: []
  617. }),
  618. smalltalk.JSObjectProxyTest);
  619. smalltalk.addMethod(
  620. "_testPropertyThatReturnsEmptyString",
  621. smalltalk.method({
  622. selector: "testPropertyThatReturnsEmptyString",
  623. category: 'tests',
  624. fn: function () {
  625. var self=this;
  626. document.location.hash = '';
  627. smalltalk.send(self, "_assert_equals_", ["", smalltalk.send(smalltalk.send((typeof document == 'undefined' ? nil : document), "_location", []), "_hash", [])]);
  628. smalltalk.send(smalltalk.send((typeof document == 'undefined' ? nil : document), "_location", []), "_hash_", ["test"]);
  629. smalltalk.send(self, "_assert_equals_", [unescape("%23test"), smalltalk.send(smalltalk.send((typeof document == 'undefined' ? nil : document), "_location", []), "_hash", [])]);
  630. return self;},
  631. args: [],
  632. source: "testPropertyThatReturnsEmptyString\x0a\x09<document.location.hash = ''>.\x0a\x09self assert: '' equals: document location hash.\x0a\x0a\x09document location hash: 'test'.\x0a\x09self assert: '#test' equals: document location hash.",
  633. messageSends: ["assert:equals:", "hash", "location", "hash:"],
  634. referencedClasses: []
  635. }),
  636. smalltalk.JSObjectProxyTest);
  637. smalltalk.addMethod(
  638. "_testYourself",
  639. smalltalk.method({
  640. selector: "testYourself",
  641. category: 'tests',
  642. fn: function () {
  643. var self=this;
  644. var body=nil;
  645. (body=(function($rec){smalltalk.send($rec, "_addClass_", ["amber"]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send("body", "_asJQuery", [])));
  646. smalltalk.send(self, "_assert_", [smalltalk.send(body, "_hasClass_", ["amber"])]);
  647. smalltalk.send(body, "_removeClass_", ["amber"]);
  648. smalltalk.send(self, "_deny_", [smalltalk.send(body, "_hasClass_", ["amber"])]);
  649. return self;},
  650. args: [],
  651. source: "testYourself\x0a\x09|body|\x0a\x09body := 'body' asJQuery\x0a\x09\x09\x09\x09addClass: 'amber';\x0a\x09\x09\x09\x09yourself.\x0a\x0a\x09self assert: (body hasClass: 'amber').\x0a\x0a\x09body removeClass: 'amber'.\x0a\x09self deny: (body hasClass: 'amber').",
  652. messageSends: ["addClass:", "yourself", "asJQuery", "assert:", "hasClass:", "removeClass:", "deny:"],
  653. referencedClasses: []
  654. }),
  655. smalltalk.JSObjectProxyTest);
  656. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  657. smalltalk.addMethod(
  658. "_testArithmetic",
  659. smalltalk.method({
  660. selector: "testArithmetic",
  661. category: 'tests',
  662. fn: function () {
  663. var self=this;
  664. smalltalk.send(self, "_assert_", [smalltalk.send((1.5) + (1), "__eq", [(2.5)])]);
  665. smalltalk.send(self, "_assert_", [smalltalk.send((2) - (1), "__eq", [(1)])]);
  666. smalltalk.send(self, "_assert_", [smalltalk.send((-2) - (1), "__eq", [(-3)])]);
  667. smalltalk.send(self, "_assert_", [smalltalk.send((12) / (2), "__eq", [(6)])]);
  668. smalltalk.send(self, "_assert_", [smalltalk.send((3) * (4), "__eq", [(12)])]);
  669. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = (1) + (2)).klass === smalltalk.Number) ? $receiver *(3) : smalltalk.send($receiver, "__star", [(3)])), "__eq", [(9)])]);
  670. smalltalk.send(self, "_assert_", [smalltalk.send((1) + (2) * (3), "__eq", [(7)])]);
  671. return self;},
  672. args: [],
  673. source: "testArithmetic\x0a\x09\x0a\x09\x22We rely on JS here, so we won't test complex behavior, just check if \x0a\x09message sends are corrects\x22\x0a\x0a\x09self assert: 1.5 + 1 = 2.5.\x0a\x09self assert: 2 - 1 = 1.\x0a\x09self assert: -2 - 1 = -3.\x0a\x09self assert: 12 / 2 = 6.\x0a\x09self assert: 3 * 4 = 12.\x0a\x0a\x09\x22Simple parenthesis and execution order\x22\x0a\x0a\x09self assert: 1 + 2 * 3 = 9.\x0a\x09self assert: 1 + (2 * 3) = 7",
  674. messageSends: ["assert:", "=", "+", "-", "/", "*"],
  675. referencedClasses: []
  676. }),
  677. smalltalk.NumberTest);
  678. smalltalk.addMethod(
  679. "_testComparison",
  680. smalltalk.method({
  681. selector: "testComparison",
  682. category: 'tests',
  683. fn: function () {
  684. var self=this;
  685. smalltalk.send(self, "_assert_", [(3) > (2)]);
  686. smalltalk.send(self, "_assert_", [(2) < (3)]);
  687. smalltalk.send(self, "_deny_", [(3) < (2)]);
  688. smalltalk.send(self, "_deny_", [(2) > (3)]);
  689. smalltalk.send(self, "_assert_", [(3) >= (3)]);
  690. smalltalk.send(self, "_assert_", [(3.1) >= (3)]);
  691. smalltalk.send(self, "_assert_", [(3) <= (3)]);
  692. smalltalk.send(self, "_assert_", [(3) <= (3.1)]);
  693. return self;},
  694. args: [],
  695. source: "testComparison\x0a\x0a\x09self assert: 3 > 2.\x0a\x09self assert: 2 < 3.\x0a\x09\x0a\x09self deny: 3 < 2.\x0a\x09self deny: 2 > 3.\x0a\x0a\x09self assert: 3 >= 3.\x0a\x09self assert: 3.1 >= 3.\x0a\x09self assert: 3 <= 3.\x0a\x09self assert: 3 <= 3.1",
  696. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  697. referencedClasses: []
  698. }),
  699. smalltalk.NumberTest);
  700. smalltalk.addMethod(
  701. "_testCopying",
  702. smalltalk.method({
  703. selector: "testCopying",
  704. category: 'tests',
  705. fn: function () {
  706. var self=this;
  707. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_copy", []), "__eq_eq", [(1)])]);
  708. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_deepCopy", []), "__eq_eq", [(1)])]);
  709. return self;},
  710. args: [],
  711. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  712. messageSends: ["assert:", "==", "copy", "deepCopy"],
  713. referencedClasses: []
  714. }),
  715. smalltalk.NumberTest);
  716. smalltalk.addMethod(
  717. "_testEquality",
  718. smalltalk.method({
  719. selector: "testEquality",
  720. category: 'tests',
  721. fn: function () {
  722. var self=this;
  723. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [(1)])]);
  724. smalltalk.send(self, "_assert_", [smalltalk.send((0), "__eq", [(0)])]);
  725. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq", [(0)])]);
  726. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [(1)])]);
  727. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  728. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  729. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [false])]);
  730. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [(0)])]);
  731. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  732. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [""])]);
  733. return self;},
  734. args: [],
  735. source: "testEquality\x0a\x09self assert: 1 = 1.\x0a\x09self assert: 0 = 0.\x0a\x09self deny: 1 = 0.\x0a\x0a\x09self assert: 1 yourself = 1.\x0a\x09self assert: 1 = 1 yourself.\x0a\x09self assert: 1 yourself = 1 yourself.\x0a\x09\x0a\x09self deny: 0 = false.\x0a\x09self deny: false = 0.\x0a\x09self deny: '' = 0.\x0a\x09self deny: 0 = ''",
  736. messageSends: ["assert:", "=", "deny:", "yourself"],
  737. referencedClasses: []
  738. }),
  739. smalltalk.NumberTest);
  740. smalltalk.addMethod(
  741. "_testIdentity",
  742. smalltalk.method({
  743. selector: "testIdentity",
  744. category: 'tests',
  745. fn: function () {
  746. var self=this;
  747. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq_eq", [(1)])]);
  748. smalltalk.send(self, "_assert_", [smalltalk.send((0), "__eq_eq", [(0)])]);
  749. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq_eq", [(0)])]);
  750. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq_eq", [(1)])]);
  751. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq_eq", [smalltalk.send((1), "_yourself", [])])]);
  752. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq_eq", [smalltalk.send((1), "_yourself", [])])]);
  753. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq_eq", [(2)])]);
  754. return self;},
  755. args: [],
  756. source: "testIdentity\x0a\x09self assert: 1 == 1.\x0a\x09self assert: 0 == 0.\x0a\x09self deny: 1 == 0.\x0a\x0a\x09self assert: 1 yourself == 1.\x0a\x09self assert: 1 == 1 yourself.\x0a\x09self assert: 1 yourself == 1 yourself.\x0a\x09\x0a\x09self deny: 1 == 2",
  757. messageSends: ["assert:", "==", "deny:", "yourself"],
  758. referencedClasses: []
  759. }),
  760. smalltalk.NumberTest);
  761. smalltalk.addMethod(
  762. "_testMinMax",
  763. smalltalk.method({
  764. selector: "testMinMax",
  765. category: 'tests',
  766. fn: function () {
  767. var self=this;
  768. smalltalk.send(self, "_assert_equals_", [smalltalk.send((2), "_max_", [(5)]), (5)]);
  769. smalltalk.send(self, "_assert_equals_", [smalltalk.send((2), "_min_", [(5)]), (2)]);
  770. return self;},
  771. args: [],
  772. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  773. messageSends: ["assert:equals:", "max:", "min:"],
  774. referencedClasses: []
  775. }),
  776. smalltalk.NumberTest);
  777. smalltalk.addMethod(
  778. "_testNegated",
  779. smalltalk.method({
  780. selector: "testNegated",
  781. category: 'tests',
  782. fn: function () {
  783. var self=this;
  784. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_negated", []), "__eq", [(-3)])]);
  785. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((-3), "_negated", []), "__eq", [(3)])]);
  786. return self;},
  787. args: [],
  788. source: "testNegated\x0a\x09self assert: 3 negated = -3.\x0a\x09self assert: -3 negated = 3",
  789. messageSends: ["assert:", "=", "negated"],
  790. referencedClasses: []
  791. }),
  792. smalltalk.NumberTest);
  793. smalltalk.addMethod(
  794. "_testPrintShowingDecimalPlaces",
  795. smalltalk.method({
  796. selector: "testPrintShowingDecimalPlaces",
  797. category: 'tests',
  798. fn: function () {
  799. var self=this;
  800. smalltalk.send(self, "_assert_equals_", ["23.00", smalltalk.send((23), "_printShowingDecimalPlaces_", [(2)])]);
  801. smalltalk.send(self, "_assert_equals_", ["23.57", smalltalk.send((23.5698), "_printShowingDecimalPlaces_", [(2)])]);
  802. smalltalk.send(self, "_assert_equals_", [unescape("-234.56700"), smalltalk.send(smalltalk.send((234.567), "_negated", []), "_printShowingDecimalPlaces_", [(5)])]);
  803. smalltalk.send(self, "_assert_equals_", ["23", smalltalk.send((23.4567), "_printShowingDecimalPlaces_", [(0)])]);
  804. smalltalk.send(self, "_assert_equals_", ["24", smalltalk.send((23.5567), "_printShowingDecimalPlaces_", [(0)])]);
  805. smalltalk.send(self, "_assert_equals_", [unescape("-23"), smalltalk.send(smalltalk.send((23.4567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  806. smalltalk.send(self, "_assert_equals_", [unescape("-24"), smalltalk.send(smalltalk.send((23.5567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  807. smalltalk.send(self, "_assert_equals_", ["100000000.0", smalltalk.send((100000000), "_printShowingDecimalPlaces_", [(1)])]);
  808. smalltalk.send(self, "_assert_equals_", ["0.98000", smalltalk.send((0.98), "_printShowingDecimalPlaces_", [(5)])]);
  809. smalltalk.send(self, "_assert_equals_", [unescape("-0.98"), smalltalk.send(smalltalk.send((0.98), "_negated", []), "_printShowingDecimalPlaces_", [(2)])]);
  810. smalltalk.send(self, "_assert_equals_", ["2.57", smalltalk.send((2.567), "_printShowingDecimalPlaces_", [(2)])]);
  811. smalltalk.send(self, "_assert_equals_", [unescape("-2.57"), smalltalk.send((-2.567), "_printShowingDecimalPlaces_", [(2)])]);
  812. smalltalk.send(self, "_assert_equals_", ["0.00", smalltalk.send((0), "_printShowingDecimalPlaces_", [(2)])]);
  813. return self;},
  814. args: [],
  815. source: "testPrintShowingDecimalPlaces\x0a\x09self assert: '23.00' equals: (23 printShowingDecimalPlaces: 2).\x0a\x09self assert: '23.57' equals: (23.5698 printShowingDecimalPlaces: 2).\x0a\x09self assert: '-234.56700' equals:( 234.567 negated printShowingDecimalPlaces: 5).\x0a\x09self assert: '23' equals: (23.4567 printShowingDecimalPlaces: 0).\x0a\x09self assert: '24' equals: (23.5567 printShowingDecimalPlaces: 0).\x0a\x09self assert: '-23' equals: (23.4567 negated printShowingDecimalPlaces: 0).\x0a\x09self assert: '-24' equals: (23.5567 negated printShowingDecimalPlaces: 0).\x0a\x09self assert: '100000000.0' equals: (100000000 printShowingDecimalPlaces: 1).\x0a\x09self assert: '0.98000' equals: (0.98 printShowingDecimalPlaces: 5).\x0a\x09self assert: '-0.98' equals: (0.98 negated printShowingDecimalPlaces: 2).\x0a\x09self assert: '2.57' equals: (2.567 printShowingDecimalPlaces: 2).\x0a\x09self assert: '-2.57' equals: (-2.567 printShowingDecimalPlaces: 2).\x0a\x09self assert: '0.00' equals: (0 printShowingDecimalPlaces: 2).",
  816. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  817. referencedClasses: []
  818. }),
  819. smalltalk.NumberTest);
  820. smalltalk.addMethod(
  821. "_testRounded",
  822. smalltalk.method({
  823. selector: "testRounded",
  824. category: 'tests',
  825. fn: function () {
  826. var self=this;
  827. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_rounded", []), "__eq", [(3)])]);
  828. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_rounded", []), "__eq", [(3)])]);
  829. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_rounded", []), "__eq", [(4)])]);
  830. return self;},
  831. args: [],
  832. source: "testRounded\x0a\x09\x0a\x09self assert: 3 rounded = 3.\x0a\x09self assert: 3.212 rounded = 3.\x0a\x09self assert: 3.51 rounded = 4",
  833. messageSends: ["assert:", "=", "rounded"],
  834. referencedClasses: []
  835. }),
  836. smalltalk.NumberTest);
  837. smalltalk.addMethod(
  838. "_testSqrt",
  839. smalltalk.method({
  840. selector: "testSqrt",
  841. category: 'tests',
  842. fn: function () {
  843. var self=this;
  844. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((4), "_sqrt", []), "__eq", [(2)])]);
  845. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((16), "_sqrt", []), "__eq", [(4)])]);
  846. return self;},
  847. args: [],
  848. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt = 2.\x0a\x09self assert: 16 sqrt = 4",
  849. messageSends: ["assert:", "=", "sqrt"],
  850. referencedClasses: []
  851. }),
  852. smalltalk.NumberTest);
  853. smalltalk.addMethod(
  854. "_testSquared",
  855. smalltalk.method({
  856. selector: "testSquared",
  857. category: 'tests',
  858. fn: function () {
  859. var self=this;
  860. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((4), "_squared", []), "__eq", [(16)])]);
  861. return self;},
  862. args: [],
  863. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared = 16",
  864. messageSends: ["assert:", "=", "squared"],
  865. referencedClasses: []
  866. }),
  867. smalltalk.NumberTest);
  868. smalltalk.addMethod(
  869. "_testTimesRepeat",
  870. smalltalk.method({
  871. selector: "testTimesRepeat",
  872. category: 'tests',
  873. fn: function () {
  874. var self=this;
  875. var i=nil;
  876. (i=(0));
  877. smalltalk.send((0), "_timesRepeat_", [(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})]);
  878. smalltalk.send(self, "_assert_equals_", [i, (0)]);
  879. smalltalk.send((5), "_timesRepeat_", [(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})]);
  880. smalltalk.send(self, "_assert_equals_", [i, (5)]);
  881. return self;},
  882. args: [],
  883. source: "testTimesRepeat\x0a\x09| i |\x0a\x0a\x09i := 0.\x0a\x090 timesRepeat: [i := i + 1].\x0a\x09self assert: i equals: 0.\x0a\x0a\x095 timesRepeat: [i := i + 1].\x0a\x09self assert: i equals: 5",
  884. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  885. referencedClasses: []
  886. }),
  887. smalltalk.NumberTest);
  888. smalltalk.addMethod(
  889. "_testTo",
  890. smalltalk.method({
  891. selector: "testTo",
  892. category: 'tests',
  893. fn: function () {
  894. var self=this;
  895. smalltalk.send(self, "_assert_equals_", [smalltalk.send((1), "_to_", [(5)]), [(1), (2), (3), (4), (5)]]);
  896. return self;},
  897. args: [],
  898. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  899. messageSends: ["assert:equals:", "to:"],
  900. referencedClasses: []
  901. }),
  902. smalltalk.NumberTest);
  903. smalltalk.addMethod(
  904. "_testToBy",
  905. smalltalk.method({
  906. selector: "testToBy",
  907. category: 'tests',
  908. fn: function () {
  909. var self=this;
  910. smalltalk.send(self, "_assert_equals_", [smalltalk.send((0), "_to_by_", [(6), (2)]), [(0), (2), (4), (6)]]);
  911. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((1), "_to_by_", [(4), (0)]);}), (smalltalk.Error || Error)]);
  912. return self;},
  913. args: [],
  914. source: "testToBy\x0a\x09self assert: (0 to: 6 by: 2) equals: #(0 2 4 6).\x0a\x0a\x09self should: [1 to: 4 by: 0] raise: Error",
  915. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  916. referencedClasses: ["Error"]
  917. }),
  918. smalltalk.NumberTest);
  919. smalltalk.addMethod(
  920. "_testTruncated",
  921. smalltalk.method({
  922. selector: "testTruncated",
  923. category: 'tests',
  924. fn: function () {
  925. var self=this;
  926. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_truncated", []), "__eq", [(3)])]);
  927. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_truncated", []), "__eq", [(3)])]);
  928. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_truncated", []), "__eq", [(3)])]);
  929. return self;},
  930. args: [],
  931. source: "testTruncated\x0a\x09\x0a\x09self assert: 3 truncated = 3.\x0a\x09self assert: 3.212 truncated = 3.\x0a\x09self assert: 3.51 truncated = 3",
  932. messageSends: ["assert:", "=", "truncated"],
  933. referencedClasses: []
  934. }),
  935. smalltalk.NumberTest);
  936. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  937. smalltalk.addMethod(
  938. "_foo",
  939. smalltalk.method({
  940. selector: "foo",
  941. category: 'not yet classified',
  942. fn: function () {
  943. var self=this;
  944. return self['@foo'];
  945. return self;},
  946. args: [],
  947. source: "foo\x0a\x09^foo",
  948. messageSends: [],
  949. referencedClasses: []
  950. }),
  951. smalltalk.ObjectMock);
  952. smalltalk.addMethod(
  953. "_foo_",
  954. smalltalk.method({
  955. selector: "foo:",
  956. category: 'not yet classified',
  957. fn: function (anObject) {
  958. var self=this;
  959. (self['@foo']=anObject);
  960. return self;},
  961. args: ["anObject"],
  962. source: "foo: anObject\x0a\x09foo := anObject",
  963. messageSends: [],
  964. referencedClasses: []
  965. }),
  966. smalltalk.ObjectMock);
  967. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  968. smalltalk.addMethod(
  969. "_testBasicAccess",
  970. smalltalk.method({
  971. selector: "testBasicAccess",
  972. category: 'tests',
  973. fn: function () {
  974. var self=this;
  975. var o=nil;
  976. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  977. smalltalk.send(o, "_basicAt_put_", ["a", (1)]);
  978. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["a"]), (1)]);
  979. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["b"]), nil]);
  980. return self;},
  981. args: [],
  982. source: "testBasicAccess\x0a\x09| o |\x0a\x09o := Object new.\x0a\x09o basicAt: 'a' put: 1.\x0a\x09self assert: (o basicAt: 'a') equals: 1.\x0a\x09self assert: (o basicAt: 'b') equals: nil",
  983. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  984. referencedClasses: ["Object"]
  985. }),
  986. smalltalk.ObjectTest);
  987. smalltalk.addMethod(
  988. "_testBasicPerform",
  989. smalltalk.method({
  990. selector: "testBasicPerform",
  991. category: 'tests',
  992. fn: function () {
  993. var self=this;
  994. var o=nil;
  995. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  996. smalltalk.send(o, "_basicAt_put_", ["func", (function(){return "hello";})]);
  997. smalltalk.send(o, "_basicAt_put_", ["func2", (function(a){return ((($receiver = a).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]));})]);
  998. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_", ["func"]), "hello"]);
  999. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_withArguments_", ["func2", [(3)]]), (4)]);
  1000. return self;},
  1001. args: [],
  1002. source: "testBasicPerform\x0a\x09| o |\x0a\x09o := Object new.\x0a\x09o basicAt: 'func' put: ['hello'].\x09\x0a\x09o basicAt: 'func2' put: [:a | a + 1].\x0a\x0a\x09self assert: (o basicPerform: 'func')\x09 equals: 'hello'.\x0a\x09self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4",
  1003. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  1004. referencedClasses: ["Object"]
  1005. }),
  1006. smalltalk.ObjectTest);
  1007. smalltalk.addMethod(
  1008. "_testDNU",
  1009. smalltalk.method({
  1010. selector: "testDNU",
  1011. category: 'tests',
  1012. fn: function () {
  1013. var self=this;
  1014. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_foo", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1015. return self;},
  1016. args: [],
  1017. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  1018. messageSends: ["should:raise:", "foo", "new"],
  1019. referencedClasses: ["Object", "MessageNotUnderstood"]
  1020. }),
  1021. smalltalk.ObjectTest);
  1022. smalltalk.addMethod(
  1023. "_testEquality",
  1024. smalltalk.method({
  1025. selector: "testEquality",
  1026. category: 'tests',
  1027. fn: function () {
  1028. var self=this;
  1029. var o=nil;
  1030. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1031. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq", [smalltalk.send((smalltalk.Object || Object), "_new", [])])]);
  1032. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [o])]);
  1033. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq", [o])]);
  1034. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [smalltalk.send(o, "_yourself", [])])]);
  1035. return self;},
  1036. args: [],
  1037. source: "testEquality\x0a\x09| o |\x0a\x09o := Object new.\x0a\x09self deny: o = Object new.\x0a\x09self assert: o = o.\x0a\x09self assert: o yourself = o.\x0a\x09self assert: o = o yourself",
  1038. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  1039. referencedClasses: ["Object"]
  1040. }),
  1041. smalltalk.ObjectTest);
  1042. smalltalk.addMethod(
  1043. "_testHalt",
  1044. smalltalk.method({
  1045. selector: "testHalt",
  1046. category: 'tests',
  1047. fn: function () {
  1048. var self=this;
  1049. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_halt", []);}), (smalltalk.Error || Error)]);
  1050. return self;},
  1051. args: [],
  1052. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  1053. messageSends: ["should:raise:", "halt", "new"],
  1054. referencedClasses: ["Object", "Error"]
  1055. }),
  1056. smalltalk.ObjectTest);
  1057. smalltalk.addMethod(
  1058. "_testIdentity",
  1059. smalltalk.method({
  1060. selector: "testIdentity",
  1061. category: 'tests',
  1062. fn: function () {
  1063. var self=this;
  1064. var o=nil;
  1065. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1066. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq_eq", [smalltalk.send((smalltalk.Object || Object), "_new", [])])]);
  1067. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq_eq", [o])]);
  1068. return self;},
  1069. args: [],
  1070. source: "testIdentity\x0a\x09| o |\x0a\x09o := Object new.\x0a\x09self deny: o == Object new.\x0a\x09self assert: o == o",
  1071. messageSends: ["new", "deny:", "==", "assert:"],
  1072. referencedClasses: ["Object"]
  1073. }),
  1074. smalltalk.ObjectTest);
  1075. smalltalk.addMethod(
  1076. "_testIfNil",
  1077. smalltalk.method({
  1078. selector: "testIfNil",
  1079. category: 'tests',
  1080. fn: function () {
  1081. var self=this;
  1082. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_isNil", [])]);
  1083. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return true;})() : $receiver, "__eq", [true])]);
  1084. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) != nil && $receiver != undefined) ? (function(){return true;})() : nil, "__eq", [true])]);
  1085. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  1086. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  1087. return self;},
  1088. args: [],
  1089. source: "testIfNil\x0a\x09self deny: Object new isNil.\x0a\x09self deny: (Object new ifNil: [true]) = true.\x0a\x09self assert: (Object new ifNotNil: [true]) = true.\x0a\x0a\x09self assert: (Object new ifNil: [false] ifNotNil: [true]) = true.\x0a\x09self assert: (Object new ifNotNil: [true] ifNil: [false]) = true",
  1090. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  1091. referencedClasses: ["Object"]
  1092. }),
  1093. smalltalk.ObjectTest);
  1094. smalltalk.addMethod(
  1095. "_testInstVars",
  1096. smalltalk.method({
  1097. selector: "testInstVars",
  1098. category: 'tests',
  1099. fn: function () {
  1100. var self=this;
  1101. var o=nil;
  1102. (o=smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_new", []));
  1103. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), nil]);
  1104. smalltalk.send(o, "_instVarAt_put_", [smalltalk.symbolFor("foo"), (1)]);
  1105. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), (1)]);
  1106. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", ["foo"]), (1)]);
  1107. return self;},
  1108. args: [],
  1109. source: "testInstVars\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: (o instVarAt: #foo) equals: nil.\x0a\x0a\x09o instVarAt: #foo put: 1.\x0a\x09self assert: (o instVarAt: #foo) equals: 1.\x0a\x09self assert: (o instVarAt: 'foo') equals: 1",
  1110. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  1111. referencedClasses: ["ObjectMock"]
  1112. }),
  1113. smalltalk.ObjectTest);
  1114. smalltalk.addMethod(
  1115. "_testNilUndefined",
  1116. smalltalk.method({
  1117. selector: "testNilUndefined",
  1118. category: 'tests',
  1119. fn: function () {
  1120. var self=this;
  1121. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "__eq", [(typeof undefined == 'undefined' ? nil : undefined)])]);
  1122. return self;},
  1123. args: [],
  1124. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09self assert: nil = undefined",
  1125. messageSends: ["assert:", "="],
  1126. referencedClasses: []
  1127. }),
  1128. smalltalk.ObjectTest);
  1129. smalltalk.addMethod(
  1130. "_testYourself",
  1131. smalltalk.method({
  1132. selector: "testYourself",
  1133. category: 'tests',
  1134. fn: function () {
  1135. var self=this;
  1136. var o=nil;
  1137. (o=smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_new", []));
  1138. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq_eq", [o])]);
  1139. return self;},
  1140. args: [],
  1141. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  1142. messageSends: ["new", "assert:", "==", "yourself"],
  1143. referencedClasses: ["ObjectMock"]
  1144. }),
  1145. smalltalk.ObjectTest);
  1146. smalltalk.addMethod(
  1147. "_testidentityHash",
  1148. smalltalk.method({
  1149. selector: "testidentityHash",
  1150. category: 'tests',
  1151. fn: function () {
  1152. var self=this;
  1153. var o1=nil;
  1154. var o2=nil;
  1155. (o1=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1156. (o2=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1157. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o1, "_identityHash", [])])]);
  1158. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o2, "_identityHash", [])])]);
  1159. return self;},
  1160. args: [],
  1161. source: "testidentityHash\x0a\x09| o1 o2 |\x0a\x09\x0a\x09o1 := Object new.\x0a\x09o2 := Object new.\x0a\x0a\x09self assert: o1 identityHash == o1 identityHash.\x0a\x09self deny: o1 identityHash == o2 identityHash",
  1162. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  1163. referencedClasses: ["Object"]
  1164. }),
  1165. smalltalk.ObjectTest);
  1166. smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
  1167. smalltalk.addMethod(
  1168. "_setUp",
  1169. smalltalk.method({
  1170. selector: "setUp",
  1171. category: 'running',
  1172. fn: function () {
  1173. var self=this;
  1174. (self['@backUpCommitPathJs']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathJs", []));
  1175. (self['@backUpCommitPathSt']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathSt", []));
  1176. smalltalk.send((smalltalk.Package || Package), "_resetCommitPaths", []);
  1177. (self['@zorkPackage']=smalltalk.send(smalltalk.send((smalltalk.Package || Package), "_new", []), "_name_", ["Zork"]));
  1178. (self['@grulPackage']=(function($rec){smalltalk.send($rec, "_name_", ["Grul"]);smalltalk.send($rec, "_commitPathJs_", [unescape("server/grul/js")]);smalltalk.send($rec, "_commitPathSt_", [unescape("grul/st")]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Package || Package), "_new", [])));
  1179. return self;},
  1180. args: [],
  1181. source: "setUp\x0a\x09backUpCommitPathJs := Package defaultCommitPathJs.\x0a\x09backUpCommitPathSt := Package defaultCommitPathSt.\x0a\x0a\x09Package resetCommitPaths.\x0a\x0a\x09zorkPackage := Package new name: 'Zork'.\x0a\x09grulPackage := Package new \x0a\x09\x09\x09\x09\x09name: 'Grul';\x0a\x09\x09\x09\x09\x09commitPathJs: 'server/grul/js';\x0a\x09\x09\x09\x09\x09commitPathSt: 'grul/st';\x0a\x09\x09\x09\x09\x09yourself",
  1182. messageSends: ["defaultCommitPathJs", "defaultCommitPathSt", "resetCommitPaths", "name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
  1183. referencedClasses: ["Package"]
  1184. }),
  1185. smalltalk.PackageTest);
  1186. smalltalk.addMethod(
  1187. "_tearDown",
  1188. smalltalk.method({
  1189. selector: "tearDown",
  1190. category: 'running',
  1191. fn: function () {
  1192. var self=this;
  1193. (function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);return smalltalk.send($rec, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);})((smalltalk.Package || Package));
  1194. return self;},
  1195. args: [],
  1196. source: "tearDown\x0a\x09 Package \x0a\x09\x09defaultCommitPathJs: backUpCommitPathJs;\x0a\x09\x09defaultCommitPathSt: backUpCommitPathSt",
  1197. messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
  1198. referencedClasses: ["Package"]
  1199. }),
  1200. smalltalk.PackageTest);
  1201. smalltalk.addMethod(
  1202. "_testGrulCommitPathJsShouldBeServerGrulJs",
  1203. smalltalk.method({
  1204. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  1205. category: 'tests',
  1206. fn: function () {
  1207. var self=this;
  1208. smalltalk.send(self, "_assert_equals_", [unescape("server/grul/js"), smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  1209. return self;},
  1210. args: [],
  1211. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  1212. messageSends: ["assert:equals:", "commitPathJs"],
  1213. referencedClasses: []
  1214. }),
  1215. smalltalk.PackageTest);
  1216. smalltalk.addMethod(
  1217. "_testGrulCommitPathStShouldBeGrulSt",
  1218. smalltalk.method({
  1219. selector: "testGrulCommitPathStShouldBeGrulSt",
  1220. category: 'tests',
  1221. fn: function () {
  1222. var self=this;
  1223. smalltalk.send(self, "_assert_equals_", [unescape("grul/st"), smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  1224. return self;},
  1225. args: [],
  1226. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  1227. messageSends: ["assert:equals:", "commitPathSt"],
  1228. referencedClasses: []
  1229. }),
  1230. smalltalk.PackageTest);
  1231. smalltalk.addMethod(
  1232. "_testZorkCommitPathJsShouldBeJs",
  1233. smalltalk.method({
  1234. selector: "testZorkCommitPathJsShouldBeJs",
  1235. category: 'tests',
  1236. fn: function () {
  1237. var self=this;
  1238. smalltalk.send(self, "_assert_equals_", ["js", smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  1239. return self;},
  1240. args: [],
  1241. source: "testZorkCommitPathJsShouldBeJs\x0a\x09self assert: 'js' equals: zorkPackage commitPathJs",
  1242. messageSends: ["assert:equals:", "commitPathJs"],
  1243. referencedClasses: []
  1244. }),
  1245. smalltalk.PackageTest);
  1246. smalltalk.addMethod(
  1247. "_testZorkCommitPathStShouldBeSt",
  1248. smalltalk.method({
  1249. selector: "testZorkCommitPathStShouldBeSt",
  1250. category: 'tests',
  1251. fn: function () {
  1252. var self=this;
  1253. smalltalk.send(self, "_assert_equals_", ["st", smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  1254. return self;},
  1255. args: [],
  1256. source: "testZorkCommitPathStShouldBeSt\x0a\x09self assert: 'st' equals: zorkPackage commitPathSt",
  1257. messageSends: ["assert:equals:", "commitPathSt"],
  1258. referencedClasses: []
  1259. }),
  1260. smalltalk.PackageTest);
  1261. smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
  1262. smalltalk.addMethod(
  1263. "_setUp",
  1264. smalltalk.method({
  1265. selector: "setUp",
  1266. category: 'running',
  1267. fn: function () {
  1268. var self=this;
  1269. smalltalk.send(self, "_setUp", [], smalltalk.PackageTest);
  1270. (function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [unescape("javascripts/")]);return smalltalk.send($rec, "_defaultCommitPathSt_", [unescape("smalltalk/")]);})((smalltalk.Package || Package));
  1271. return self;},
  1272. args: [],
  1273. source: "setUp\x0a\x09super setUp.\x0a\x0a\x09Package\x0a\x09\x09defaultCommitPathJs: 'javascripts/';\x0a\x09\x09defaultCommitPathSt: 'smalltalk/'.",
  1274. messageSends: ["setUp", "defaultCommitPathJs:", "defaultCommitPathSt:"],
  1275. referencedClasses: ["Package"]
  1276. }),
  1277. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1278. smalltalk.addMethod(
  1279. "_testGrulCommitPathJsShouldBeServerGrulJs",
  1280. smalltalk.method({
  1281. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  1282. category: 'tests',
  1283. fn: function () {
  1284. var self=this;
  1285. smalltalk.send(self, "_assert_equals_", [unescape("server/grul/js"), smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  1286. return self;},
  1287. args: [],
  1288. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  1289. messageSends: ["assert:equals:", "commitPathJs"],
  1290. referencedClasses: []
  1291. }),
  1292. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1293. smalltalk.addMethod(
  1294. "_testGrulCommitPathStShouldBeGrulSt",
  1295. smalltalk.method({
  1296. selector: "testGrulCommitPathStShouldBeGrulSt",
  1297. category: 'tests',
  1298. fn: function () {
  1299. var self=this;
  1300. smalltalk.send(self, "_assert_equals_", [unescape("grul/st"), smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  1301. return self;},
  1302. args: [],
  1303. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  1304. messageSends: ["assert:equals:", "commitPathSt"],
  1305. referencedClasses: []
  1306. }),
  1307. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1308. smalltalk.addMethod(
  1309. "_testZorkCommitPathJsShouldBeJavascript",
  1310. smalltalk.method({
  1311. selector: "testZorkCommitPathJsShouldBeJavascript",
  1312. category: 'tests',
  1313. fn: function () {
  1314. var self=this;
  1315. smalltalk.send(self, "_assert_equals_", [unescape("javascripts/"), smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  1316. return self;},
  1317. args: [],
  1318. source: "testZorkCommitPathJsShouldBeJavascript\x0a\x09self assert: 'javascripts/' equals: zorkPackage commitPathJs",
  1319. messageSends: ["assert:equals:", "commitPathJs"],
  1320. referencedClasses: []
  1321. }),
  1322. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1323. smalltalk.addMethod(
  1324. "_testZorkCommitPathStShouldBeSmalltalk",
  1325. smalltalk.method({
  1326. selector: "testZorkCommitPathStShouldBeSmalltalk",
  1327. category: 'tests',
  1328. fn: function () {
  1329. var self=this;
  1330. smalltalk.send(self, "_assert_equals_", [unescape("smalltalk/"), smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  1331. return self;},
  1332. args: [],
  1333. source: "testZorkCommitPathStShouldBeSmalltalk\x0a\x09self assert: 'smalltalk/' equals: zorkPackage commitPathSt",
  1334. messageSends: ["assert:equals:", "commitPathSt"],
  1335. referencedClasses: []
  1336. }),
  1337. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1338. smalltalk.addMethod(
  1339. "_shouldInheritSelectors",
  1340. smalltalk.method({
  1341. selector: "shouldInheritSelectors",
  1342. category: 'accessing',
  1343. fn: function () {
  1344. var self=this;
  1345. return false;
  1346. return self;},
  1347. args: [],
  1348. source: "shouldInheritSelectors\x0a\x09^ false",
  1349. messageSends: [],
  1350. referencedClasses: []
  1351. }),
  1352. smalltalk.PackageWithDefaultCommitPathChangedTest.klass);
  1353. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1354. smalltalk.addMethod(
  1355. "_testAccessing",
  1356. smalltalk.method({
  1357. selector: "testAccessing",
  1358. category: 'tests',
  1359. fn: function () {
  1360. var self=this;
  1361. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)]), "_x", []), (3)]);
  1362. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)]), "_y", []), (4)]);
  1363. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_new", []), "_x_", [(3)]), "_x", []), (3)]);
  1364. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_new", []), "_y_", [(4)]), "_y", []), (4)]);
  1365. return self;},
  1366. args: [],
  1367. source: "testAccessing\x0a\x09self assert: (Point x: 3 y: 4) x equals: 3.\x0a\x09self assert: (Point x: 3 y: 4) y equals: 4.\x0a\x09self assert: (Point new x: 3) x equals: 3.\x0a\x09self assert: (Point new y: 4) y equals: 4",
  1368. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  1369. referencedClasses: ["Point"]
  1370. }),
  1371. smalltalk.PointTest);
  1372. smalltalk.addMethod(
  1373. "_testArithmetic",
  1374. smalltalk.method({
  1375. selector: "testArithmetic",
  1376. category: 'tests',
  1377. fn: function () {
  1378. var self=this;
  1379. smalltalk.send(self, "_assert_equals_", [((($receiver = smalltalk.send((3), "__at", [(4)])).klass === smalltalk.Number) ? $receiver *smalltalk.send((3), "__at", [(4)]) : smalltalk.send($receiver, "__star", [smalltalk.send((3), "__at", [(4)])])), smalltalk.send((smalltalk.Point || Point), "_x_y_", [(9), (16)])]);
  1380. smalltalk.send(self, "_assert_equals_", [((($receiver = smalltalk.send((3), "__at", [(4)])).klass === smalltalk.Number) ? $receiver +smalltalk.send((3), "__at", [(4)]) : smalltalk.send($receiver, "__plus", [smalltalk.send((3), "__at", [(4)])])), smalltalk.send((smalltalk.Point || Point), "_x_y_", [(6), (8)])]);
  1381. smalltalk.send(self, "_assert_equals_", [((($receiver = smalltalk.send((3), "__at", [(4)])).klass === smalltalk.Number) ? $receiver -smalltalk.send((3), "__at", [(4)]) : smalltalk.send($receiver, "__minus", [smalltalk.send((3), "__at", [(4)])])), smalltalk.send((smalltalk.Point || Point), "_x_y_", [(0), (0)])]);
  1382. smalltalk.send(self, "_assert_equals_", [((($receiver = smalltalk.send((6), "__at", [(8)])).klass === smalltalk.Number) ? $receiver /smalltalk.send((3), "__at", [(4)]) : smalltalk.send($receiver, "__slash", [smalltalk.send((3), "__at", [(4)])])), smalltalk.send((smalltalk.Point || Point), "_x_y_", [(2), (2)])]);
  1383. return self;},
  1384. args: [],
  1385. source: "testArithmetic\x0a\x09self assert: 3@4 * (3@4 ) equals: (Point x: 9 y: 16).\x0a\x09self assert: 3@4 + (3@4 ) equals: (Point x: 6 y: 8).\x0a\x09self assert: 3@4 - (3@4 ) equals: (Point x: 0 y: 0).\x0a\x09self assert: 6@8 / (3@4 ) equals: (Point x: 2 y: 2)",
  1386. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  1387. referencedClasses: ["Point"]
  1388. }),
  1389. smalltalk.PointTest);
  1390. smalltalk.addMethod(
  1391. "_testAt",
  1392. smalltalk.method({
  1393. selector: "testAt",
  1394. category: 'tests',
  1395. fn: function () {
  1396. var self=this;
  1397. smalltalk.send(self, "_assert_equals_", [smalltalk.send((3), "__at", [(4)]), smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)])]);
  1398. return self;},
  1399. args: [],
  1400. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  1401. messageSends: ["assert:equals:", "@", "x:y:"],
  1402. referencedClasses: ["Point"]
  1403. }),
  1404. smalltalk.PointTest);
  1405. smalltalk.addMethod(
  1406. "_testEgality",
  1407. smalltalk.method({
  1408. selector: "testEgality",
  1409. category: 'tests',
  1410. fn: function () {
  1411. var self=this;
  1412. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "__at", [(4)]), "__eq", [smalltalk.send((3), "__at", [(4)])])]);
  1413. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send((3), "__at", [(5)]), "__eq", [smalltalk.send((3), "__at", [(6)])])]);
  1414. return self;},
  1415. args: [],
  1416. source: "testEgality\x0a\x09self assert: 3@4 = (3@4).\x0a\x09self deny: 3@5 = (3@6)",
  1417. messageSends: ["assert:", "=", "@", "deny:"],
  1418. referencedClasses: []
  1419. }),
  1420. smalltalk.PointTest);
  1421. smalltalk.addMethod(
  1422. "_testTranslateBy",
  1423. smalltalk.method({
  1424. selector: "testTranslateBy",
  1425. category: 'tests',
  1426. fn: function () {
  1427. var self=this;
  1428. smalltalk.send(self, "_assert_equals_", [smalltalk.send((3), "__at", [(4)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send((0), "__at", [(1)])])]);
  1429. smalltalk.send(self, "_assert_equals_", [smalltalk.send((3), "__at", [(2)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send((0), "__at", [smalltalk.send((1), "_negated", [])])])]);
  1430. smalltalk.send(self, "_assert_equals_", [smalltalk.send((5), "__at", [(6)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send((2), "__at", [(3)])])]);
  1431. smalltalk.send(self, "_assert_equals_", [smalltalk.send((0), "__at", [(3)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send(smalltalk.send((3), "_negated", []), "__at", [(0)])])]);
  1432. return self;},
  1433. args: [],
  1434. source: "testTranslateBy\x0a\x09self assert: 3@4 equals: (3@3 translateBy: 0@1).\x0a\x09self assert: 3@2 equals: (3@3 translateBy: 0@1 negated).\x0a\x09self assert: 5@6 equals: (3@3 translateBy: 2@3).\x0a\x09self assert: 0@3 equals: (3@3 translateBy: 3 negated @0).",
  1435. messageSends: ["assert:equals:", "@", "translateBy:", "negated"],
  1436. referencedClasses: []
  1437. }),
  1438. smalltalk.PointTest);
  1439. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1440. smalltalk.addMethod(
  1441. "_textNext",
  1442. smalltalk.method({
  1443. selector: "textNext",
  1444. category: 'tests',
  1445. fn: function () {
  1446. var self=this;
  1447. smalltalk.send((10000), "_timesRepeat_", [(function(){var current=nil;
  1448. var next=nil;
  1449. (next=smalltalk.send(smalltalk.send((smalltalk.Random || Random), "_new", []), "_next", []));smalltalk.send(self, "_assert_", [((($receiver = next).klass === smalltalk.Number) ? $receiver >=(0) : smalltalk.send($receiver, "__gt_eq", [(0)]))]);smalltalk.send(self, "_assert_", [((($receiver = next).klass === smalltalk.Number) ? $receiver <(1) : smalltalk.send($receiver, "__lt", [(1)]))]);smalltalk.send(self, "_deny_", [smalltalk.send(current, "__eq", [next])]);return smalltalk.send(next, "__eq", [current]);})]);
  1450. return self;},
  1451. args: [],
  1452. source: "textNext\x0a\x0a\x0910000 timesRepeat: [\x0a\x09\x09\x09| current next | \x0a\x09\x09\x09next := Random new next.\x0a\x09\x09\x09self assert: (next >= 0).\x0a\x09\x09\x09self assert: (next < 1).\x0a\x09\x09\x09self deny: current = next.\x0a\x09\x09\x09next = current]",
  1453. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  1454. referencedClasses: ["Random"]
  1455. }),
  1456. smalltalk.RandomTest);
  1457. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1458. smalltalk.addMethod(
  1459. "_testAddRemove",
  1460. smalltalk.method({
  1461. selector: "testAddRemove",
  1462. category: 'tests',
  1463. fn: function () {
  1464. var self=this;
  1465. var set=nil;
  1466. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  1467. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_isEmpty", [])]);
  1468. smalltalk.send(set, "_add_", [(3)]);
  1469. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [(3)])]);
  1470. smalltalk.send(set, "_add_", [(5)]);
  1471. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [(5)])]);
  1472. smalltalk.send(set, "_remove_", [(3)]);
  1473. smalltalk.send(self, "_deny_", [smalltalk.send(set, "_includes_", [(3)])]);
  1474. return self;},
  1475. args: [],
  1476. source: "testAddRemove\x0a\x09| set |\x0a\x09set := Set new.\x0a\x09\x0a\x09self assert: set isEmpty.\x0a\x0a\x09set add: 3.\x0a\x09self assert: (set includes: 3).\x0a\x0a\x09set add: 5.\x0a\x09self assert: (set includes: 5).\x0a\x0a\x09set remove: 3.\x0a\x09self deny: (set includes: 3)",
  1477. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  1478. referencedClasses: ["Set"]
  1479. }),
  1480. smalltalk.SetTest);
  1481. smalltalk.addMethod(
  1482. "_testAt",
  1483. smalltalk.method({
  1484. selector: "testAt",
  1485. category: 'tests',
  1486. fn: function () {
  1487. var self=this;
  1488. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_new", []), "_at_put_", [(1), (2)]);}), (smalltalk.Error || Error)]);
  1489. return self;},
  1490. args: [],
  1491. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  1492. messageSends: ["should:raise:", "at:put:", "new"],
  1493. referencedClasses: ["Set", "Error"]
  1494. }),
  1495. smalltalk.SetTest);
  1496. smalltalk.addMethod(
  1497. "_testSize",
  1498. smalltalk.method({
  1499. selector: "testSize",
  1500. category: 'tests',
  1501. fn: function () {
  1502. var self=this;
  1503. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_new", []), "_size", []), (0)]);
  1504. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_withAll_", [[(1), (2), (3), (4)]]), "_size", []), (4)]);
  1505. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_withAll_", [[(1), (1), (1), (1)]]), "_size", []), (1)]);
  1506. return self;},
  1507. args: [],
  1508. source: "testSize\x0a\x09self assert: Set new size equals: 0.\x0a\x09self assert: (Set withAll: #(1 2 3 4)) size equals: 4.\x0a\x09self assert: (Set withAll: #(1 1 1 1)) size equals: 1",
  1509. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  1510. referencedClasses: ["Set"]
  1511. }),
  1512. smalltalk.SetTest);
  1513. smalltalk.addMethod(
  1514. "_testUnicity",
  1515. smalltalk.method({
  1516. selector: "testUnicity",
  1517. category: 'tests',
  1518. fn: function () {
  1519. var self=this;
  1520. var set=nil;
  1521. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  1522. smalltalk.send(set, "_add_", [(21)]);
  1523. smalltalk.send(set, "_add_", ["hello"]);
  1524. smalltalk.send(set, "_add_", [(21)]);
  1525. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [(2)])]);
  1526. smalltalk.send(set, "_add_", ["hello"]);
  1527. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [(2)])]);
  1528. smalltalk.send(self, "_assert_equals_", [smalltalk.send(set, "_asArray", []), [(21), "hello"]]);
  1529. return self;},
  1530. args: [],
  1531. source: "testUnicity\x0a\x09| set |\x0a\x09set := Set new.\x0a\x09set add: 21.\x0a\x09set add: 'hello'.\x0a\x0a\x09set add: 21.\x0a\x09self assert: set size = 2.\x0a\x09\x0a\x09set add: 'hello'.\x0a\x09self assert: set size = 2.\x0a\x0a\x09self assert: set asArray equals: #(21 'hello')",
  1532. messageSends: ["new", "add:", "assert:", "=", "size", "assert:equals:", "asArray"],
  1533. referencedClasses: ["Set"]
  1534. }),
  1535. smalltalk.SetTest);
  1536. smalltalk.addClass('StringTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1537. smalltalk.addMethod(
  1538. "_testAddRemove",
  1539. smalltalk.method({
  1540. selector: "testAddRemove",
  1541. category: 'tests',
  1542. fn: function () {
  1543. var self=this;
  1544. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_add_", ["a"]);}), (smalltalk.Error || Error)]);
  1545. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_remove_", ["h"]);}), (smalltalk.Error || Error)]);
  1546. return self;},
  1547. args: [],
  1548. source: "testAddRemove\x0a\x09self should: ['hello' add: 'a'] raise: Error.\x0a\x09self should: ['hello' remove: 'h'] raise: Error",
  1549. messageSends: ["should:raise:", "add:", "remove:"],
  1550. referencedClasses: ["Error"]
  1551. }),
  1552. smalltalk.StringTest);
  1553. smalltalk.addMethod(
  1554. "_testAsArray",
  1555. smalltalk.method({
  1556. selector: "testAsArray",
  1557. category: 'tests',
  1558. fn: function () {
  1559. var self=this;
  1560. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_asArray", []), "__eq", [["h", "e", "l", "l", "o"]])]);
  1561. return self;},
  1562. args: [],
  1563. source: "testAsArray\x0a\x09self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').",
  1564. messageSends: ["assert:", "=", "asArray"],
  1565. referencedClasses: []
  1566. }),
  1567. smalltalk.StringTest);
  1568. smalltalk.addMethod(
  1569. "_testAt",
  1570. smalltalk.method({
  1571. selector: "testAt",
  1572. category: 'tests',
  1573. fn: function () {
  1574. var self=this;
  1575. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_", [(1)]), "__eq", ["h"])]);
  1576. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_", [(5)]), "__eq", ["o"])]);
  1577. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_ifAbsent_", [(6), (function(){return nil;})]), "__eq", [nil])]);
  1578. return self;},
  1579. args: [],
  1580. source: "testAt\x0a\x09self assert: ('hello' at: 1) = 'h'.\x0a\x09self assert: ('hello' at: 5) = 'o'.\x0a\x09self assert: ('hello' at: 6 ifAbsent: [nil]) = nil",
  1581. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  1582. referencedClasses: []
  1583. }),
  1584. smalltalk.StringTest);
  1585. smalltalk.addMethod(
  1586. "_testAtPut",
  1587. smalltalk.method({
  1588. selector: "testAtPut",
  1589. category: 'tests',
  1590. fn: function () {
  1591. var self=this;
  1592. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_at_put_", [(1), "a"]);}), (smalltalk.Error || Error)]);
  1593. return self;},
  1594. args: [],
  1595. source: "testAtPut\x0a\x09\x22String instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1596. messageSends: ["should:raise:", "at:put:"],
  1597. referencedClasses: ["Error"]
  1598. }),
  1599. smalltalk.StringTest);
  1600. smalltalk.addMethod(
  1601. "_testCopyWithoutAll",
  1602. smalltalk.method({
  1603. selector: "testCopyWithoutAll",
  1604. category: 'tests',
  1605. fn: function () {
  1606. var self=this;
  1607. smalltalk.send(self, "_assert_equals_", ["hello world", smalltalk.send(unescape("*hello*%20*world*"), "_copyWithoutAll_", [unescape("*")])]);
  1608. return self;},
  1609. args: [],
  1610. source: "testCopyWithoutAll\x0a\x09self \x0a\x09\x09assert: 'hello world' \x0a\x09\x09equals: ('*hello* *world*' copyWithoutAll: '*')",
  1611. messageSends: ["assert:equals:", "copyWithoutAll:"],
  1612. referencedClasses: []
  1613. }),
  1614. smalltalk.StringTest);
  1615. smalltalk.addMethod(
  1616. "_testEquality",
  1617. smalltalk.method({
  1618. selector: "testEquality",
  1619. category: 'tests',
  1620. fn: function () {
  1621. var self=this;
  1622. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", ["hello"])]);
  1623. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq", ["world"])]);
  1624. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", [smalltalk.send("hello", "_yourself", [])])]);
  1625. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_yourself", []), "__eq", ["hello"])]);
  1626. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  1627. return self;},
  1628. args: [],
  1629. source: "testEquality\x0a\x09self assert: 'hello' = 'hello'.\x0a\x09self deny: 'hello' = 'world'.\x0a\x0a\x09self assert: 'hello' = 'hello' yourself.\x0a\x09self assert: 'hello' yourself = 'hello'.\x0a\x0a\x09\x22test JS falsy value\x22\x0a\x09self deny: '' = 0",
  1630. messageSends: ["assert:", "=", "deny:", "yourself"],
  1631. referencedClasses: []
  1632. }),
  1633. smalltalk.StringTest);
  1634. smalltalk.addMethod(
  1635. "_testIncludesSubString",
  1636. smalltalk.method({
  1637. selector: "testIncludesSubString",
  1638. category: 'tests',
  1639. fn: function () {
  1640. var self=this;
  1641. smalltalk.send(self, "_assert_", [smalltalk.send("amber", "_includesSubString_", ["ber"])]);
  1642. smalltalk.send(self, "_deny_", [smalltalk.send("amber", "_includesSubString_", ["zork"])]);
  1643. return self;},
  1644. args: [],
  1645. source: "testIncludesSubString\x0a\x09self assert: ('amber' includesSubString: 'ber').\x0a\x09self deny: ('amber' includesSubString: 'zork').",
  1646. messageSends: ["assert:", "includesSubString:", "deny:"],
  1647. referencedClasses: []
  1648. }),
  1649. smalltalk.StringTest);
  1650. smalltalk.addMethod(
  1651. "_testJoin",
  1652. smalltalk.method({
  1653. selector: "testJoin",
  1654. category: 'tests',
  1655. fn: function () {
  1656. var self=this;
  1657. smalltalk.send(self, "_assert_equals_", [unescape("hello%2Cworld"), smalltalk.send(unescape("%2C"), "_join_", [["hello", "world"]])]);
  1658. return self;},
  1659. args: [],
  1660. source: "testJoin\x0a\x09self assert: 'hello,world' equals: (',' join: #('hello' 'world'))",
  1661. messageSends: ["assert:equals:", "join:"],
  1662. referencedClasses: []
  1663. }),
  1664. smalltalk.StringTest);
  1665. smalltalk.addMethod(
  1666. "_testSize",
  1667. smalltalk.method({
  1668. selector: "testSize",
  1669. category: 'tests',
  1670. fn: function () {
  1671. var self=this;
  1672. smalltalk.send(self, "_assert_equals_", [smalltalk.send("smalltalk", "_size", []), (9)]);
  1673. smalltalk.send(self, "_assert_equals_", [smalltalk.send("", "_size", []), (0)]);
  1674. return self;},
  1675. args: [],
  1676. source: "testSize\x0a\x09self assert: 'smalltalk' size equals: 9.\x0a\x09self assert: '' size equals: 0",
  1677. messageSends: ["assert:equals:", "size"],
  1678. referencedClasses: []
  1679. }),
  1680. smalltalk.StringTest);
  1681. smalltalk.addMethod(
  1682. "_testStreamContents",
  1683. smalltalk.method({
  1684. selector: "testStreamContents",
  1685. category: 'tests',
  1686. fn: function () {
  1687. var self=this;
  1688. 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);})])]);
  1689. return self;},
  1690. args: [],
  1691. source: "testStreamContents\x0a\x09self \x0a\x09\x09assert: 'hello world' \x0a\x09\x09equals: (String streamContents: [:aStream| aStream \x0a \x09\x09\x09\x09\x09nextPutAll: 'hello'; space; \x0a \x09\x09\x09\x09\x09nextPutAll: 'world'])",
  1692. messageSends: ["assert:equals:", "streamContents:", "nextPutAll:", "space"],
  1693. referencedClasses: ["String"]
  1694. }),
  1695. smalltalk.StringTest);
  1696. smalltalk.addClass('SymbolTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1697. smalltalk.addMethod(
  1698. "_testAsString",
  1699. smalltalk.method({
  1700. selector: "testAsString",
  1701. category: 'tests',
  1702. fn: function () {
  1703. var self=this;
  1704. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("hello"), "_asString", []), "hello"]);
  1705. return self;},
  1706. args: [],
  1707. source: "testAsString\x0a\x09self assert: #hello asString equals: 'hello'",
  1708. messageSends: ["assert:equals:", "asString"],
  1709. referencedClasses: []
  1710. }),
  1711. smalltalk.SymbolTest);
  1712. smalltalk.addMethod(
  1713. "_testAsSymbol",
  1714. smalltalk.method({
  1715. selector: "testAsSymbol",
  1716. category: 'tests',
  1717. fn: function () {
  1718. var self=this;
  1719. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_asSymbol", [])])]);
  1720. return self;},
  1721. args: [],
  1722. source: "testAsSymbol\x0a\x09self assert: #hello == #hello asSymbol",
  1723. messageSends: ["assert:", "==", "asSymbol"],
  1724. referencedClasses: []
  1725. }),
  1726. smalltalk.SymbolTest);
  1727. smalltalk.addMethod(
  1728. "_testAt",
  1729. smalltalk.method({
  1730. selector: "testAt",
  1731. category: 'tests',
  1732. fn: function () {
  1733. var self=this;
  1734. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_", [(1)]), "__eq", ["h"])]);
  1735. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_", [(5)]), "__eq", ["o"])]);
  1736. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_ifAbsent_", [(6), (function(){return nil;})]), "__eq", [nil])]);
  1737. return self;},
  1738. args: [],
  1739. source: "testAt\x0a\x09self assert: (#hello at: 1) = 'h'.\x0a\x09self assert: (#hello at: 5) = 'o'.\x0a\x09self assert: (#hello at: 6 ifAbsent: [nil]) = nil",
  1740. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  1741. referencedClasses: []
  1742. }),
  1743. smalltalk.SymbolTest);
  1744. smalltalk.addMethod(
  1745. "_testAtPut",
  1746. smalltalk.method({
  1747. selector: "testAtPut",
  1748. category: 'tests',
  1749. fn: function () {
  1750. var self=this;
  1751. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_at_put_", [(1), "a"]);}), (smalltalk.Error || Error)]);
  1752. return self;},
  1753. args: [],
  1754. source: "testAtPut\x0a\x09\x22Symbol instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1755. messageSends: ["should:raise:", "at:put:"],
  1756. referencedClasses: ["Error"]
  1757. }),
  1758. smalltalk.SymbolTest);
  1759. smalltalk.addMethod(
  1760. "_testComparing",
  1761. smalltalk.method({
  1762. selector: "testComparing",
  1763. category: 'tests',
  1764. fn: function () {
  1765. var self=this;
  1766. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >smalltalk.symbolFor("aa") : smalltalk.send($receiver, "__gt", [smalltalk.symbolFor("aa")]))]);
  1767. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__gt", [smalltalk.symbolFor("ba")]))]);
  1768. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver <smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt", [smalltalk.symbolFor("ba")]))]);
  1769. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("bb")).klass === smalltalk.Number) ? $receiver <smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt", [smalltalk.symbolFor("ba")]))]);
  1770. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >=smalltalk.symbolFor("aa") : smalltalk.send($receiver, "__gt_eq", [smalltalk.symbolFor("aa")]))]);
  1771. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__gt_eq", [smalltalk.symbolFor("ba")]))]);
  1772. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver <=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt_eq", [smalltalk.symbolFor("ba")]))]);
  1773. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("bb")).klass === smalltalk.Number) ? $receiver <=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt_eq", [smalltalk.symbolFor("ba")]))]);
  1774. return self;},
  1775. args: [],
  1776. source: "testComparing\x0a\x09self assert: #ab > #aa.\x0a\x09self deny: #ab > #ba.\x0a\x0a\x09self assert: #ab < #ba.\x0a\x09self deny: #bb < #ba.\x0a\x0a\x09self assert: #ab >= #aa.\x0a\x09self deny: #ab >= #ba.\x0a\x0a\x09self assert: #ab <= #ba.\x0a\x09self deny: #bb <= #ba",
  1777. messageSends: ["assert:", ">", "deny:", "<", ">=", "<="],
  1778. referencedClasses: []
  1779. }),
  1780. smalltalk.SymbolTest);
  1781. smalltalk.addMethod(
  1782. "_testCopying",
  1783. smalltalk.method({
  1784. selector: "testCopying",
  1785. category: 'tests',
  1786. fn: function () {
  1787. var self=this;
  1788. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_copy", []), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  1789. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_deepCopy", []), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  1790. return self;},
  1791. args: [],
  1792. source: "testCopying\x0a\x09self assert: #hello copy == #hello.\x0a\x09self assert: #hello deepCopy == #hello",
  1793. messageSends: ["assert:", "==", "copy", "deepCopy"],
  1794. referencedClasses: []
  1795. }),
  1796. smalltalk.SymbolTest);
  1797. smalltalk.addMethod(
  1798. "_testEquality",
  1799. smalltalk.method({
  1800. selector: "testEquality",
  1801. category: 'tests',
  1802. fn: function () {
  1803. var self=this;
  1804. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.symbolFor("hello")])]);
  1805. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.symbolFor("world")])]);
  1806. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", [])])]);
  1807. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", []), "__eq", [smalltalk.symbolFor("hello")])]);
  1808. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", ["hello"])]);
  1809. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq", [smalltalk.symbolFor("hello")])]);
  1810. return self;},
  1811. args: [],
  1812. source: "testEquality\x0a\x09self assert: #hello = #hello.\x0a\x09self deny: #hello = #world.\x0a\x0a\x09self assert: #hello = #hello yourself.\x0a\x09self assert: #hello yourself = #hello.\x0a\x0a\x09self deny: #hello = 'hello'.\x0a\x09self deny: 'hello' = #hello.",
  1813. messageSends: ["assert:", "=", "deny:", "yourself"],
  1814. referencedClasses: []
  1815. }),
  1816. smalltalk.SymbolTest);
  1817. smalltalk.addMethod(
  1818. "_testIdentity",
  1819. smalltalk.method({
  1820. selector: "testIdentity",
  1821. category: 'tests',
  1822. fn: function () {
  1823. var self=this;
  1824. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  1825. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.symbolFor("world")])]);
  1826. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", [])])]);
  1827. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", []), "__eq", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_asString", []), "_asSymbol", [])])]);
  1828. return self;},
  1829. args: [],
  1830. source: "testIdentity\x0a\x09self assert: #hello == #hello.\x0a\x09self deny: #hello == #world.\x0a\x0a\x09self assert: #hello = #hello yourself.\x0a\x09self assert: #hello yourself = #hello asString asSymbol",
  1831. messageSends: ["assert:", "==", "deny:", "=", "yourself", "asSymbol", "asString"],
  1832. referencedClasses: []
  1833. }),
  1834. smalltalk.SymbolTest);
  1835. smalltalk.addMethod(
  1836. "_testIsSymbolIsString",
  1837. smalltalk.method({
  1838. selector: "testIsSymbolIsString",
  1839. category: 'tests',
  1840. fn: function () {
  1841. var self=this;
  1842. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "_isSymbol", [])]);
  1843. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "_isSymbol", [])]);
  1844. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "_isString", [])]);
  1845. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "_isString", [])]);
  1846. return self;},
  1847. args: [],
  1848. source: "testIsSymbolIsString\x0a\x09self assert: #hello isSymbol.\x0a\x09self deny: 'hello' isSymbol.\x0a\x09self deny: #hello isString.\x0a\x09self assert: 'hello' isString",
  1849. messageSends: ["assert:", "isSymbol", "deny:", "isString"],
  1850. referencedClasses: []
  1851. }),
  1852. smalltalk.SymbolTest);
  1853. smalltalk.addMethod(
  1854. "_testSize",
  1855. smalltalk.method({
  1856. selector: "testSize",
  1857. category: 'tests',
  1858. fn: function () {
  1859. var self=this;
  1860. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("a"), "_size", []), (1)]);
  1861. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("aaaaa"), "_size", []), (5)]);
  1862. return self;},
  1863. args: [],
  1864. source: "testSize\x0a\x09self assert: #a size equals: 1.\x0a\x09self assert: #aaaaa size equals: 5",
  1865. messageSends: ["assert:equals:", "size"],
  1866. referencedClasses: []
  1867. }),
  1868. smalltalk.SymbolTest);
  1869. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1870. smalltalk.addMethod(
  1871. "_testCopying",
  1872. smalltalk.method({
  1873. selector: "testCopying",
  1874. category: 'tests',
  1875. fn: function () {
  1876. var self=this;
  1877. smalltalk.send(self, "_assert_equals_", [smalltalk.send(nil, "_copy", []), nil]);
  1878. return self;},
  1879. args: [],
  1880. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  1881. messageSends: ["assert:equals:", "copy"],
  1882. referencedClasses: []
  1883. }),
  1884. smalltalk.UndefinedTest);
  1885. smalltalk.addMethod(
  1886. "_testDeepCopy",
  1887. smalltalk.method({
  1888. selector: "testDeepCopy",
  1889. category: 'tests',
  1890. fn: function () {
  1891. var self=this;
  1892. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(nil, "_deepCopy", []), "__eq", [nil])]);
  1893. return self;},
  1894. args: [],
  1895. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  1896. messageSends: ["assert:", "=", "deepCopy"],
  1897. referencedClasses: []
  1898. }),
  1899. smalltalk.UndefinedTest);
  1900. smalltalk.addMethod(
  1901. "_testIfNil",
  1902. smalltalk.method({
  1903. selector: "testIfNil",
  1904. category: 'tests',
  1905. fn: function () {
  1906. var self=this;
  1907. smalltalk.send(self, "_assert_equals_", [(($receiver = nil) == nil || $receiver == undefined) ? (function(){return true;})() : $receiver, true]);
  1908. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = nil) != nil && $receiver != undefined) ? (function(){return true;})() : nil, "__eq", [true])]);
  1909. smalltalk.send(self, "_assert_equals_", [(($receiver = nil) == nil || $receiver == undefined) ? (function(){return true;})() : (function(){return false;})(), true]);
  1910. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = nil) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  1911. return self;},
  1912. args: [],
  1913. source: "testIfNil\x0a\x09self assert: (nil ifNil: [true]) equals: true.\x0a\x09self deny: (nil ifNotNil: [true]) = true.\x0a\x09self assert: (nil ifNil: [true] ifNotNil: [false]) equals: true.\x0a\x09self deny: (nil ifNotNil: [true] ifNil: [false]) = true",
  1914. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  1915. referencedClasses: []
  1916. }),
  1917. smalltalk.UndefinedTest);
  1918. smalltalk.addMethod(
  1919. "_testIsNil",
  1920. smalltalk.method({
  1921. selector: "testIsNil",
  1922. category: 'tests',
  1923. fn: function () {
  1924. var self=this;
  1925. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "_isNil", [])]);
  1926. smalltalk.send(self, "_deny_", [smalltalk.send(nil, "_notNil", [])]);
  1927. return self;},
  1928. args: [],
  1929. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  1930. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  1931. referencedClasses: []
  1932. }),
  1933. smalltalk.UndefinedTest);