Kernel-Tests.js 114 KB

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