Kernel-Tests.js 149 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126
  1. smalltalk.addPackage('Kernel-Tests', {});
  2. smalltalk.addClass('BlockClosureTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3. smalltalk.addMethod(
  4. "_testCanClearInterval",
  5. smalltalk.method({
  6. selector: "testCanClearInterval",
  7. category: 'tests',
  8. fn: function (){
  9. var self=this;
  10. smalltalk.send(self, "_shouldnt_raise_", [(function(){return smalltalk.send(smalltalk.send((function(){return smalltalk.send(smalltalk.send((smalltalk.Error || Error), "_new", []), "_signal", []);}), "_valueWithInterval_", [(0)]), "_clearInterval", []);}), (smalltalk.Error || Error)]);
  11. return self;},
  12. args: [],
  13. source: "testCanClearInterval\x0a\x09self shouldnt: [([Error new signal] valueWithInterval: 0) clearInterval] raise: Error",
  14. messageSends: ["shouldnt:raise:", "clearInterval", "valueWithInterval:", "signal", "new"],
  15. referencedClasses: ["Error"]
  16. }),
  17. smalltalk.BlockClosureTest);
  18. smalltalk.addMethod(
  19. "_testCanClearTimeout",
  20. smalltalk.method({
  21. selector: "testCanClearTimeout",
  22. category: 'tests',
  23. fn: function (){
  24. var self=this;
  25. smalltalk.send(self, "_shouldnt_raise_", [(function(){return smalltalk.send(smalltalk.send((function(){return smalltalk.send(smalltalk.send((smalltalk.Error || Error), "_new", []), "_signal", []);}), "_valueWithTimeout_", [(0)]), "_clearTimeout", []);}), (smalltalk.Error || Error)]);
  26. return self;},
  27. args: [],
  28. source: "testCanClearTimeout\x0a\x09self shouldnt: [([Error new signal] valueWithTimeout: 0) clearTimeout] raise: Error",
  29. messageSends: ["shouldnt:raise:", "clearTimeout", "valueWithTimeout:", "signal", "new"],
  30. referencedClasses: ["Error"]
  31. }),
  32. smalltalk.BlockClosureTest);
  33. smalltalk.addMethod(
  34. "_testCompiledSource",
  35. smalltalk.method({
  36. selector: "testCompiledSource",
  37. category: 'tests',
  38. fn: function (){
  39. var self=this;
  40. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((function(){return (1) + (1);}), "_compiledSource", []), "_includesSubString_", ["function"])]);
  41. return self;},
  42. args: [],
  43. source: "testCompiledSource\x0a\x09self assert: ([1+1] compiledSource includesSubString: 'function')",
  44. messageSends: ["assert:", "includesSubString:", "compiledSource", "+"],
  45. referencedClasses: []
  46. }),
  47. smalltalk.BlockClosureTest);
  48. smalltalk.addMethod(
  49. "_testEnsure",
  50. smalltalk.method({
  51. selector: "testEnsure",
  52. category: 'tests',
  53. fn: function (){
  54. var self=this;
  55. smalltalk.send(self, "_assert_equals_", [(3), smalltalk.send((function(){return (3);}), "_ensure_", [(function(){return (4);})])]);
  56. return self;},
  57. args: [],
  58. source: "testEnsure\x0a\x09self assert: 3 equals: ([3] ensure: [4])",
  59. messageSends: ["assert:equals:", "ensure:"],
  60. referencedClasses: []
  61. }),
  62. smalltalk.BlockClosureTest);
  63. smalltalk.addMethod(
  64. "_testEnsureRaises",
  65. smalltalk.method({
  66. selector: "testEnsureRaises",
  67. category: 'tests',
  68. fn: function (){
  69. var self=this;
  70. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((function(){return smalltalk.send(smalltalk.send((smalltalk.Error || Error), "_new", []), "_signal", []);}), "_ensure_", [(function(){return true;})]);}), (smalltalk.Error || Error)]);
  71. return self;},
  72. args: [],
  73. source: "testEnsureRaises\x0a\x09self should: [[Error new signal] ensure: [true]] raise: Error",
  74. messageSends: ["should:raise:", "ensure:", "signal", "new"],
  75. referencedClasses: ["Error"]
  76. }),
  77. smalltalk.BlockClosureTest);
  78. smalltalk.addMethod(
  79. "_testNumArgs",
  80. smalltalk.method({
  81. selector: "testNumArgs",
  82. category: 'tests',
  83. fn: function (){
  84. var self=this;
  85. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(){return nil;}), "_numArgs", []), (0)]);
  86. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(a, b){return nil;}), "_numArgs", []), (2)]);
  87. return self;},
  88. args: [],
  89. source: "testNumArgs\x0a\x09self assert: [] numArgs equals: 0.\x0a\x09self assert: [:a :b | ] numArgs equals: 2",
  90. messageSends: ["assert:equals:", "numArgs"],
  91. referencedClasses: []
  92. }),
  93. smalltalk.BlockClosureTest);
  94. smalltalk.addMethod(
  95. "_testOnDo",
  96. smalltalk.method({
  97. selector: "testOnDo",
  98. category: 'tests',
  99. fn: function (){
  100. var self=this;
  101. 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;})])]);
  102. return self;},
  103. args: [],
  104. source: "testOnDo\x0a\x09self assert: ([Error new signal] on: Error do: [:ex | true])",
  105. messageSends: ["assert:", "on:do:", "signal", "new"],
  106. referencedClasses: ["Error"]
  107. }),
  108. smalltalk.BlockClosureTest);
  109. smalltalk.addMethod(
  110. "_testValue",
  111. smalltalk.method({
  112. selector: "testValue",
  113. category: 'tests',
  114. fn: function (){
  115. var self=this;
  116. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(){return (1) + (1);}), "_value", []), (2)]);
  117. 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)]);
  118. 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)]);
  119. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(a, b, c){return (1);}), "_value", []), (1)]);
  120. return self;},
  121. args: [],
  122. 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",
  123. messageSends: ["assert:equals:", "value", "+", "value:", "value:value:", "*"],
  124. referencedClasses: []
  125. }),
  126. smalltalk.BlockClosureTest);
  127. smalltalk.addMethod(
  128. "_testValueWithPossibleArguments",
  129. smalltalk.method({
  130. selector: "testValueWithPossibleArguments",
  131. category: 'tests',
  132. fn: function (){
  133. var self=this;
  134. smalltalk.send(self, "_assert_equals_", [smalltalk.send((function(){return (1);}), "_valueWithPossibleArguments_", [[(3), (4)]]), (1)]);
  135. 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)]);
  136. 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)]);
  137. return self;},
  138. args: [],
  139. 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.",
  140. messageSends: ["assert:equals:", "valueWithPossibleArguments:", "+"],
  141. referencedClasses: []
  142. }),
  143. smalltalk.BlockClosureTest);
  144. smalltalk.addMethod(
  145. "_testWhileFalse",
  146. smalltalk.method({
  147. selector: "testWhileFalse",
  148. category: 'tests',
  149. fn: function (){
  150. var self=this;
  151. var i=nil;
  152. (i=(0));
  153. (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)])));})()}})();
  154. smalltalk.send(self, "_assert_equals_", [i, (6)]);
  155. (i=(0));
  156. (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)]));})()) {}})();
  157. smalltalk.send(self, "_assert_equals_", [i, (6)]);
  158. return self;},
  159. args: [],
  160. 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",
  161. messageSends: ["whileFalse:", ">", "+", "assert:equals:", "whileFalse"],
  162. referencedClasses: []
  163. }),
  164. smalltalk.BlockClosureTest);
  165. smalltalk.addMethod(
  166. "_testWhileTrue",
  167. smalltalk.method({
  168. selector: "testWhileTrue",
  169. category: 'tests',
  170. fn: function (){
  171. var self=this;
  172. var i=nil;
  173. (i=(0));
  174. (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)])));})()}})();
  175. smalltalk.send(self, "_assert_equals_", [i, (5)]);
  176. (i=(0));
  177. (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)]));})()) {}})();
  178. smalltalk.send(self, "_assert_equals_", [i, (5)]);
  179. return self;},
  180. args: [],
  181. 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",
  182. messageSends: ["whileTrue:", "<", "+", "assert:equals:", "whileTrue"],
  183. referencedClasses: []
  184. }),
  185. smalltalk.BlockClosureTest);
  186. smalltalk.addClass('BooleanTest', smalltalk.TestCase, [], 'Kernel-Tests');
  187. smalltalk.addMethod(
  188. "_testEquality",
  189. smalltalk.method({
  190. selector: "testEquality",
  191. category: 'tests',
  192. fn: function (){
  193. var self=this;
  194. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [false])]);
  195. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [(0)])]);
  196. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [false])]);
  197. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [""])]);
  198. smalltalk.send(self, "_assert_", [smalltalk.send(true, "__eq", [true])]);
  199. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [true])]);
  200. smalltalk.send(self, "_deny_", [smalltalk.send(true, "__eq", [false])]);
  201. smalltalk.send(self, "_assert_", [smalltalk.send(false, "__eq", [false])]);
  202. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq", [true])]);
  203. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq", [smalltalk.send(true, "_yourself", [])])]);
  204. return self;},
  205. args: [],
  206. 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",
  207. messageSends: ["deny:", "=", "assert:", "yourself"],
  208. referencedClasses: []
  209. }),
  210. smalltalk.BooleanTest);
  211. smalltalk.addMethod(
  212. "_testIdentity",
  213. smalltalk.method({
  214. selector: "testIdentity",
  215. category: 'tests',
  216. fn: function (){
  217. var self=this;
  218. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq_eq", [false])]);
  219. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq_eq", [(0)])]);
  220. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq_eq", [false])]);
  221. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq_eq", [""])]);
  222. smalltalk.send(self, "_assert_", [smalltalk.send(true, "__eq_eq", [true])]);
  223. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq_eq", [true])]);
  224. smalltalk.send(self, "_deny_", [smalltalk.send(true, "__eq_eq", [false])]);
  225. smalltalk.send(self, "_assert_", [smalltalk.send(false, "__eq_eq", [false])]);
  226. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq_eq", [true])]);
  227. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(true, "_yourself", []), "__eq_eq", [smalltalk.send(true, "_yourself", [])])]);
  228. return self;},
  229. args: [],
  230. 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",
  231. messageSends: ["deny:", "==", "assert:", "yourself"],
  232. referencedClasses: []
  233. }),
  234. smalltalk.BooleanTest);
  235. smalltalk.addMethod(
  236. "_testIfTrueIfFalse",
  237. smalltalk.method({
  238. selector: "testIfTrueIfFalse",
  239. category: 'tests',
  240. fn: function (){
  241. var self=this;
  242. 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"])]);
  243. 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])]);
  244. 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])]);
  245. 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"])]);
  246. 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"])]);
  247. 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"])]);
  248. 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"])]);
  249. 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"])]);
  250. return self;},
  251. args: [],
  252. 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'.",
  253. messageSends: ["assert:", "=", "ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  254. referencedClasses: []
  255. }),
  256. smalltalk.BooleanTest);
  257. smalltalk.addMethod(
  258. "_testIfTrueIfFalseWithBoxing",
  259. smalltalk.method({
  260. selector: "testIfTrueIfFalseWithBoxing",
  261. category: 'tests',
  262. fn: function (){
  263. var self=this;
  264. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(true, "_boxed", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return "alternative block";})])), "__eq", ["alternative block"])]);
  265. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(true, "_boxed", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return "alternative block";})])), "__eq", [nil])]);
  266. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(false, "_boxed", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return "alternative block";})])), "__eq", [nil])]);
  267. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(false, "_boxed", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return "alternative block";})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return "alternative block";})])), "__eq", ["alternative block"])]);
  268. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(false, "_boxed", [])).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"])]);
  269. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(false, "_boxed", [])).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"])]);
  270. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(true, "_boxed", [])).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"])]);
  271. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = smalltalk.send(true, "_boxed", [])).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"])]);
  272. return self;},
  273. args: [],
  274. source: "testIfTrueIfFalseWithBoxing\x0a \x0a\x09self assert: (true boxed ifTrue: ['alternative block']) = 'alternative block'.\x0a\x09self assert: (true boxed ifFalse: ['alternative block']) = nil.\x0a\x0a\x09self assert: (false boxed ifTrue: ['alternative block']) = nil.\x0a\x09self assert: (false boxed ifFalse: ['alternative block']) = 'alternative block'.\x0a\x0a\x09self assert: (false boxed ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.\x0a\x09self assert: (false boxed ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.\x0a\x0a\x09self assert: (true boxed ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.\x0a\x09self assert: (true boxed ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.",
  275. messageSends: ["assert:", "=", "ifTrue:", "boxed", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  276. referencedClasses: []
  277. }),
  278. smalltalk.BooleanTest);
  279. smalltalk.addMethod(
  280. "_testLogic",
  281. smalltalk.method({
  282. selector: "testLogic",
  283. category: 'tests',
  284. fn: function (){
  285. var self=this;
  286. (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);
  287. (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);
  288. (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);
  289. (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);
  290. return self;},
  291. args: [],
  292. 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))",
  293. messageSends: ["assert:", "&", "deny:", "|", ">"],
  294. referencedClasses: []
  295. }),
  296. smalltalk.BooleanTest);
  297. smalltalk.addMethod(
  298. "_testLogicKeywords",
  299. smalltalk.method({
  300. selector: "testLogicKeywords",
  301. category: 'tests',
  302. fn: function (){
  303. var self=this;
  304. (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);
  305. (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);
  306. (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);
  307. (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);
  308. return self;},
  309. args: [],
  310. 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 ])",
  311. messageSends: ["assert:", "and:", "deny:", "or:", ">"],
  312. referencedClasses: []
  313. }),
  314. smalltalk.BooleanTest);
  315. smalltalk.addMethod(
  316. "_testNonBooleanError",
  317. smalltalk.method({
  318. selector: "testNonBooleanError",
  319. category: 'tests',
  320. fn: function (){
  321. var self=this;
  322. var nonBoolean=nil;
  323. (nonBoolean= '' );
  324. smalltalk.send(self, "_should_raise_", [(function(){return ((($receiver = nonBoolean).klass === smalltalk.Boolean) ? ($receiver ? (function(){return nil;})() : (function(){return nil;})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return nil;}), (function(){return nil;})]));}), (smalltalk.NonBooleanReceiver || NonBooleanReceiver)]);
  325. return self;},
  326. args: [],
  327. source: "testNonBooleanError\x0a\x09|nonBoolean|\x0a nonBoolean := < '' >.\x0a self should: [nonBoolean ifTrue: [] ifFalse: []] raise: NonBooleanReceiver",
  328. messageSends: ["should:raise:", "ifTrue:ifFalse:"],
  329. referencedClasses: ["NonBooleanReceiver"]
  330. }),
  331. smalltalk.BooleanTest);
  332. smalltalk.addClass('ClassBuilderTest', smalltalk.TestCase, ['builder', 'theClass'], 'Kernel-Tests');
  333. smalltalk.addMethod(
  334. "_setUp",
  335. smalltalk.method({
  336. selector: "setUp",
  337. category: 'running',
  338. fn: function (){
  339. var self=this;
  340. (self['@builder']=smalltalk.send((smalltalk.ClassBuilder || ClassBuilder), "_new", []));
  341. return self;},
  342. args: [],
  343. source: "setUp\x0a\x09builder := ClassBuilder new",
  344. messageSends: ["new"],
  345. referencedClasses: ["ClassBuilder"]
  346. }),
  347. smalltalk.ClassBuilderTest);
  348. smalltalk.addMethod(
  349. "_tearDown",
  350. smalltalk.method({
  351. selector: "tearDown",
  352. category: 'running',
  353. fn: function (){
  354. var self=this;
  355. (($receiver = self['@theClass']) != nil && $receiver != undefined) ? (function(){smalltalk.send(smalltalk.send((smalltalk.Smalltalk || Smalltalk), "_current", []), "_removeClass_", [self['@theClass']]);return (self['@theClass']=nil);})() : nil;
  356. return self;},
  357. args: [],
  358. source: "tearDown\x0a\x09theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]",
  359. messageSends: ["ifNotNil:", "removeClass:", "current"],
  360. referencedClasses: ["Smalltalk"]
  361. }),
  362. smalltalk.ClassBuilderTest);
  363. smalltalk.addMethod(
  364. "_testClassCopy",
  365. smalltalk.method({
  366. selector: "testClassCopy",
  367. category: 'running',
  368. fn: function (){
  369. var self=this;
  370. (self['@theClass']=smalltalk.send(self['@builder'], "_copyClass_named_", [(smalltalk.ObjectMock || ObjectMock), "ObjectMock2"]));
  371. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@theClass'], "_superclass", []), "__eq_eq", [smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_superclass", [])])]);
  372. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@theClass'], "_instanceVariableNames", []), "__eq_eq", [smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_instanceVariableNames", [])])]);
  373. smalltalk.send(self, "_assert_equals_", [smalltalk.send(self['@theClass'], "_name", []), "ObjectMock2"]);
  374. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@theClass'], "_package", []), "__eq_eq", [smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_package", [])])]);
  375. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self['@theClass'], "_methodDictionary", []), "_keys", []), smalltalk.send(smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_methodDictionary", []), "_keys", [])]);
  376. return self;},
  377. args: [],
  378. 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",
  379. messageSends: ["copyClass:named:", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary"],
  380. referencedClasses: ["ObjectMock"]
  381. }),
  382. smalltalk.ClassBuilderTest);
  383. smalltalk.addMethod(
  384. "_testInstanceVariableNames",
  385. smalltalk.method({
  386. selector: "testInstanceVariableNames",
  387. category: 'running',
  388. fn: function (){
  389. var self=this;
  390. smalltalk.send(self, "_assert_equals_", [smalltalk.send(self['@builder'], "_instanceVariableNamesFor_", [" hello world "]), ["hello", "world"]]);
  391. return self;},
  392. args: [],
  393. source: "testInstanceVariableNames\x0a\x09self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')",
  394. messageSends: ["assert:equals:", "instanceVariableNamesFor:"],
  395. referencedClasses: []
  396. }),
  397. smalltalk.ClassBuilderTest);
  398. smalltalk.addClass('CollectionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  399. smalltalk.addMethod(
  400. "_assertSameContents_as_",
  401. smalltalk.method({
  402. selector: "assertSameContents:as:",
  403. category: 'convenience',
  404. fn: function (aCollection, anotherCollection){
  405. var self=this;
  406. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(aCollection, "_size", []), "__eq", [smalltalk.send(anotherCollection, "_size", [])])]);
  407. smalltalk.send(aCollection, "_do_", [(function(each){return smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(aCollection, "_occurrencesOf_", [each]), "__eq", [smalltalk.send(anotherCollection, "_occurrencesOf_", [each])])]);})]);
  408. return self;},
  409. args: ["aCollection", "anotherCollection"],
  410. source: "assertSameContents: aCollection \x09as: anotherCollection\x0a\x09self assert: aCollection size = anotherCollection size.\x0a\x09aCollection do: [ :each |\x0a\x09\x09self assert: (aCollection occurrencesOf: each) = (anotherCollection occurrencesOf: each) ]",
  411. messageSends: ["assert:", "=", "size", "do:", "occurrencesOf:"],
  412. referencedClasses: []
  413. }),
  414. smalltalk.CollectionTest);
  415. smalltalk.addMethod(
  416. "_collection",
  417. smalltalk.method({
  418. selector: "collection",
  419. category: 'accessing',
  420. fn: function (){
  421. var self=this;
  422. return smalltalk.send(smalltalk.send(self, "_collectionClass", []), "_withAll_", [smalltalk.send(self, "_defaultValues", [])]);
  423. return self;},
  424. args: [],
  425. source: "collection\x0a\x09^ self collectionClass withAll: self defaultValues",
  426. messageSends: ["withAll:", "collectionClass", "defaultValues"],
  427. referencedClasses: []
  428. }),
  429. smalltalk.CollectionTest);
  430. smalltalk.addMethod(
  431. "_collectionClass",
  432. smalltalk.method({
  433. selector: "collectionClass",
  434. category: 'accessing',
  435. fn: function (){
  436. var self=this;
  437. return smalltalk.send(smalltalk.send(self, "_class", []), "_collectionClass", []);
  438. return self;},
  439. args: [],
  440. source: "collectionClass\x0a\x09^ self class collectionClass",
  441. messageSends: ["collectionClass", "class"],
  442. referencedClasses: []
  443. }),
  444. smalltalk.CollectionTest);
  445. smalltalk.addMethod(
  446. "_collectionWithDuplicates",
  447. smalltalk.method({
  448. selector: "collectionWithDuplicates",
  449. category: 'accessing',
  450. fn: function (){
  451. var self=this;
  452. return smalltalk.send(smalltalk.send(self, "_collectionClass", []), "_withAll_", [["a", "b", "c", (1), (2), (1), "a"]]);
  453. return self;},
  454. args: [],
  455. source: "collectionWithDuplicates\x0a\x09^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')",
  456. messageSends: ["withAll:", "collectionClass"],
  457. referencedClasses: []
  458. }),
  459. smalltalk.CollectionTest);
  460. smalltalk.addMethod(
  461. "_defaultValues",
  462. smalltalk.method({
  463. selector: "defaultValues",
  464. category: 'accessing',
  465. fn: function (){
  466. var self=this;
  467. return [(1), (2), (3), (-4)];
  468. return self;},
  469. args: [],
  470. source: "defaultValues\x0a\x09^ #(1 2 3 -4)",
  471. messageSends: [],
  472. referencedClasses: []
  473. }),
  474. smalltalk.CollectionTest);
  475. smalltalk.addMethod(
  476. "_isCollectionReadOnly",
  477. smalltalk.method({
  478. selector: "isCollectionReadOnly",
  479. category: 'testing',
  480. fn: function (){
  481. var self=this;
  482. return false;
  483. return self;},
  484. args: [],
  485. source: "isCollectionReadOnly\x0a\x09^ false",
  486. messageSends: [],
  487. referencedClasses: []
  488. }),
  489. smalltalk.CollectionTest);
  490. smalltalk.addMethod(
  491. "_testAsArray",
  492. smalltalk.method({
  493. selector: "testAsArray",
  494. category: 'tests',
  495. fn: function (){
  496. var self=this;
  497. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(self, "_collection", []), smalltalk.send(smalltalk.send(self, "_collection", []), "_asArray", [])]);
  498. return self;},
  499. args: [],
  500. source: "testAsArray\x0a\x09self \x0a\x09\x09assertSameContents: self collection \x0a\x09\x09as: self collection asArray",
  501. messageSends: ["assertSameContents:as:", "collection", "asArray"],
  502. referencedClasses: []
  503. }),
  504. smalltalk.CollectionTest);
  505. smalltalk.addMethod(
  506. "_testAsOrderedCollection",
  507. smalltalk.method({
  508. selector: "testAsOrderedCollection",
  509. category: 'tests',
  510. fn: function (){
  511. var self=this;
  512. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(self, "_collection", []), smalltalk.send(smalltalk.send(self, "_collection", []), "_asOrderedCollection", [])]);
  513. return self;},
  514. args: [],
  515. source: "testAsOrderedCollection\x0a\x09self \x0a\x09\x09assertSameContents: self collection \x0a\x09\x09as: self collection asOrderedCollection",
  516. messageSends: ["assertSameContents:as:", "collection", "asOrderedCollection"],
  517. referencedClasses: []
  518. }),
  519. smalltalk.CollectionTest);
  520. smalltalk.addMethod(
  521. "_testAsSet",
  522. smalltalk.method({
  523. selector: "testAsSet",
  524. category: 'tests',
  525. fn: function (){
  526. var self=this;
  527. var c=nil;
  528. var set=nil;
  529. (c=smalltalk.send(self, "_collectionWithDuplicates", []));
  530. (set=smalltalk.send(c, "_asSet", []));
  531. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [(5)])]);
  532. smalltalk.send(c, "_do_", [(function(each){return smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [each])]);})]);
  533. return self;},
  534. args: [],
  535. source: "testAsSet\x0a\x09| c set |\x0a\x09c := self collectionWithDuplicates.\x0a\x09set := c asSet.\x0a\x09self assert: set size = 5.\x0a\x09c do: [ :each |\x0a\x09\x09self assert: (set includes: each) ]",
  536. messageSends: ["collectionWithDuplicates", "asSet", "assert:", "=", "size", "do:", "includes:"],
  537. referencedClasses: []
  538. }),
  539. smalltalk.CollectionTest);
  540. smalltalk.addMethod(
  541. "_testCollect",
  542. smalltalk.method({
  543. selector: "testCollect",
  544. category: 'tests',
  545. fn: function (){
  546. var self=this;
  547. var newCollection=nil;
  548. (newCollection=[(1), (2), (3), (4)]);
  549. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_collect_", [(function(each){return smalltalk.send(each, "_abs", []);})]), newCollection]);
  550. return self;},
  551. args: [],
  552. source: "testCollect\x0a\x09| newCollection |\x0a\x09newCollection := #(1 2 3 4).\x0a\x09self \x0a\x09\x09assertSameContents: (self collection collect: [ :each |\x0a\x09\x09\x09each abs ])\x0a\x09\x09as: newCollection",
  553. messageSends: ["assertSameContents:as:", "collect:", "collection", "abs"],
  554. referencedClasses: []
  555. }),
  556. smalltalk.CollectionTest);
  557. smalltalk.addMethod(
  558. "_testDetect",
  559. smalltalk.method({
  560. selector: "testDetect",
  561. category: 'tests',
  562. fn: function (){
  563. var self=this;
  564. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_collection", []), "_detect_", [(function(each){return ((($receiver = each).klass === smalltalk.Number) ? $receiver <(0) : smalltalk.send($receiver, "__lt", [(0)]));})]), "__eq", [(-4)])]);
  565. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send(self, "_collection", []), "_detect_", [(function(each){return smalltalk.send(each, "__eq", [(6)]);})]);}), (smalltalk.Error || Error)]);
  566. return self;},
  567. args: [],
  568. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each < 0 ]) = -4.\x0a\x09self \x0a\x09\x09should: [ self collection detect: [ :each | each = 6 ] ]\x0a\x09\x09raise: Error",
  569. messageSends: ["assert:", "=", "detect:", "collection", "<", "should:raise:"],
  570. referencedClasses: ["Error"]
  571. }),
  572. smalltalk.CollectionTest);
  573. smalltalk.addMethod(
  574. "_testDo",
  575. smalltalk.method({
  576. selector: "testDo",
  577. category: 'tests',
  578. fn: function (){
  579. var self=this;
  580. var newCollection=nil;
  581. (newCollection=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection), "_new", []));
  582. smalltalk.send(smalltalk.send(self, "_collection", []), "_do_", [(function(each){return smalltalk.send(newCollection, "_add_", [each]);})]);
  583. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(self, "_collection", []), newCollection]);
  584. return self;},
  585. args: [],
  586. source: "testDo\x0a\x09| newCollection |\x0a\x09newCollection := OrderedCollection new.\x0a\x09self collection do: [ :each |\x0a\x09\x09newCollection add: each ].\x0a\x09self \x0a\x09\x09assertSameContents: self collection \x0a\x09\x09as: newCollection",
  587. messageSends: ["new", "do:", "collection", "add:", "assertSameContents:as:"],
  588. referencedClasses: ["OrderedCollection"]
  589. }),
  590. smalltalk.CollectionTest);
  591. smalltalk.addMethod(
  592. "_testIsEmpty",
  593. smalltalk.method({
  594. selector: "testIsEmpty",
  595. category: 'tests',
  596. fn: function (){
  597. var self=this;
  598. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_collectionClass", []), "_new", []), "_isEmpty", [])]);
  599. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_isEmpty", [])]);
  600. return self;},
  601. args: [],
  602. source: "testIsEmpty\x0a\x09self assert: self collectionClass new isEmpty.\x0a\x09self deny: self collection isEmpty",
  603. messageSends: ["assert:", "isEmpty", "new", "collectionClass", "deny:", "collection"],
  604. referencedClasses: []
  605. }),
  606. smalltalk.CollectionTest);
  607. smalltalk.addMethod(
  608. "_testSelect",
  609. smalltalk.method({
  610. selector: "testSelect",
  611. category: 'tests',
  612. fn: function (){
  613. var self=this;
  614. var newCollection=nil;
  615. (newCollection=[(2), (-4)]);
  616. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_select_", [(function(each){return smalltalk.send(each, "_even", []);})]), newCollection]);
  617. return self;},
  618. args: [],
  619. source: "testSelect\x0a\x09| newCollection |\x0a\x09newCollection := #(2 -4).\x0a\x09self \x0a\x09\x09assertSameContents: (self collection select: [ :each |\x0a\x09\x09\x09each even ])\x0a\x09\x09as: newCollection",
  620. messageSends: ["assertSameContents:as:", "select:", "collection", "even"],
  621. referencedClasses: []
  622. }),
  623. smalltalk.CollectionTest);
  624. smalltalk.addMethod(
  625. "_testSize",
  626. smalltalk.method({
  627. selector: "testSize",
  628. category: 'tests',
  629. fn: function (){
  630. var self=this;
  631. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_collectionClass", []), "_new", []), "_size", []), "__eq", [(0)])]);
  632. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_collection", []), "_size", []), "__eq", [(4)])]);
  633. return self;},
  634. args: [],
  635. source: "testSize\x0a\x09self assert: self collectionClass new size = 0.\x0a\x09self assert: self collection size = 4",
  636. messageSends: ["assert:", "=", "size", "new", "collectionClass", "collection"],
  637. referencedClasses: []
  638. }),
  639. smalltalk.CollectionTest);
  640. smalltalk.addMethod(
  641. "_collectionClass",
  642. smalltalk.method({
  643. selector: "collectionClass",
  644. category: 'accessing',
  645. fn: function (){
  646. var self=this;
  647. return nil;
  648. return self;},
  649. args: [],
  650. source: "collectionClass\x0a\x09^ nil",
  651. messageSends: [],
  652. referencedClasses: []
  653. }),
  654. smalltalk.CollectionTest.klass);
  655. smalltalk.addMethod(
  656. "_isAbstract",
  657. smalltalk.method({
  658. selector: "isAbstract",
  659. category: 'testing',
  660. fn: function (){
  661. var self=this;
  662. return smalltalk.send(smalltalk.send(self, "_collectionClass", []), "_isNil", []);
  663. return self;},
  664. args: [],
  665. source: "isAbstract\x0a\x09^ self collectionClass isNil",
  666. messageSends: ["isNil", "collectionClass"],
  667. referencedClasses: []
  668. }),
  669. smalltalk.CollectionTest.klass);
  670. smalltalk.addClass('HashedCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
  671. smalltalk.addMethod(
  672. "_collection",
  673. smalltalk.method({
  674. selector: "collection",
  675. category: 'accessing',
  676. fn: function (){
  677. var self=this;
  678. return smalltalk.HashedCollection._fromPairs_([smalltalk.send("a", "__minus_gt", [(1)]),smalltalk.send("b", "__minus_gt", [(2)]),smalltalk.send("c", "__minus_gt", [(3)]),smalltalk.send("d", "__minus_gt", [(-4)])]);
  679. return self;},
  680. args: [],
  681. source: "collection\x0a\x09^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4 }",
  682. messageSends: ["->"],
  683. referencedClasses: []
  684. }),
  685. smalltalk.HashedCollectionTest);
  686. smalltalk.addMethod(
  687. "_collectionWithDuplicates",
  688. smalltalk.method({
  689. selector: "collectionWithDuplicates",
  690. category: 'accessing',
  691. fn: function (){
  692. var self=this;
  693. return smalltalk.HashedCollection._fromPairs_([smalltalk.send("a", "__minus_gt", [(1)]),smalltalk.send("b", "__minus_gt", [(2)]),smalltalk.send("c", "__minus_gt", [(3)]),smalltalk.send("d", "__minus_gt", [(-4)]),smalltalk.send("e", "__minus_gt", [(1)]),smalltalk.send("f", "__minus_gt", [(2)]),smalltalk.send("g", "__minus_gt", [(10)])]);
  694. return self;},
  695. args: [],
  696. source: "collectionWithDuplicates\x0a\x09^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4. 'e' -> 1. 'f' -> 2. 'g' -> 10 }",
  697. messageSends: ["->"],
  698. referencedClasses: []
  699. }),
  700. smalltalk.HashedCollectionTest);
  701. smalltalk.addMethod(
  702. "_collectionClass",
  703. smalltalk.method({
  704. selector: "collectionClass",
  705. category: 'accessing',
  706. fn: function (){
  707. var self=this;
  708. return (smalltalk.HashedCollection || HashedCollection);
  709. return self;},
  710. args: [],
  711. source: "collectionClass\x0a\x09^ HashedCollection",
  712. messageSends: [],
  713. referencedClasses: ["HashedCollection"]
  714. }),
  715. smalltalk.HashedCollectionTest.klass);
  716. smalltalk.addClass('DictionaryTest', smalltalk.HashedCollectionTest, [], 'Kernel-Tests');
  717. smalltalk.addMethod(
  718. "_collection",
  719. smalltalk.method({
  720. selector: "collection",
  721. category: 'accessing',
  722. fn: function (){
  723. var self=this;
  724. return (function($rec){smalltalk.send($rec, "_at_put_", [(1), (1)]);smalltalk.send($rec, "_at_put_", ["a", (2)]);smalltalk.send($rec, "_at_put_", [true, (3)]);smalltalk.send($rec, "_at_put_", [(4), (-4)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  725. return self;},
  726. args: [],
  727. source: "collection\x0a\x09^ Dictionary new\x0a\x09\x09at: 1 put: 1;\x0a\x09\x09at: 'a' put: 2;\x0a\x09\x09at: true put: 3;\x0a\x09\x09at: 4 put: -4;\x0a\x09\x09yourself",
  728. messageSends: ["at:put:", "yourself", "new"],
  729. referencedClasses: ["Dictionary"]
  730. }),
  731. smalltalk.DictionaryTest);
  732. smalltalk.addMethod(
  733. "_collectionWithDuplicates",
  734. smalltalk.method({
  735. selector: "collectionWithDuplicates",
  736. category: 'accessing',
  737. fn: function (){
  738. var self=this;
  739. return (function($rec){smalltalk.send($rec, "_at_put_", [(1), (1)]);smalltalk.send($rec, "_at_put_", ["a", (2)]);smalltalk.send($rec, "_at_put_", [true, (3)]);smalltalk.send($rec, "_at_put_", [(4), (-4)]);smalltalk.send($rec, "_at_put_", ["b", (1)]);smalltalk.send($rec, "_at_put_", [(3), (3)]);smalltalk.send($rec, "_at_put_", [false, (12)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  740. return self;},
  741. args: [],
  742. source: "collectionWithDuplicates\x0a\x09^ Dictionary new\x0a\x09\x09at: 1 put: 1;\x0a\x09\x09at: 'a' put: 2;\x0a\x09\x09at: true put: 3;\x0a\x09\x09at: 4 put: -4;\x0a\x09\x09at: 'b' put: 1;\x0a\x09\x09at: 3 put: 3;\x0a\x09\x09at: false put: 12;\x0a\x09\x09yourself",
  743. messageSends: ["at:put:", "yourself", "new"],
  744. referencedClasses: ["Dictionary"]
  745. }),
  746. smalltalk.DictionaryTest);
  747. smalltalk.addMethod(
  748. "_testAccessing",
  749. smalltalk.method({
  750. selector: "testAccessing",
  751. category: 'tests',
  752. fn: function (){
  753. var self=this;
  754. var d=nil;
  755. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  756. smalltalk.send(d, "_at_put_", ["hello", "world"]);
  757. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", ["hello"]), "__eq", ["world"])]);
  758. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_ifAbsent_", ["hello", (function(){return nil;})]), "__eq", ["world"])]);
  759. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(d, "_at_ifAbsent_", ["foo", (function(){return nil;})]), "__eq", ["world"])]);
  760. smalltalk.send(d, "_at_put_", [(1), (2)]);
  761. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", [(1)]), "__eq", [(2)])]);
  762. smalltalk.send(d, "_at_put_", [smalltalk.send((1), "__at", [(3)]), (3)]);
  763. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", [smalltalk.send((1), "__at", [(3)])]), "__eq", [(3)])]);
  764. return self;},
  765. args: [],
  766. 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",
  767. messageSends: ["new", "at:put:", "assert:", "=", "at:", "at:ifAbsent:", "deny:", "@"],
  768. referencedClasses: ["Dictionary"]
  769. }),
  770. smalltalk.DictionaryTest);
  771. smalltalk.addMethod(
  772. "_testDynamicDictionaries",
  773. smalltalk.method({
  774. selector: "testDynamicDictionaries",
  775. category: 'tests',
  776. fn: function (){
  777. var self=this;
  778. 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)])])])]);
  779. return self;},
  780. args: [],
  781. source: "testDynamicDictionaries\x0a\x09self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)",
  782. messageSends: ["assert:", "=", "asDictionary", "->", "with:"],
  783. referencedClasses: ["Dictionary"]
  784. }),
  785. smalltalk.DictionaryTest);
  786. smalltalk.addMethod(
  787. "_testEquality",
  788. smalltalk.method({
  789. selector: "testEquality",
  790. category: 'tests',
  791. fn: function (){
  792. var self=this;
  793. var d1=nil;
  794. var d2=nil;
  795. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []), "__eq", [smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])])]);
  796. (d1=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  797. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  798. smalltalk.send(self, "_assert_", [smalltalk.send(d1, "__eq", [d2])]);
  799. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (3)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  800. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  801. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(2), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  802. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  803. (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", [])));
  804. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  805. return self;},
  806. args: [],
  807. 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.",
  808. messageSends: ["assert:", "=", "new", "at:put:", "yourself", "deny:"],
  809. referencedClasses: ["Dictionary"]
  810. }),
  811. smalltalk.DictionaryTest);
  812. smalltalk.addMethod(
  813. "_testIfAbsent",
  814. smalltalk.method({
  815. selector: "testIfAbsent",
  816. category: 'tests',
  817. fn: function (){
  818. var self=this;
  819. var d=nil;
  820. var visited=nil;
  821. (visited=false);
  822. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  823. smalltalk.send(d, "_at_ifAbsent_", ["hello", (function(){return (visited=true);})]);
  824. smalltalk.send(self, "_assert_", [visited]);
  825. return self;},
  826. args: [],
  827. 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.",
  828. messageSends: ["new", "at:ifAbsent:", "assert:"],
  829. referencedClasses: ["Dictionary"]
  830. }),
  831. smalltalk.DictionaryTest);
  832. smalltalk.addMethod(
  833. "_testIfPresent",
  834. smalltalk.method({
  835. selector: "testIfPresent",
  836. category: 'tests',
  837. fn: function (){
  838. var self=this;
  839. var d=nil;
  840. var visited=nil;
  841. var absent=nil;
  842. (visited=false);
  843. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  844. smalltalk.send(d, "_at_put_", ["hello", "world"]);
  845. smalltalk.send(d, "_at_ifPresent_", ["hello", (function(value){return (visited=value);})]);
  846. smalltalk.send(self, "_assert_", [smalltalk.send(visited, "__eq", ["world"])]);
  847. (absent=smalltalk.send(d, "_at_ifPresent_", ["bye", (function(value){return (visited=value);})]));
  848. smalltalk.send(self, "_assert_", [smalltalk.send(absent, "_isNil", [])]);
  849. return self;},
  850. args: [],
  851. 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.",
  852. messageSends: ["new", "at:put:", "at:ifPresent:", "assert:", "=", "isNil"],
  853. referencedClasses: ["Dictionary"]
  854. }),
  855. smalltalk.DictionaryTest);
  856. smalltalk.addMethod(
  857. "_testIfPresentIfAbsent",
  858. smalltalk.method({
  859. selector: "testIfPresentIfAbsent",
  860. category: 'tests',
  861. fn: function (){
  862. var self=this;
  863. var d=nil;
  864. var visited=nil;
  865. (visited=false);
  866. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  867. smalltalk.send(d, "_at_put_", ["hello", "world"]);
  868. smalltalk.send(d, "_at_ifPresent_ifAbsent_", ["hello", (function(value){return (visited=value);}), (function(){return (visited=true);})]);
  869. smalltalk.send(self, "_assert_", [smalltalk.send(visited, "__eq", ["world"])]);
  870. smalltalk.send(d, "_at_ifPresent_ifAbsent_", ["buy", (function(value){return (visited=value);}), (function(){return (visited=true);})]);
  871. smalltalk.send(self, "_assert_", [visited]);
  872. return self;},
  873. args: [],
  874. 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.",
  875. messageSends: ["new", "at:put:", "at:ifPresent:ifAbsent:", "assert:", "="],
  876. referencedClasses: ["Dictionary"]
  877. }),
  878. smalltalk.DictionaryTest);
  879. smalltalk.addMethod(
  880. "_testKeys",
  881. smalltalk.method({
  882. selector: "testKeys",
  883. category: 'tests',
  884. fn: function (){
  885. var self=this;
  886. var d=nil;
  887. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  888. smalltalk.send(d, "_at_put_", [(1), (2)]);
  889. smalltalk.send(d, "_at_put_", [(2), (3)]);
  890. smalltalk.send(d, "_at_put_", [(3), (4)]);
  891. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (2), (3)]])]);
  892. return self;},
  893. args: [],
  894. 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)",
  895. messageSends: ["new", "at:put:", "assert:", "=", "keys"],
  896. referencedClasses: ["Dictionary"]
  897. }),
  898. smalltalk.DictionaryTest);
  899. smalltalk.addMethod(
  900. "_testPrintString",
  901. smalltalk.method({
  902. selector: "testPrintString",
  903. category: 'tests',
  904. fn: function (){
  905. var self=this;
  906. 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", []))]);
  907. return self;},
  908. args: [],
  909. 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)",
  910. messageSends: ["assert:equals:", "at:put:", "printString", "new"],
  911. referencedClasses: ["Dictionary"]
  912. }),
  913. smalltalk.DictionaryTest);
  914. smalltalk.addMethod(
  915. "_testRemoveKey",
  916. smalltalk.method({
  917. selector: "testRemoveKey",
  918. category: 'tests',
  919. fn: function (){
  920. var self=this;
  921. var d=nil;
  922. var key=nil;
  923. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  924. smalltalk.send(d, "_at_put_", [(1), (2)]);
  925. smalltalk.send(d, "_at_put_", [(2), (3)]);
  926. smalltalk.send(d, "_at_put_", [(3), (4)]);
  927. (key=(2));
  928. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (2), (3)]])]);
  929. smalltalk.send(d, "_removeKey_", [key]);
  930. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (3)]])]);
  931. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_values", []), "__eq", [[(2), (4)]])]);
  932. smalltalk.send(self, "_deny_", [smalltalk.send(d, "_includesKey_", [(2)])]);
  933. return self;},
  934. args: [],
  935. 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)",
  936. messageSends: ["new", "at:put:", "assert:", "=", "keys", "removeKey:", "values", "deny:", "includesKey:"],
  937. referencedClasses: ["Dictionary"]
  938. }),
  939. smalltalk.DictionaryTest);
  940. smalltalk.addMethod(
  941. "_testRemoveKeyIfAbsent",
  942. smalltalk.method({
  943. selector: "testRemoveKeyIfAbsent",
  944. category: 'tests',
  945. fn: function (){
  946. var self=this;
  947. var d=nil;
  948. var key=nil;
  949. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  950. smalltalk.send(d, "_at_put_", [(1), (2)]);
  951. smalltalk.send(d, "_at_put_", [(2), (3)]);
  952. smalltalk.send(d, "_at_put_", [(3), (4)]);
  953. (key=(2));
  954. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_", [key]), "__eq", [(3)])]);
  955. (key=(3));
  956. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_ifAbsent_", [key, (function(){return (42);})]), "__eq", [(4)])]);
  957. (key="why");
  958. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_ifAbsent_", [key, (function(){return (42);})]), "__eq", [(42)])]);
  959. return self;},
  960. args: [],
  961. 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.",
  962. messageSends: ["new", "at:put:", "assert:", "=", "removeKey:", "removeKey:ifAbsent:"],
  963. referencedClasses: ["Dictionary"]
  964. }),
  965. smalltalk.DictionaryTest);
  966. smalltalk.addMethod(
  967. "_testSize",
  968. smalltalk.method({
  969. selector: "testSize",
  970. category: 'tests',
  971. fn: function (){
  972. var self=this;
  973. var d=nil;
  974. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  975. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(0)])]);
  976. smalltalk.send(d, "_at_put_", [(1), (2)]);
  977. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(1)])]);
  978. smalltalk.send(d, "_at_put_", [(2), (3)]);
  979. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(2)])]);
  980. return self;},
  981. args: [],
  982. 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.",
  983. messageSends: ["new", "assert:", "=", "size", "at:put:"],
  984. referencedClasses: ["Dictionary"]
  985. }),
  986. smalltalk.DictionaryTest);
  987. smalltalk.addMethod(
  988. "_testValues",
  989. smalltalk.method({
  990. selector: "testValues",
  991. category: 'tests',
  992. fn: function (){
  993. var self=this;
  994. var d=nil;
  995. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  996. smalltalk.send(d, "_at_put_", [(1), (2)]);
  997. smalltalk.send(d, "_at_put_", [(2), (3)]);
  998. smalltalk.send(d, "_at_put_", [(3), (4)]);
  999. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_values", []), "__eq", [[(2), (3), (4)]])]);
  1000. return self;},
  1001. args: [],
  1002. 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)",
  1003. messageSends: ["new", "at:put:", "assert:", "=", "values"],
  1004. referencedClasses: ["Dictionary"]
  1005. }),
  1006. smalltalk.DictionaryTest);
  1007. smalltalk.addMethod(
  1008. "_collectionClass",
  1009. smalltalk.method({
  1010. selector: "collectionClass",
  1011. category: 'accessing',
  1012. fn: function (){
  1013. var self=this;
  1014. return (smalltalk.Dictionary || Dictionary);
  1015. return self;},
  1016. args: [],
  1017. source: "collectionClass\x0a\x09^ Dictionary",
  1018. messageSends: [],
  1019. referencedClasses: ["Dictionary"]
  1020. }),
  1021. smalltalk.DictionaryTest.klass);
  1022. smalltalk.addClass('SequenceableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
  1023. smalltalk.addMethod(
  1024. "_testAt",
  1025. smalltalk.method({
  1026. selector: "testAt",
  1027. category: 'tests',
  1028. fn: function (){
  1029. var self=this;
  1030. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_collection", []), "_at_", [(4)]), "__eq", [(-4)])]);
  1031. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send(self, "_collection", []), "_at_", [(5)]);}), (smalltalk.Error || Error)]);
  1032. return self;},
  1033. args: [],
  1034. source: "testAt\x0a\x09self assert: (self collection at: 4) = -4.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
  1035. messageSends: ["assert:", "=", "at:", "collection", "should:raise:"],
  1036. referencedClasses: ["Error"]
  1037. }),
  1038. smalltalk.SequenceableCollectionTest);
  1039. smalltalk.addMethod(
  1040. "_testAtIfAbsent",
  1041. smalltalk.method({
  1042. selector: "testAtIfAbsent",
  1043. category: 'tests',
  1044. fn: function (){
  1045. var self=this;
  1046. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_collection", []), "_at_ifAbsent_", [((($receiver = smalltalk.send(smalltalk.send(self, "_collection", []), "_size", [])).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])), (function(){return "none";})]), "__eq", ["none"])]);
  1047. return self;},
  1048. args: [],
  1049. source: "testAtIfAbsent\x0a\x09self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) = 'none'",
  1050. messageSends: ["assert:", "=", "at:ifAbsent:", "collection", "+", "size"],
  1051. referencedClasses: []
  1052. }),
  1053. smalltalk.SequenceableCollectionTest);
  1054. smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1055. smalltalk.addMethod(
  1056. "_testAtIfAbsent",
  1057. smalltalk.method({
  1058. selector: "testAtIfAbsent",
  1059. category: 'testing',
  1060. fn: function (){
  1061. var self=this;
  1062. var array=nil;
  1063. (array=["hello", "world"]);
  1064. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_", [(1)]), "hello"]);
  1065. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_", [(2)]), "world"]);
  1066. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(2), (function(){return "not found";})]), "world"]);
  1067. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(0), (function(){return "not found";})]), "not found"]);
  1068. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(-10), (function(){return "not found";})]), "not found"]);
  1069. smalltalk.send(self, "_assert_equals_", [smalltalk.send(array, "_at_ifAbsent_", [(3), (function(){return "not found";})]), "not found"]);
  1070. return self;},
  1071. args: [],
  1072. 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'.",
  1073. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  1074. referencedClasses: []
  1075. }),
  1076. smalltalk.ArrayTest);
  1077. smalltalk.addMethod(
  1078. "_testFirstN",
  1079. smalltalk.method({
  1080. selector: "testFirstN",
  1081. category: 'testing',
  1082. fn: function (){
  1083. var self=this;
  1084. smalltalk.send(self, "_assert_equals_", [[(1),(2),(3)], smalltalk.send([(1),(2),(3),(4),(5)], "_first_", [(3)])]);
  1085. return self;},
  1086. args: [],
  1087. source: "testFirstN\x0a\x09self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).",
  1088. messageSends: ["assert:equals:", "first:"],
  1089. referencedClasses: []
  1090. }),
  1091. smalltalk.ArrayTest);
  1092. smalltalk.addMethod(
  1093. "_testIfEmpty",
  1094. smalltalk.method({
  1095. selector: "testIfEmpty",
  1096. category: 'testing',
  1097. fn: function (){
  1098. var self=this;
  1099. smalltalk.send(self, "_assert_equals_", ["zork", smalltalk.send("", "_ifEmpty_", [(function(){return "zork";})])]);
  1100. return self;},
  1101. args: [],
  1102. source: "testIfEmpty\x0a\x09self assert: 'zork' equals: ( '' ifEmpty: ['zork'] )",
  1103. messageSends: ["assert:equals:", "ifEmpty:"],
  1104. referencedClasses: []
  1105. }),
  1106. smalltalk.ArrayTest);
  1107. smalltalk.addMethod(
  1108. "_testPrintString",
  1109. smalltalk.method({
  1110. selector: "testPrintString",
  1111. category: 'testing',
  1112. fn: function (){
  1113. var self=this;
  1114. var array=nil;
  1115. (array=smalltalk.send((smalltalk.Array || Array), "_new", []));
  1116. smalltalk.send(self, "_assert_equals_", ["a Array ()", smalltalk.send(array, "_printString", [])]);
  1117. (function($rec){smalltalk.send($rec, "_add_", [(1)]);return smalltalk.send($rec, "_add_", [(3)]);})(array);
  1118. smalltalk.send(self, "_assert_equals_", ["a Array (1 3)", smalltalk.send(array, "_printString", [])]);
  1119. smalltalk.send(array, "_add_", ["foo"]);
  1120. smalltalk.send(self, "_assert_equals_", ["a Array (1 3 'foo')", smalltalk.send(array, "_printString", [])]);
  1121. (function($rec){smalltalk.send($rec, "_remove_", [(1)]);return smalltalk.send($rec, "_remove_", [(3)]);})(array);
  1122. smalltalk.send(self, "_assert_equals_", ["a Array ('foo')", smalltalk.send(array, "_printString", [])]);
  1123. smalltalk.send(array, "_addLast_", [(3)]);
  1124. smalltalk.send(self, "_assert_equals_", ["a Array ('foo' 3)", smalltalk.send(array, "_printString", [])]);
  1125. smalltalk.send(array, "_addLast_", [(3)]);
  1126. smalltalk.send(self, "_assert_equals_", ["a Array ('foo' 3 3)", smalltalk.send(array, "_printString", [])]);
  1127. return self;},
  1128. args: [],
  1129. 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 ).",
  1130. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:", "addLast:"],
  1131. referencedClasses: ["Array"]
  1132. }),
  1133. smalltalk.ArrayTest);
  1134. smalltalk.addMethod(
  1135. "_collectionClass",
  1136. smalltalk.method({
  1137. selector: "collectionClass",
  1138. category: 'accessing',
  1139. fn: function (){
  1140. var self=this;
  1141. return (smalltalk.Array || Array);
  1142. return self;},
  1143. args: [],
  1144. source: "collectionClass\x0a\x09^ Array",
  1145. messageSends: [],
  1146. referencedClasses: ["Array"]
  1147. }),
  1148. smalltalk.ArrayTest.klass);
  1149. smalltalk.addClass('StringTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1150. smalltalk.addMethod(
  1151. "_collection",
  1152. smalltalk.method({
  1153. selector: "collection",
  1154. category: 'accessing',
  1155. fn: function (){
  1156. var self=this;
  1157. return "hello";
  1158. return self;},
  1159. args: [],
  1160. source: "collection\x0a\x09^'hello'",
  1161. messageSends: [],
  1162. referencedClasses: []
  1163. }),
  1164. smalltalk.StringTest);
  1165. smalltalk.addMethod(
  1166. "_collectionWithDuplicates",
  1167. smalltalk.method({
  1168. selector: "collectionWithDuplicates",
  1169. category: 'accessing',
  1170. fn: function (){
  1171. var self=this;
  1172. return "abbaerte";
  1173. return self;},
  1174. args: [],
  1175. source: "collectionWithDuplicates\x0a\x09^ 'abbaerte'",
  1176. messageSends: [],
  1177. referencedClasses: []
  1178. }),
  1179. smalltalk.StringTest);
  1180. smalltalk.addMethod(
  1181. "_testAddRemove",
  1182. smalltalk.method({
  1183. selector: "testAddRemove",
  1184. category: 'tests',
  1185. fn: function (){
  1186. var self=this;
  1187. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_add_", ["a"]);}), (smalltalk.Error || Error)]);
  1188. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_remove_", ["h"]);}), (smalltalk.Error || Error)]);
  1189. return self;},
  1190. args: [],
  1191. source: "testAddRemove\x0a\x09self should: ['hello' add: 'a'] raise: Error.\x0a\x09self should: ['hello' remove: 'h'] raise: Error",
  1192. messageSends: ["should:raise:", "add:", "remove:"],
  1193. referencedClasses: ["Error"]
  1194. }),
  1195. smalltalk.StringTest);
  1196. smalltalk.addMethod(
  1197. "_testAsArray",
  1198. smalltalk.method({
  1199. selector: "testAsArray",
  1200. category: 'tests',
  1201. fn: function (){
  1202. var self=this;
  1203. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_asArray", []), "__eq", [["h", "e", "l", "l", "o"]])]);
  1204. return self;},
  1205. args: [],
  1206. source: "testAsArray\x0a\x09self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').",
  1207. messageSends: ["assert:", "=", "asArray"],
  1208. referencedClasses: []
  1209. }),
  1210. smalltalk.StringTest);
  1211. smalltalk.addMethod(
  1212. "_testAt",
  1213. smalltalk.method({
  1214. selector: "testAt",
  1215. category: 'tests',
  1216. fn: function (){
  1217. var self=this;
  1218. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_", [(1)]), "__eq", ["h"])]);
  1219. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_", [(5)]), "__eq", ["o"])]);
  1220. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_ifAbsent_", [(6), (function(){return nil;})]), "__eq", [nil])]);
  1221. return self;},
  1222. args: [],
  1223. 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",
  1224. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  1225. referencedClasses: []
  1226. }),
  1227. smalltalk.StringTest);
  1228. smalltalk.addMethod(
  1229. "_testAtPut",
  1230. smalltalk.method({
  1231. selector: "testAtPut",
  1232. category: 'tests',
  1233. fn: function (){
  1234. var self=this;
  1235. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_at_put_", [(1), "a"]);}), (smalltalk.Error || Error)]);
  1236. return self;},
  1237. args: [],
  1238. source: "testAtPut\x0a\x09\x22String instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1239. messageSends: ["should:raise:", "at:put:"],
  1240. referencedClasses: ["Error"]
  1241. }),
  1242. smalltalk.StringTest);
  1243. smalltalk.addMethod(
  1244. "_testCollect",
  1245. smalltalk.method({
  1246. selector: "testCollect",
  1247. category: 'tests',
  1248. fn: function (){
  1249. var self=this;
  1250. var newCollection=nil;
  1251. (newCollection="hheelllloo");
  1252. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_collect_", [(function(each){return smalltalk.send(each, "__comma", [each]);})]), newCollection]);
  1253. return self;},
  1254. args: [],
  1255. source: "testCollect\x0a\x09| newCollection |\x0a\x09newCollection := 'hheelllloo'.\x0a\x09self \x0a\x09\x09assertSameContents: (self collection collect: [ :each |\x0a\x09\x09\x09each, each ])\x0a\x09\x09as: newCollection",
  1256. messageSends: ["assertSameContents:as:", "collect:", "collection", ","],
  1257. referencedClasses: []
  1258. }),
  1259. smalltalk.StringTest);
  1260. smalltalk.addMethod(
  1261. "_testCopyWithoutAll",
  1262. smalltalk.method({
  1263. selector: "testCopyWithoutAll",
  1264. category: 'tests',
  1265. fn: function (){
  1266. var self=this;
  1267. smalltalk.send(self, "_assert_equals_", ["hello world", smalltalk.send("*hello* *world*", "_copyWithoutAll_", ["*"])]);
  1268. return self;},
  1269. args: [],
  1270. source: "testCopyWithoutAll\x0a\x09self \x0a\x09\x09assert: 'hello world' \x0a\x09\x09equals: ('*hello* *world*' copyWithoutAll: '*')",
  1271. messageSends: ["assert:equals:", "copyWithoutAll:"],
  1272. referencedClasses: []
  1273. }),
  1274. smalltalk.StringTest);
  1275. smalltalk.addMethod(
  1276. "_testDetect",
  1277. smalltalk.method({
  1278. selector: "testDetect",
  1279. category: 'tests',
  1280. fn: function (){
  1281. var self=this;
  1282. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_collection", []), "_detect_", [(function(each){return smalltalk.send(each, "__eq", ["h"]);})]), "__eq", ["h"])]);
  1283. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send(self, "_collection", []), "_detect_", [(function(each){return smalltalk.send(each, "__eq", [(6)]);})]);}), (smalltalk.Error || Error)]);
  1284. return self;},
  1285. args: [],
  1286. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.\x0a\x09self \x0a\x09\x09should: [ self collection detect: [ :each | each = 6 ] ]\x0a\x09\x09raise: Error",
  1287. messageSends: ["assert:", "=", "detect:", "collection", "should:raise:"],
  1288. referencedClasses: ["Error"]
  1289. }),
  1290. smalltalk.StringTest);
  1291. smalltalk.addMethod(
  1292. "_testEquality",
  1293. smalltalk.method({
  1294. selector: "testEquality",
  1295. category: 'tests',
  1296. fn: function (){
  1297. var self=this;
  1298. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", ["hello"])]);
  1299. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq", ["world"])]);
  1300. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", [smalltalk.send("hello", "_yourself", [])])]);
  1301. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_yourself", []), "__eq", ["hello"])]);
  1302. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  1303. return self;},
  1304. args: [],
  1305. 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",
  1306. messageSends: ["assert:", "=", "deny:", "yourself"],
  1307. referencedClasses: []
  1308. }),
  1309. smalltalk.StringTest);
  1310. smalltalk.addMethod(
  1311. "_testIdentity",
  1312. smalltalk.method({
  1313. selector: "testIdentity",
  1314. category: 'tests',
  1315. fn: function (){
  1316. var self=this;
  1317. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq_eq", ["hello"])]);
  1318. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq_eq", ["world"])]);
  1319. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq_eq", [smalltalk.send("hello", "_yourself", [])])]);
  1320. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_yourself", []), "__eq_eq", ["hello"])]);
  1321. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq_eq", [(0)])]);
  1322. return self;},
  1323. args: [],
  1324. 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",
  1325. messageSends: ["assert:", "==", "deny:", "yourself"],
  1326. referencedClasses: []
  1327. }),
  1328. smalltalk.StringTest);
  1329. smalltalk.addMethod(
  1330. "_testIncludesSubString",
  1331. smalltalk.method({
  1332. selector: "testIncludesSubString",
  1333. category: 'tests',
  1334. fn: function (){
  1335. var self=this;
  1336. smalltalk.send(self, "_assert_", [smalltalk.send("amber", "_includesSubString_", ["ber"])]);
  1337. smalltalk.send(self, "_deny_", [smalltalk.send("amber", "_includesSubString_", ["zork"])]);
  1338. return self;},
  1339. args: [],
  1340. source: "testIncludesSubString\x0a\x09self assert: ('amber' includesSubString: 'ber').\x0a\x09self deny: ('amber' includesSubString: 'zork').",
  1341. messageSends: ["assert:", "includesSubString:", "deny:"],
  1342. referencedClasses: []
  1343. }),
  1344. smalltalk.StringTest);
  1345. smalltalk.addMethod(
  1346. "_testJoin",
  1347. smalltalk.method({
  1348. selector: "testJoin",
  1349. category: 'tests',
  1350. fn: function (){
  1351. var self=this;
  1352. smalltalk.send(self, "_assert_equals_", ["hello,world", smalltalk.send(",", "_join_", [["hello", "world"]])]);
  1353. return self;},
  1354. args: [],
  1355. source: "testJoin\x0a\x09self assert: 'hello,world' equals: (',' join: #('hello' 'world'))",
  1356. messageSends: ["assert:equals:", "join:"],
  1357. referencedClasses: []
  1358. }),
  1359. smalltalk.StringTest);
  1360. smalltalk.addMethod(
  1361. "_testSelect",
  1362. smalltalk.method({
  1363. selector: "testSelect",
  1364. category: 'tests',
  1365. fn: function (){
  1366. var self=this;
  1367. var newCollection=nil;
  1368. (newCollection="o");
  1369. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_select_", [(function(each){return smalltalk.send(each, "__eq", ["o"]);})]), newCollection]);
  1370. return self;},
  1371. args: [],
  1372. source: "testSelect\x0a\x09| newCollection |\x0a\x09newCollection := 'o'.\x0a\x09self \x0a\x09\x09assertSameContents: (self collection select: [ :each |\x0a\x09\x09\x09each = 'o' ])\x0a\x09\x09as: newCollection",
  1373. messageSends: ["assertSameContents:as:", "select:", "collection", "="],
  1374. referencedClasses: []
  1375. }),
  1376. smalltalk.StringTest);
  1377. smalltalk.addMethod(
  1378. "_testSize",
  1379. smalltalk.method({
  1380. selector: "testSize",
  1381. category: 'tests',
  1382. fn: function (){
  1383. var self=this;
  1384. smalltalk.send(self, "_assert_equals_", [smalltalk.send("smalltalk", "_size", []), (9)]);
  1385. smalltalk.send(self, "_assert_equals_", [smalltalk.send("", "_size", []), (0)]);
  1386. return self;},
  1387. args: [],
  1388. source: "testSize\x0a\x09self assert: 'smalltalk' size equals: 9.\x0a\x09self assert: '' size equals: 0",
  1389. messageSends: ["assert:equals:", "size"],
  1390. referencedClasses: []
  1391. }),
  1392. smalltalk.StringTest);
  1393. smalltalk.addMethod(
  1394. "_testStreamContents",
  1395. smalltalk.method({
  1396. selector: "testStreamContents",
  1397. category: 'tests',
  1398. fn: function (){
  1399. var self=this;
  1400. 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);})])]);
  1401. return self;},
  1402. args: [],
  1403. source: "testStreamContents\x0a\x09self \x0a\x09\x09assert: 'hello world' \x0a\x09\x09equals: (String streamContents: [ :aStream | \x0a\x09\x09\x09aStream \x0a\x09\x09\x09\x09nextPutAll: 'hello'; space; \x0a\x09\x09\x09\x09nextPutAll: 'world' ])",
  1404. messageSends: ["assert:equals:", "streamContents:", "nextPutAll:", "space"],
  1405. referencedClasses: ["String"]
  1406. }),
  1407. smalltalk.StringTest);
  1408. smalltalk.addMethod(
  1409. "_collectionClass",
  1410. smalltalk.method({
  1411. selector: "collectionClass",
  1412. category: 'accessing',
  1413. fn: function (){
  1414. var self=this;
  1415. return (smalltalk.String || String);
  1416. return self;},
  1417. args: [],
  1418. source: "collectionClass\x0a\x09^ String",
  1419. messageSends: [],
  1420. referencedClasses: ["String"]
  1421. }),
  1422. smalltalk.StringTest.klass);
  1423. smalltalk.addClass('SymbolTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1424. smalltalk.addMethod(
  1425. "_collection",
  1426. smalltalk.method({
  1427. selector: "collection",
  1428. category: 'accessing',
  1429. fn: function (){
  1430. var self=this;
  1431. return smalltalk.symbolFor("hello");
  1432. return self;},
  1433. args: [],
  1434. source: "collection\x0a\x09^ #hello",
  1435. messageSends: [],
  1436. referencedClasses: []
  1437. }),
  1438. smalltalk.SymbolTest);
  1439. smalltalk.addMethod(
  1440. "_collectionWithDuplicates",
  1441. smalltalk.method({
  1442. selector: "collectionWithDuplicates",
  1443. category: 'accessing',
  1444. fn: function (){
  1445. var self=this;
  1446. return smalltalk.symbolFor("phhaaarorra");
  1447. return self;},
  1448. args: [],
  1449. source: "collectionWithDuplicates\x0a\x09^ #phhaaarorra",
  1450. messageSends: [],
  1451. referencedClasses: []
  1452. }),
  1453. smalltalk.SymbolTest);
  1454. smalltalk.addMethod(
  1455. "_testAsString",
  1456. smalltalk.method({
  1457. selector: "testAsString",
  1458. category: 'tests',
  1459. fn: function (){
  1460. var self=this;
  1461. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("hello"), "_asString", []), "hello"]);
  1462. return self;},
  1463. args: [],
  1464. source: "testAsString\x0a\x09self assert: #hello asString equals: 'hello'",
  1465. messageSends: ["assert:equals:", "asString"],
  1466. referencedClasses: []
  1467. }),
  1468. smalltalk.SymbolTest);
  1469. smalltalk.addMethod(
  1470. "_testAsSymbol",
  1471. smalltalk.method({
  1472. selector: "testAsSymbol",
  1473. category: 'tests',
  1474. fn: function (){
  1475. var self=this;
  1476. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_asSymbol", [])])]);
  1477. return self;},
  1478. args: [],
  1479. source: "testAsSymbol\x0a\x09self assert: #hello == #hello asSymbol",
  1480. messageSends: ["assert:", "==", "asSymbol"],
  1481. referencedClasses: []
  1482. }),
  1483. smalltalk.SymbolTest);
  1484. smalltalk.addMethod(
  1485. "_testAt",
  1486. smalltalk.method({
  1487. selector: "testAt",
  1488. category: 'tests',
  1489. fn: function (){
  1490. var self=this;
  1491. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_", [(1)]), "__eq", ["h"])]);
  1492. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_", [(5)]), "__eq", ["o"])]);
  1493. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_ifAbsent_", [(6), (function(){return nil;})]), "__eq", [nil])]);
  1494. return self;},
  1495. args: [],
  1496. 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",
  1497. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  1498. referencedClasses: []
  1499. }),
  1500. smalltalk.SymbolTest);
  1501. smalltalk.addMethod(
  1502. "_testAtPut",
  1503. smalltalk.method({
  1504. selector: "testAtPut",
  1505. category: 'tests',
  1506. fn: function (){
  1507. var self=this;
  1508. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_at_put_", [(1), "a"]);}), (smalltalk.Error || Error)]);
  1509. return self;},
  1510. args: [],
  1511. source: "testAtPut\x0a\x09\x22Symbol instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1512. messageSends: ["should:raise:", "at:put:"],
  1513. referencedClasses: ["Error"]
  1514. }),
  1515. smalltalk.SymbolTest);
  1516. smalltalk.addMethod(
  1517. "_testCollect",
  1518. smalltalk.method({
  1519. selector: "testCollect",
  1520. category: 'tests',
  1521. fn: function (){
  1522. var self=this;
  1523. var newCollection=nil;
  1524. (newCollection=smalltalk.symbolFor("hheelllloo"));
  1525. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_collect_", [(function(each){return smalltalk.send(each, "__comma", [each]);})]), newCollection]);
  1526. return self;},
  1527. args: [],
  1528. source: "testCollect\x0a\x09| newCollection |\x0a\x09newCollection := #hheelllloo.\x0a\x09self \x0a\x09\x09assertSameContents: (self collection collect: [ :each |\x0a\x09\x09\x09each, each ])\x0a\x09\x09as: newCollection",
  1529. messageSends: ["assertSameContents:as:", "collect:", "collection", ","],
  1530. referencedClasses: []
  1531. }),
  1532. smalltalk.SymbolTest);
  1533. smalltalk.addMethod(
  1534. "_testComparing",
  1535. smalltalk.method({
  1536. selector: "testComparing",
  1537. category: 'tests',
  1538. fn: function (){
  1539. var self=this;
  1540. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >smalltalk.symbolFor("aa") : smalltalk.send($receiver, "__gt", [smalltalk.symbolFor("aa")]))]);
  1541. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__gt", [smalltalk.symbolFor("ba")]))]);
  1542. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver <smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt", [smalltalk.symbolFor("ba")]))]);
  1543. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("bb")).klass === smalltalk.Number) ? $receiver <smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt", [smalltalk.symbolFor("ba")]))]);
  1544. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >=smalltalk.symbolFor("aa") : smalltalk.send($receiver, "__gt_eq", [smalltalk.symbolFor("aa")]))]);
  1545. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__gt_eq", [smalltalk.symbolFor("ba")]))]);
  1546. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver <=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt_eq", [smalltalk.symbolFor("ba")]))]);
  1547. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("bb")).klass === smalltalk.Number) ? $receiver <=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt_eq", [smalltalk.symbolFor("ba")]))]);
  1548. return self;},
  1549. args: [],
  1550. 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",
  1551. messageSends: ["assert:", ">", "deny:", "<", ">=", "<="],
  1552. referencedClasses: []
  1553. }),
  1554. smalltalk.SymbolTest);
  1555. smalltalk.addMethod(
  1556. "_testCopying",
  1557. smalltalk.method({
  1558. selector: "testCopying",
  1559. category: 'tests',
  1560. fn: function (){
  1561. var self=this;
  1562. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_copy", []), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  1563. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_deepCopy", []), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  1564. return self;},
  1565. args: [],
  1566. source: "testCopying\x0a\x09self assert: #hello copy == #hello.\x0a\x09self assert: #hello deepCopy == #hello",
  1567. messageSends: ["assert:", "==", "copy", "deepCopy"],
  1568. referencedClasses: []
  1569. }),
  1570. smalltalk.SymbolTest);
  1571. smalltalk.addMethod(
  1572. "_testDetect",
  1573. smalltalk.method({
  1574. selector: "testDetect",
  1575. category: 'tests',
  1576. fn: function (){
  1577. var self=this;
  1578. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_collection", []), "_detect_", [(function(each){return smalltalk.send(each, "__eq", ["h"]);})]), "__eq", ["h"])]);
  1579. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send(self, "_collection", []), "_detect_", [(function(each){return smalltalk.send(each, "__eq", ["z"]);})]);}), (smalltalk.Error || Error)]);
  1580. return self;},
  1581. args: [],
  1582. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.\x0a\x09self \x0a\x09\x09should: [ self collection detect: [ :each | each = 'z' ] ]\x0a\x09\x09raise: Error",
  1583. messageSends: ["assert:", "=", "detect:", "collection", "should:raise:"],
  1584. referencedClasses: ["Error"]
  1585. }),
  1586. smalltalk.SymbolTest);
  1587. smalltalk.addMethod(
  1588. "_testEquality",
  1589. smalltalk.method({
  1590. selector: "testEquality",
  1591. category: 'tests',
  1592. fn: function (){
  1593. var self=this;
  1594. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.symbolFor("hello")])]);
  1595. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.symbolFor("world")])]);
  1596. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", [])])]);
  1597. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", []), "__eq", [smalltalk.symbolFor("hello")])]);
  1598. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", ["hello"])]);
  1599. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq", [smalltalk.symbolFor("hello")])]);
  1600. return self;},
  1601. args: [],
  1602. 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.",
  1603. messageSends: ["assert:", "=", "deny:", "yourself"],
  1604. referencedClasses: []
  1605. }),
  1606. smalltalk.SymbolTest);
  1607. smalltalk.addMethod(
  1608. "_testIdentity",
  1609. smalltalk.method({
  1610. selector: "testIdentity",
  1611. category: 'tests',
  1612. fn: function (){
  1613. var self=this;
  1614. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  1615. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.symbolFor("world")])]);
  1616. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", [])])]);
  1617. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", []), "__eq", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_asString", []), "_asSymbol", [])])]);
  1618. return self;},
  1619. args: [],
  1620. 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",
  1621. messageSends: ["assert:", "==", "deny:", "=", "yourself", "asSymbol", "asString"],
  1622. referencedClasses: []
  1623. }),
  1624. smalltalk.SymbolTest);
  1625. smalltalk.addMethod(
  1626. "_testIsEmpty",
  1627. smalltalk.method({
  1628. selector: "testIsEmpty",
  1629. category: 'tests',
  1630. fn: function (){
  1631. var self=this;
  1632. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_isEmpty", [])]);
  1633. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("", "_asSymbol", []), "_isEmpty", [])]);
  1634. return self;},
  1635. args: [],
  1636. source: "testIsEmpty\x0a\x09self deny: self collection isEmpty.\x0a\x09self assert: '' asSymbol isEmpty",
  1637. messageSends: ["deny:", "isEmpty", "collection", "assert:", "asSymbol"],
  1638. referencedClasses: []
  1639. }),
  1640. smalltalk.SymbolTest);
  1641. smalltalk.addMethod(
  1642. "_testIsSymbolIsString",
  1643. smalltalk.method({
  1644. selector: "testIsSymbolIsString",
  1645. category: 'tests',
  1646. fn: function (){
  1647. var self=this;
  1648. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "_isSymbol", [])]);
  1649. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "_isSymbol", [])]);
  1650. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "_isString", [])]);
  1651. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "_isString", [])]);
  1652. return self;},
  1653. args: [],
  1654. source: "testIsSymbolIsString\x0a\x09self assert: #hello isSymbol.\x0a\x09self deny: 'hello' isSymbol.\x0a\x09self deny: #hello isString.\x0a\x09self assert: 'hello' isString",
  1655. messageSends: ["assert:", "isSymbol", "deny:", "isString"],
  1656. referencedClasses: []
  1657. }),
  1658. smalltalk.SymbolTest);
  1659. smalltalk.addMethod(
  1660. "_testSelect",
  1661. smalltalk.method({
  1662. selector: "testSelect",
  1663. category: 'tests',
  1664. fn: function (){
  1665. var self=this;
  1666. var newCollection=nil;
  1667. (newCollection="o");
  1668. smalltalk.send(self, "_assertSameContents_as_", [smalltalk.send(smalltalk.send(self, "_collection", []), "_select_", [(function(each){return smalltalk.send(each, "__eq", ["o"]);})]), newCollection]);
  1669. return self;},
  1670. args: [],
  1671. source: "testSelect\x0a\x09| newCollection |\x0a\x09newCollection := 'o'.\x0a\x09self \x0a\x09\x09assertSameContents: (self collection select: [ :each |\x0a\x09\x09\x09each = 'o' ])\x0a\x09\x09as: newCollection",
  1672. messageSends: ["assertSameContents:as:", "select:", "collection", "="],
  1673. referencedClasses: []
  1674. }),
  1675. smalltalk.SymbolTest);
  1676. smalltalk.addMethod(
  1677. "_testSize",
  1678. smalltalk.method({
  1679. selector: "testSize",
  1680. category: 'tests',
  1681. fn: function (){
  1682. var self=this;
  1683. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("a"), "_size", []), (1)]);
  1684. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("aaaaa"), "_size", []), (5)]);
  1685. return self;},
  1686. args: [],
  1687. source: "testSize\x0a\x09self assert: #a size equals: 1.\x0a\x09self assert: #aaaaa size equals: 5",
  1688. messageSends: ["assert:equals:", "size"],
  1689. referencedClasses: []
  1690. }),
  1691. smalltalk.SymbolTest);
  1692. smalltalk.addMethod(
  1693. "_collectionClass",
  1694. smalltalk.method({
  1695. selector: "collectionClass",
  1696. category: 'accessing',
  1697. fn: function (){
  1698. var self=this;
  1699. return (smalltalk.Symbol || Symbol);
  1700. return self;},
  1701. args: [],
  1702. source: "collectionClass\x0a\x09^ Symbol",
  1703. messageSends: [],
  1704. referencedClasses: ["Symbol"]
  1705. }),
  1706. smalltalk.SymbolTest.klass);
  1707. smalltalk.addClass('JSObjectProxyTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1708. smalltalk.addMethod(
  1709. "_jsObject",
  1710. smalltalk.method({
  1711. selector: "jsObject",
  1712. category: 'accessing',
  1713. fn: function (){
  1714. var self=this;
  1715. return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null};
  1716. return self;},
  1717. args: [],
  1718. source: "jsObject\x0a\x09<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null}>",
  1719. messageSends: [],
  1720. referencedClasses: []
  1721. }),
  1722. smalltalk.JSObjectProxyTest);
  1723. smalltalk.addMethod(
  1724. "_testDNU",
  1725. smalltalk.method({
  1726. selector: "testDNU",
  1727. category: 'tests',
  1728. fn: function (){
  1729. var self=this;
  1730. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send(self, "_jsObject", []), "_foo", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1731. return self;},
  1732. args: [],
  1733. source: "testDNU\x0a\x09self should: [self jsObject foo] raise: MessageNotUnderstood",
  1734. messageSends: ["should:raise:", "foo", "jsObject"],
  1735. referencedClasses: ["MessageNotUnderstood"]
  1736. }),
  1737. smalltalk.JSObjectProxyTest);
  1738. smalltalk.addMethod(
  1739. "_testMessageSend",
  1740. smalltalk.method({
  1741. selector: "testMessageSend",
  1742. category: 'tests',
  1743. fn: function (){
  1744. var self=this;
  1745. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_a", []), (1)]);
  1746. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_b", []), (2)]);
  1747. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_c_", [(3)]), (3)]);
  1748. return self;},
  1749. args: [],
  1750. 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",
  1751. messageSends: ["assert:equals:", "a", "jsObject", "b", "c:"],
  1752. referencedClasses: []
  1753. }),
  1754. smalltalk.JSObjectProxyTest);
  1755. smalltalk.addMethod(
  1756. "_testMethodWithArguments",
  1757. smalltalk.method({
  1758. selector: "testMethodWithArguments",
  1759. category: 'tests',
  1760. fn: function (){
  1761. var self=this;
  1762. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_c_", [(1)]), (1)]);
  1763. return self;},
  1764. args: [],
  1765. source: "testMethodWithArguments\x0a\x09self assert: (self jsObject c: 1) equals: 1",
  1766. messageSends: ["assert:equals:", "c:", "jsObject"],
  1767. referencedClasses: []
  1768. }),
  1769. smalltalk.JSObjectProxyTest);
  1770. smalltalk.addMethod(
  1771. "_testPrinting",
  1772. smalltalk.method({
  1773. selector: "testPrinting",
  1774. category: 'tests',
  1775. fn: function (){
  1776. var self=this;
  1777. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_jsObject", []), "_printString", []), "__eq", ["[object Object]"])]);
  1778. return self;},
  1779. args: [],
  1780. source: "testPrinting\x0a\x09self assert: self jsObject printString = '[object Object]'",
  1781. messageSends: ["assert:", "=", "printString", "jsObject"],
  1782. referencedClasses: []
  1783. }),
  1784. smalltalk.JSObjectProxyTest);
  1785. smalltalk.addMethod(
  1786. "_testPropertyThatReturnsEmptyString",
  1787. smalltalk.method({
  1788. selector: "testPropertyThatReturnsEmptyString",
  1789. category: 'tests',
  1790. fn: function (){
  1791. var self=this;
  1792. var object=nil;
  1793. (object=smalltalk.send(self, "_jsObject", []));
  1794. smalltalk.send(self, "_assert_equals_", ["", smalltalk.send(object, "_d", [])]);
  1795. smalltalk.send(object, "_d_", ["hello"]);
  1796. smalltalk.send(self, "_assert_equals_", ["hello", smalltalk.send(object, "_d", [])]);
  1797. return self;},
  1798. args: [],
  1799. source: "testPropertyThatReturnsEmptyString\x0a\x09| object |\x0a\x0a\x09object := self jsObject.\x0a\x09self assert: '' equals: object d.\x0a\x0a\x09object d: 'hello'.\x0a\x09self assert: 'hello' equals: object d",
  1800. messageSends: ["jsObject", "assert:equals:", "d", "d:"],
  1801. referencedClasses: []
  1802. }),
  1803. smalltalk.JSObjectProxyTest);
  1804. smalltalk.addMethod(
  1805. "_testPropertyThatReturnsUndefined",
  1806. smalltalk.method({
  1807. selector: "testPropertyThatReturnsUndefined",
  1808. category: 'tests',
  1809. fn: function (){
  1810. var self=this;
  1811. var object=nil;
  1812. (object=smalltalk.send(self, "_jsObject", []));
  1813. smalltalk.send(self, "_shouldnt_raise_", [(function(){return smalltalk.send(object, "_e", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1814. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(object, "_e", []), "_isNil", [])]);
  1815. return self;},
  1816. args: [],
  1817. source: "testPropertyThatReturnsUndefined\x0a\x09| object |\x0a\x0a\x09object := self jsObject.\x0a\x09self shouldnt: [ object e ] raise: MessageNotUnderstood.\x0a self assert: object e isNil",
  1818. messageSends: ["jsObject", "shouldnt:raise:", "e", "assert:", "isNil"],
  1819. referencedClasses: ["MessageNotUnderstood"]
  1820. }),
  1821. smalltalk.JSObjectProxyTest);
  1822. smalltalk.addMethod(
  1823. "_testYourself",
  1824. smalltalk.method({
  1825. selector: "testYourself",
  1826. category: 'tests',
  1827. fn: function (){
  1828. var self=this;
  1829. var object=nil;
  1830. (object=(function($rec){smalltalk.send($rec, "_d_", ["test"]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_jsObject", [])));
  1831. smalltalk.send(self, "_assert_equals_", [smalltalk.send(object, "_d", []), "test"]);
  1832. return self;},
  1833. args: [],
  1834. source: "testYourself\x0a\x09| object |\x0a\x09object := self jsObject\x0a\x09\x09d: 'test';\x0a\x09\x09yourself.\x0a\x0a\x09self assert: object d equals: 'test'",
  1835. messageSends: ["d:", "yourself", "jsObject", "assert:equals:", "d"],
  1836. referencedClasses: []
  1837. }),
  1838. smalltalk.JSObjectProxyTest);
  1839. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1840. smalltalk.addMethod(
  1841. "_testAbs",
  1842. smalltalk.method({
  1843. selector: "testAbs",
  1844. category: 'tests',
  1845. fn: function (){
  1846. var self=this;
  1847. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((4), "_abs", []), "__eq", [(4)])]);
  1848. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((-4), "_abs", []), "__eq", [(4)])]);
  1849. return self;},
  1850. args: [],
  1851. source: "testAbs\x0a\x09self assert: 4 abs = 4.\x0a\x09self assert: -4 abs = 4",
  1852. messageSends: ["assert:", "=", "abs"],
  1853. referencedClasses: []
  1854. }),
  1855. smalltalk.NumberTest);
  1856. smalltalk.addMethod(
  1857. "_testArithmetic",
  1858. smalltalk.method({
  1859. selector: "testArithmetic",
  1860. category: 'tests',
  1861. fn: function (){
  1862. var self=this;
  1863. smalltalk.send(self, "_assert_", [smalltalk.send((1.5) + (1), "__eq", [(2.5)])]);
  1864. smalltalk.send(self, "_assert_", [smalltalk.send((2) - (1), "__eq", [(1)])]);
  1865. smalltalk.send(self, "_assert_", [smalltalk.send((-2) - (1), "__eq", [(-3)])]);
  1866. smalltalk.send(self, "_assert_", [smalltalk.send((12) / (2), "__eq", [(6)])]);
  1867. smalltalk.send(self, "_assert_", [smalltalk.send((3) * (4), "__eq", [(12)])]);
  1868. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = (1) + (2)).klass === smalltalk.Number) ? $receiver *(3) : smalltalk.send($receiver, "__star", [(3)])), "__eq", [(9)])]);
  1869. smalltalk.send(self, "_assert_", [smalltalk.send((1) + (2) * (3), "__eq", [(7)])]);
  1870. return self;},
  1871. args: [],
  1872. 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",
  1873. messageSends: ["assert:", "=", "+", "-", "/", "*"],
  1874. referencedClasses: []
  1875. }),
  1876. smalltalk.NumberTest);
  1877. smalltalk.addMethod(
  1878. "_testComparison",
  1879. smalltalk.method({
  1880. selector: "testComparison",
  1881. category: 'tests',
  1882. fn: function (){
  1883. var self=this;
  1884. smalltalk.send(self, "_assert_", [(3) > (2)]);
  1885. smalltalk.send(self, "_assert_", [(2) < (3)]);
  1886. smalltalk.send(self, "_deny_", [(3) < (2)]);
  1887. smalltalk.send(self, "_deny_", [(2) > (3)]);
  1888. smalltalk.send(self, "_assert_", [(3) >= (3)]);
  1889. smalltalk.send(self, "_assert_", [(3.1) >= (3)]);
  1890. smalltalk.send(self, "_assert_", [(3) <= (3)]);
  1891. smalltalk.send(self, "_assert_", [(3) <= (3.1)]);
  1892. return self;},
  1893. args: [],
  1894. 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",
  1895. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  1896. referencedClasses: []
  1897. }),
  1898. smalltalk.NumberTest);
  1899. smalltalk.addMethod(
  1900. "_testCopying",
  1901. smalltalk.method({
  1902. selector: "testCopying",
  1903. category: 'tests',
  1904. fn: function (){
  1905. var self=this;
  1906. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_copy", []), "__eq_eq", [(1)])]);
  1907. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_deepCopy", []), "__eq_eq", [(1)])]);
  1908. return self;},
  1909. args: [],
  1910. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  1911. messageSends: ["assert:", "==", "copy", "deepCopy"],
  1912. referencedClasses: []
  1913. }),
  1914. smalltalk.NumberTest);
  1915. smalltalk.addMethod(
  1916. "_testEquality",
  1917. smalltalk.method({
  1918. selector: "testEquality",
  1919. category: 'tests',
  1920. fn: function (){
  1921. var self=this;
  1922. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [(1)])]);
  1923. smalltalk.send(self, "_assert_", [smalltalk.send((0), "__eq", [(0)])]);
  1924. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq", [(0)])]);
  1925. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [(1)])]);
  1926. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  1927. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  1928. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [false])]);
  1929. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [(0)])]);
  1930. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  1931. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [""])]);
  1932. return self;},
  1933. args: [],
  1934. 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 = ''",
  1935. messageSends: ["assert:", "=", "deny:", "yourself"],
  1936. referencedClasses: []
  1937. }),
  1938. smalltalk.NumberTest);
  1939. smalltalk.addMethod(
  1940. "_testHexNumbers",
  1941. smalltalk.method({
  1942. selector: "testHexNumbers",
  1943. category: 'tests',
  1944. fn: function (){
  1945. var self=this;
  1946. smalltalk.send(self, "_assert_", [smalltalk.send((9), "__eq", [(9)])]);
  1947. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((10), "_truncated", []), "__eq", [(10)])]);
  1948. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((11), "_truncated", []), "__eq", [(11)])]);
  1949. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((12), "_truncated", []), "__eq", [(12)])]);
  1950. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((13), "_truncated", []), "__eq", [(13)])]);
  1951. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((14), "_truncated", []), "__eq", [(14)])]);
  1952. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((15), "_truncated", []), "__eq", [(15)])]);
  1953. return self;},
  1954. args: [],
  1955. source: "testHexNumbers\x0a\x0a\x09self assert: 16r9 = 9.\x0a\x09self assert: 16rA truncated = 10.\x0a\x09self assert: 16rB truncated = 11.\x0a\x09self assert: 16rC truncated = 12.\x0a\x09self assert: 16rD truncated = 13.\x0a\x09self assert: 16rE truncated = 14.\x0a\x09self assert: 16rF truncated = 15",
  1956. messageSends: ["assert:", "=", "truncated"],
  1957. referencedClasses: []
  1958. }),
  1959. smalltalk.NumberTest);
  1960. smalltalk.addMethod(
  1961. "_testIdentity",
  1962. smalltalk.method({
  1963. selector: "testIdentity",
  1964. category: 'tests',
  1965. fn: function (){
  1966. var self=this;
  1967. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq_eq", [(1)])]);
  1968. smalltalk.send(self, "_assert_", [smalltalk.send((0), "__eq_eq", [(0)])]);
  1969. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq_eq", [(0)])]);
  1970. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq_eq", [(1)])]);
  1971. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq_eq", [smalltalk.send((1), "_yourself", [])])]);
  1972. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq_eq", [smalltalk.send((1), "_yourself", [])])]);
  1973. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq_eq", [(2)])]);
  1974. return self;},
  1975. args: [],
  1976. 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",
  1977. messageSends: ["assert:", "==", "deny:", "yourself"],
  1978. referencedClasses: []
  1979. }),
  1980. smalltalk.NumberTest);
  1981. smalltalk.addMethod(
  1982. "_testInvalidHexNumbers",
  1983. smalltalk.method({
  1984. selector: "testInvalidHexNumbers",
  1985. category: 'tests',
  1986. fn: function (){
  1987. var self=this;
  1988. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rG", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1989. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rg", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1990. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rH", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1991. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rh", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1992. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rI", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1993. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_ri", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1994. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rJ", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1995. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rj", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1996. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rK", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1997. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rk", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1998. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rL", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1999. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rl", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2000. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rM", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2001. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rm", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2002. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rN", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2003. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rn", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2004. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rO", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2005. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_ro", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2006. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rP", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2007. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rp", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2008. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rQ", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2009. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rq", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2010. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rR", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2011. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rr", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2012. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rS", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2013. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rs", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2014. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rT", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2015. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rt", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2016. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rU", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2017. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_ru", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2018. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rV", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2019. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rv", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2020. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rW", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2021. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rw", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2022. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rX", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2023. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rx", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2024. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rY", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2025. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_ry", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2026. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rZ", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2027. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((16), "_rz", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2028. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((11259375), "_Z", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2029. return self;},
  2030. args: [],
  2031. source: "testInvalidHexNumbers\x0a\x0a\x09self should: [16rG] raise: MessageNotUnderstood.\x0a \x09self should: [16rg] raise: MessageNotUnderstood.\x0a\x09self should: [16rH] raise: MessageNotUnderstood.\x0a \x09self should: [16rh] raise: MessageNotUnderstood.\x0a\x09self should: [16rI] raise: MessageNotUnderstood.\x0a \x09self should: [16ri] raise: MessageNotUnderstood.\x0a\x09self should: [16rJ] raise: MessageNotUnderstood.\x0a \x09self should: [16rj] raise: MessageNotUnderstood.\x0a\x09self should: [16rK] raise: MessageNotUnderstood.\x0a \x09self should: [16rk] raise: MessageNotUnderstood.\x0a\x09self should: [16rL] raise: MessageNotUnderstood.\x0a \x09self should: [16rl] raise: MessageNotUnderstood.\x0a\x09self should: [16rM] raise: MessageNotUnderstood.\x0a \x09self should: [16rm] raise: MessageNotUnderstood.\x0a\x09self should: [16rN] raise: MessageNotUnderstood.\x0a \x09self should: [16rn] raise: MessageNotUnderstood.\x0a\x09self should: [16rO] raise: MessageNotUnderstood.\x0a \x09self should: [16ro] raise: MessageNotUnderstood.\x0a\x09self should: [16rP] raise: MessageNotUnderstood.\x0a \x09self should: [16rp] raise: MessageNotUnderstood.\x0a\x09self should: [16rQ] raise: MessageNotUnderstood.\x0a \x09self should: [16rq] raise: MessageNotUnderstood.\x0a\x09self should: [16rR] raise: MessageNotUnderstood.\x0a \x09self should: [16rr] raise: MessageNotUnderstood.\x0a\x09self should: [16rS] raise: MessageNotUnderstood.\x0a \x09self should: [16rs] raise: MessageNotUnderstood.\x0a\x09self should: [16rT] raise: MessageNotUnderstood.\x0a \x09self should: [16rt] raise: MessageNotUnderstood.\x0a\x09self should: [16rU] raise: MessageNotUnderstood.\x0a \x09self should: [16ru] raise: MessageNotUnderstood.\x0a\x09self should: [16rV] raise: MessageNotUnderstood.\x0a \x09self should: [16rv] raise: MessageNotUnderstood.\x0a\x09self should: [16rW] raise: MessageNotUnderstood.\x0a \x09self should: [16rw] raise: MessageNotUnderstood.\x0a\x09self should: [16rX] raise: MessageNotUnderstood.\x0a \x09self should: [16rx] raise: MessageNotUnderstood.\x0a\x09self should: [16rY] raise: MessageNotUnderstood.\x0a \x09self should: [16ry] raise: MessageNotUnderstood.\x0a\x09self should: [16rZ] raise: MessageNotUnderstood.\x0a \x09self should: [16rz] raise: MessageNotUnderstood.\x0a self should: [16rABcdEfZ] raise: MessageNotUnderstood.",
  2032. messageSends: ["should:raise:", "rG", "rg", "rH", "rh", "rI", "ri", "rJ", "rj", "rK", "rk", "rL", "rl", "rM", "rm", "rN", "rn", "rO", "ro", "rP", "rp", "rQ", "rq", "rR", "rr", "rS", "rs", "rT", "rt", "rU", "ru", "rV", "rv", "rW", "rw", "rX", "rx", "rY", "ry", "rZ", "rz", "Z"],
  2033. referencedClasses: ["MessageNotUnderstood"]
  2034. }),
  2035. smalltalk.NumberTest);
  2036. smalltalk.addMethod(
  2037. "_testMinMax",
  2038. smalltalk.method({
  2039. selector: "testMinMax",
  2040. category: 'tests',
  2041. fn: function (){
  2042. var self=this;
  2043. smalltalk.send(self, "_assert_equals_", [smalltalk.send((2), "_max_", [(5)]), (5)]);
  2044. smalltalk.send(self, "_assert_equals_", [smalltalk.send((2), "_min_", [(5)]), (2)]);
  2045. return self;},
  2046. args: [],
  2047. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  2048. messageSends: ["assert:equals:", "max:", "min:"],
  2049. referencedClasses: []
  2050. }),
  2051. smalltalk.NumberTest);
  2052. smalltalk.addMethod(
  2053. "_testNegated",
  2054. smalltalk.method({
  2055. selector: "testNegated",
  2056. category: 'tests',
  2057. fn: function (){
  2058. var self=this;
  2059. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_negated", []), "__eq", [(-3)])]);
  2060. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((-3), "_negated", []), "__eq", [(3)])]);
  2061. return self;},
  2062. args: [],
  2063. source: "testNegated\x0a\x09self assert: 3 negated = -3.\x0a\x09self assert: -3 negated = 3",
  2064. messageSends: ["assert:", "=", "negated"],
  2065. referencedClasses: []
  2066. }),
  2067. smalltalk.NumberTest);
  2068. smalltalk.addMethod(
  2069. "_testPrintShowingDecimalPlaces",
  2070. smalltalk.method({
  2071. selector: "testPrintShowingDecimalPlaces",
  2072. category: 'tests',
  2073. fn: function (){
  2074. var self=this;
  2075. smalltalk.send(self, "_assert_equals_", ["23.00", smalltalk.send((23), "_printShowingDecimalPlaces_", [(2)])]);
  2076. smalltalk.send(self, "_assert_equals_", ["23.57", smalltalk.send((23.5698), "_printShowingDecimalPlaces_", [(2)])]);
  2077. smalltalk.send(self, "_assert_equals_", ["-234.56700", smalltalk.send(smalltalk.send((234.567), "_negated", []), "_printShowingDecimalPlaces_", [(5)])]);
  2078. smalltalk.send(self, "_assert_equals_", ["23", smalltalk.send((23.4567), "_printShowingDecimalPlaces_", [(0)])]);
  2079. smalltalk.send(self, "_assert_equals_", ["24", smalltalk.send((23.5567), "_printShowingDecimalPlaces_", [(0)])]);
  2080. smalltalk.send(self, "_assert_equals_", ["-23", smalltalk.send(smalltalk.send((23.4567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  2081. smalltalk.send(self, "_assert_equals_", ["-24", smalltalk.send(smalltalk.send((23.5567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  2082. smalltalk.send(self, "_assert_equals_", ["100000000.0", smalltalk.send((100000000), "_printShowingDecimalPlaces_", [(1)])]);
  2083. smalltalk.send(self, "_assert_equals_", ["0.98000", smalltalk.send((0.98), "_printShowingDecimalPlaces_", [(5)])]);
  2084. smalltalk.send(self, "_assert_equals_", ["-0.98", smalltalk.send(smalltalk.send((0.98), "_negated", []), "_printShowingDecimalPlaces_", [(2)])]);
  2085. smalltalk.send(self, "_assert_equals_", ["2.57", smalltalk.send((2.567), "_printShowingDecimalPlaces_", [(2)])]);
  2086. smalltalk.send(self, "_assert_equals_", ["-2.57", smalltalk.send((-2.567), "_printShowingDecimalPlaces_", [(2)])]);
  2087. smalltalk.send(self, "_assert_equals_", ["0.00", smalltalk.send((0), "_printShowingDecimalPlaces_", [(2)])]);
  2088. return self;},
  2089. args: [],
  2090. 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).",
  2091. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  2092. referencedClasses: []
  2093. }),
  2094. smalltalk.NumberTest);
  2095. smalltalk.addMethod(
  2096. "_testRounded",
  2097. smalltalk.method({
  2098. selector: "testRounded",
  2099. category: 'tests',
  2100. fn: function (){
  2101. var self=this;
  2102. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_rounded", []), "__eq", [(3)])]);
  2103. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_rounded", []), "__eq", [(3)])]);
  2104. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_rounded", []), "__eq", [(4)])]);
  2105. return self;},
  2106. args: [],
  2107. source: "testRounded\x0a\x09\x0a\x09self assert: 3 rounded = 3.\x0a\x09self assert: 3.212 rounded = 3.\x0a\x09self assert: 3.51 rounded = 4",
  2108. messageSends: ["assert:", "=", "rounded"],
  2109. referencedClasses: []
  2110. }),
  2111. smalltalk.NumberTest);
  2112. smalltalk.addMethod(
  2113. "_testSqrt",
  2114. smalltalk.method({
  2115. selector: "testSqrt",
  2116. category: 'tests',
  2117. fn: function (){
  2118. var self=this;
  2119. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((4), "_sqrt", []), "__eq", [(2)])]);
  2120. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((16), "_sqrt", []), "__eq", [(4)])]);
  2121. return self;},
  2122. args: [],
  2123. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt = 2.\x0a\x09self assert: 16 sqrt = 4",
  2124. messageSends: ["assert:", "=", "sqrt"],
  2125. referencedClasses: []
  2126. }),
  2127. smalltalk.NumberTest);
  2128. smalltalk.addMethod(
  2129. "_testSquared",
  2130. smalltalk.method({
  2131. selector: "testSquared",
  2132. category: 'tests',
  2133. fn: function (){
  2134. var self=this;
  2135. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((4), "_squared", []), "__eq", [(16)])]);
  2136. return self;},
  2137. args: [],
  2138. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared = 16",
  2139. messageSends: ["assert:", "=", "squared"],
  2140. referencedClasses: []
  2141. }),
  2142. smalltalk.NumberTest);
  2143. smalltalk.addMethod(
  2144. "_testTimesRepeat",
  2145. smalltalk.method({
  2146. selector: "testTimesRepeat",
  2147. category: 'tests',
  2148. fn: function (){
  2149. var self=this;
  2150. var i=nil;
  2151. (i=(0));
  2152. smalltalk.send((0), "_timesRepeat_", [(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})]);
  2153. smalltalk.send(self, "_assert_equals_", [i, (0)]);
  2154. smalltalk.send((5), "_timesRepeat_", [(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})]);
  2155. smalltalk.send(self, "_assert_equals_", [i, (5)]);
  2156. return self;},
  2157. args: [],
  2158. 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",
  2159. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  2160. referencedClasses: []
  2161. }),
  2162. smalltalk.NumberTest);
  2163. smalltalk.addMethod(
  2164. "_testTo",
  2165. smalltalk.method({
  2166. selector: "testTo",
  2167. category: 'tests',
  2168. fn: function (){
  2169. var self=this;
  2170. smalltalk.send(self, "_assert_equals_", [smalltalk.send((1), "_to_", [(5)]), [(1), (2), (3), (4), (5)]]);
  2171. return self;},
  2172. args: [],
  2173. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  2174. messageSends: ["assert:equals:", "to:"],
  2175. referencedClasses: []
  2176. }),
  2177. smalltalk.NumberTest);
  2178. smalltalk.addMethod(
  2179. "_testToBy",
  2180. smalltalk.method({
  2181. selector: "testToBy",
  2182. category: 'tests',
  2183. fn: function (){
  2184. var self=this;
  2185. smalltalk.send(self, "_assert_equals_", [smalltalk.send((0), "_to_by_", [(6), (2)]), [(0), (2), (4), (6)]]);
  2186. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((1), "_to_by_", [(4), (0)]);}), (smalltalk.Error || Error)]);
  2187. return self;},
  2188. args: [],
  2189. 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",
  2190. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  2191. referencedClasses: ["Error"]
  2192. }),
  2193. smalltalk.NumberTest);
  2194. smalltalk.addMethod(
  2195. "_testTruncated",
  2196. smalltalk.method({
  2197. selector: "testTruncated",
  2198. category: 'tests',
  2199. fn: function (){
  2200. var self=this;
  2201. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_truncated", []), "__eq", [(3)])]);
  2202. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_truncated", []), "__eq", [(3)])]);
  2203. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_truncated", []), "__eq", [(3)])]);
  2204. return self;},
  2205. args: [],
  2206. source: "testTruncated\x0a\x09\x0a\x09self assert: 3 truncated = 3.\x0a\x09self assert: 3.212 truncated = 3.\x0a\x09self assert: 3.51 truncated = 3",
  2207. messageSends: ["assert:", "=", "truncated"],
  2208. referencedClasses: []
  2209. }),
  2210. smalltalk.NumberTest);
  2211. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  2212. smalltalk.addMethod(
  2213. "_foo",
  2214. smalltalk.method({
  2215. selector: "foo",
  2216. category: 'not yet classified',
  2217. fn: function (){
  2218. var self=this;
  2219. return self['@foo'];
  2220. return self;},
  2221. args: [],
  2222. source: "foo\x0a\x09^foo",
  2223. messageSends: [],
  2224. referencedClasses: []
  2225. }),
  2226. smalltalk.ObjectMock);
  2227. smalltalk.addMethod(
  2228. "_foo_",
  2229. smalltalk.method({
  2230. selector: "foo:",
  2231. category: 'not yet classified',
  2232. fn: function (anObject){
  2233. var self=this;
  2234. (self['@foo']=anObject);
  2235. return self;},
  2236. args: ["anObject"],
  2237. source: "foo: anObject\x0a\x09foo := anObject",
  2238. messageSends: [],
  2239. referencedClasses: []
  2240. }),
  2241. smalltalk.ObjectMock);
  2242. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2243. smalltalk.addMethod(
  2244. "_testBasicAccess",
  2245. smalltalk.method({
  2246. selector: "testBasicAccess",
  2247. category: 'tests',
  2248. fn: function (){
  2249. var self=this;
  2250. var o=nil;
  2251. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  2252. smalltalk.send(o, "_basicAt_put_", ["a", (1)]);
  2253. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["a"]), (1)]);
  2254. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["b"]), nil]);
  2255. return self;},
  2256. args: [],
  2257. 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",
  2258. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  2259. referencedClasses: ["Object"]
  2260. }),
  2261. smalltalk.ObjectTest);
  2262. smalltalk.addMethod(
  2263. "_testBasicPerform",
  2264. smalltalk.method({
  2265. selector: "testBasicPerform",
  2266. category: 'tests',
  2267. fn: function (){
  2268. var self=this;
  2269. var o=nil;
  2270. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  2271. smalltalk.send(o, "_basicAt_put_", ["func", (function(){return "hello";})]);
  2272. smalltalk.send(o, "_basicAt_put_", ["func2", (function(a){return ((($receiver = a).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]));})]);
  2273. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_", ["func"]), "hello"]);
  2274. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_withArguments_", ["func2", [(3)]]), (4)]);
  2275. return self;},
  2276. args: [],
  2277. 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",
  2278. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  2279. referencedClasses: ["Object"]
  2280. }),
  2281. smalltalk.ObjectTest);
  2282. smalltalk.addMethod(
  2283. "_testDNU",
  2284. smalltalk.method({
  2285. selector: "testDNU",
  2286. category: 'tests',
  2287. fn: function (){
  2288. var self=this;
  2289. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_foo", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  2290. return self;},
  2291. args: [],
  2292. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  2293. messageSends: ["should:raise:", "foo", "new"],
  2294. referencedClasses: ["Object", "MessageNotUnderstood"]
  2295. }),
  2296. smalltalk.ObjectTest);
  2297. smalltalk.addMethod(
  2298. "_testEquality",
  2299. smalltalk.method({
  2300. selector: "testEquality",
  2301. category: 'tests',
  2302. fn: function (){
  2303. var self=this;
  2304. var o=nil;
  2305. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  2306. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq", [smalltalk.send((smalltalk.Object || Object), "_new", [])])]);
  2307. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [o])]);
  2308. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq", [o])]);
  2309. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [smalltalk.send(o, "_yourself", [])])]);
  2310. return self;},
  2311. args: [],
  2312. 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",
  2313. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  2314. referencedClasses: ["Object"]
  2315. }),
  2316. smalltalk.ObjectTest);
  2317. smalltalk.addMethod(
  2318. "_testHalt",
  2319. smalltalk.method({
  2320. selector: "testHalt",
  2321. category: 'tests',
  2322. fn: function (){
  2323. var self=this;
  2324. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_halt", []);}), (smalltalk.Error || Error)]);
  2325. return self;},
  2326. args: [],
  2327. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  2328. messageSends: ["should:raise:", "halt", "new"],
  2329. referencedClasses: ["Object", "Error"]
  2330. }),
  2331. smalltalk.ObjectTest);
  2332. smalltalk.addMethod(
  2333. "_testIdentity",
  2334. smalltalk.method({
  2335. selector: "testIdentity",
  2336. category: 'tests',
  2337. fn: function (){
  2338. var self=this;
  2339. var o=nil;
  2340. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  2341. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq_eq", [smalltalk.send((smalltalk.Object || Object), "_new", [])])]);
  2342. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq_eq", [o])]);
  2343. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq_eq", [o])]);
  2344. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq_eq", [smalltalk.send(o, "_yourself", [])])]);
  2345. return self;},
  2346. args: [],
  2347. 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",
  2348. messageSends: ["new", "deny:", "==", "assert:", "yourself"],
  2349. referencedClasses: ["Object"]
  2350. }),
  2351. smalltalk.ObjectTest);
  2352. smalltalk.addMethod(
  2353. "_testIfNil",
  2354. smalltalk.method({
  2355. selector: "testIfNil",
  2356. category: 'tests',
  2357. fn: function (){
  2358. var self=this;
  2359. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_isNil", [])]);
  2360. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return true;})() : $receiver, "__eq", [true])]);
  2361. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) != nil && $receiver != undefined) ? (function(){return true;})() : nil, "__eq", [true])]);
  2362. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  2363. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  2364. return self;},
  2365. args: [],
  2366. 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",
  2367. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  2368. referencedClasses: ["Object"]
  2369. }),
  2370. smalltalk.ObjectTest);
  2371. smalltalk.addMethod(
  2372. "_testInstVars",
  2373. smalltalk.method({
  2374. selector: "testInstVars",
  2375. category: 'tests',
  2376. fn: function (){
  2377. var self=this;
  2378. var o=nil;
  2379. (o=smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_new", []));
  2380. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), nil]);
  2381. smalltalk.send(o, "_instVarAt_put_", [smalltalk.symbolFor("foo"), (1)]);
  2382. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), (1)]);
  2383. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", ["foo"]), (1)]);
  2384. return self;},
  2385. args: [],
  2386. 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",
  2387. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  2388. referencedClasses: ["ObjectMock"]
  2389. }),
  2390. smalltalk.ObjectTest);
  2391. smalltalk.addMethod(
  2392. "_testNilUndefined",
  2393. smalltalk.method({
  2394. selector: "testNilUndefined",
  2395. category: 'tests',
  2396. fn: function (){
  2397. var self=this;
  2398. var notDefined=nil;
  2399. notDefined = undefined;
  2400. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "__eq", [notDefined])]);
  2401. return self;},
  2402. args: [],
  2403. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09| notDefined |\x0a \x0a <notDefined = undefined>.\x0a\x0a\x09self assert: nil = notDefined",
  2404. messageSends: ["assert:", "="],
  2405. referencedClasses: []
  2406. }),
  2407. smalltalk.ObjectTest);
  2408. smalltalk.addMethod(
  2409. "_testYourself",
  2410. smalltalk.method({
  2411. selector: "testYourself",
  2412. category: 'tests',
  2413. fn: function (){
  2414. var self=this;
  2415. var o=nil;
  2416. (o=smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_new", []));
  2417. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq_eq", [o])]);
  2418. return self;},
  2419. args: [],
  2420. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  2421. messageSends: ["new", "assert:", "==", "yourself"],
  2422. referencedClasses: ["ObjectMock"]
  2423. }),
  2424. smalltalk.ObjectTest);
  2425. smalltalk.addMethod(
  2426. "_testidentityHash",
  2427. smalltalk.method({
  2428. selector: "testidentityHash",
  2429. category: 'tests',
  2430. fn: function (){
  2431. var self=this;
  2432. var o1=nil;
  2433. var o2=nil;
  2434. (o1=smalltalk.send((smalltalk.Object || Object), "_new", []));
  2435. (o2=smalltalk.send((smalltalk.Object || Object), "_new", []));
  2436. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o1, "_identityHash", [])])]);
  2437. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o2, "_identityHash", [])])]);
  2438. return self;},
  2439. args: [],
  2440. 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",
  2441. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  2442. referencedClasses: ["Object"]
  2443. }),
  2444. smalltalk.ObjectTest);
  2445. smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
  2446. smalltalk.addMethod(
  2447. "_setUp",
  2448. smalltalk.method({
  2449. selector: "setUp",
  2450. category: 'running',
  2451. fn: function (){
  2452. var self=this;
  2453. (self['@backUpCommitPathJs']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathJs", []));
  2454. (self['@backUpCommitPathSt']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathSt", []));
  2455. smalltalk.send((smalltalk.Package || Package), "_resetCommitPaths", []);
  2456. (self['@zorkPackage']=smalltalk.send(smalltalk.send((smalltalk.Package || Package), "_new", []), "_name_", ["Zork"]));
  2457. (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", [])));
  2458. return self;},
  2459. args: [],
  2460. 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",
  2461. messageSends: ["defaultCommitPathJs", "defaultCommitPathSt", "resetCommitPaths", "name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
  2462. referencedClasses: ["Package"]
  2463. }),
  2464. smalltalk.PackageTest);
  2465. smalltalk.addMethod(
  2466. "_tearDown",
  2467. smalltalk.method({
  2468. selector: "tearDown",
  2469. category: 'running',
  2470. fn: function (){
  2471. var self=this;
  2472. (function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);return smalltalk.send($rec, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);})((smalltalk.Package || Package));
  2473. return self;},
  2474. args: [],
  2475. source: "tearDown\x0a\x09 Package \x0a\x09\x09defaultCommitPathJs: backUpCommitPathJs;\x0a\x09\x09defaultCommitPathSt: backUpCommitPathSt",
  2476. messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
  2477. referencedClasses: ["Package"]
  2478. }),
  2479. smalltalk.PackageTest);
  2480. smalltalk.addMethod(
  2481. "_testGrulCommitPathJsShouldBeServerGrulJs",
  2482. smalltalk.method({
  2483. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  2484. category: 'tests',
  2485. fn: function (){
  2486. var self=this;
  2487. smalltalk.send(self, "_assert_equals_", ["server/grul/js", smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  2488. return self;},
  2489. args: [],
  2490. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  2491. messageSends: ["assert:equals:", "commitPathJs"],
  2492. referencedClasses: []
  2493. }),
  2494. smalltalk.PackageTest);
  2495. smalltalk.addMethod(
  2496. "_testGrulCommitPathStShouldBeGrulSt",
  2497. smalltalk.method({
  2498. selector: "testGrulCommitPathStShouldBeGrulSt",
  2499. category: 'tests',
  2500. fn: function (){
  2501. var self=this;
  2502. smalltalk.send(self, "_assert_equals_", ["grul/st", smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  2503. return self;},
  2504. args: [],
  2505. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  2506. messageSends: ["assert:equals:", "commitPathSt"],
  2507. referencedClasses: []
  2508. }),
  2509. smalltalk.PackageTest);
  2510. smalltalk.addMethod(
  2511. "_testZorkCommitPathJsShouldBeJs",
  2512. smalltalk.method({
  2513. selector: "testZorkCommitPathJsShouldBeJs",
  2514. category: 'tests',
  2515. fn: function (){
  2516. var self=this;
  2517. smalltalk.send(self, "_assert_equals_", ["js", smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  2518. return self;},
  2519. args: [],
  2520. source: "testZorkCommitPathJsShouldBeJs\x0a\x09self assert: 'js' equals: zorkPackage commitPathJs",
  2521. messageSends: ["assert:equals:", "commitPathJs"],
  2522. referencedClasses: []
  2523. }),
  2524. smalltalk.PackageTest);
  2525. smalltalk.addMethod(
  2526. "_testZorkCommitPathStShouldBeSt",
  2527. smalltalk.method({
  2528. selector: "testZorkCommitPathStShouldBeSt",
  2529. category: 'tests',
  2530. fn: function (){
  2531. var self=this;
  2532. smalltalk.send(self, "_assert_equals_", ["st", smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  2533. return self;},
  2534. args: [],
  2535. source: "testZorkCommitPathStShouldBeSt\x0a\x09self assert: 'st' equals: zorkPackage commitPathSt",
  2536. messageSends: ["assert:equals:", "commitPathSt"],
  2537. referencedClasses: []
  2538. }),
  2539. smalltalk.PackageTest);
  2540. smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
  2541. smalltalk.addMethod(
  2542. "_setUp",
  2543. smalltalk.method({
  2544. selector: "setUp",
  2545. category: 'running',
  2546. fn: function (){
  2547. var self=this;
  2548. smalltalk.send((typeof super_ == 'undefined' ? nil : super_), "_setUp", []);
  2549. (function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", ["javascripts/"]);return smalltalk.send($rec, "_defaultCommitPathSt_", ["smalltalk/"]);})((smalltalk.Package || Package));
  2550. return self;},
  2551. args: [],
  2552. source: "setUp\x0a\x09super setUp.\x0a\x0a\x09Package\x0a\x09\x09defaultCommitPathJs: 'javascripts/';\x0a\x09\x09defaultCommitPathSt: 'smalltalk/'.",
  2553. messageSends: ["setUp", "defaultCommitPathJs:", "defaultCommitPathSt:"],
  2554. referencedClasses: ["Package"]
  2555. }),
  2556. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2557. smalltalk.addMethod(
  2558. "_testGrulCommitPathJsShouldBeServerGrulJs",
  2559. smalltalk.method({
  2560. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  2561. category: 'tests',
  2562. fn: function (){
  2563. var self=this;
  2564. smalltalk.send(self, "_assert_equals_", ["server/grul/js", smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  2565. return self;},
  2566. args: [],
  2567. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  2568. messageSends: ["assert:equals:", "commitPathJs"],
  2569. referencedClasses: []
  2570. }),
  2571. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2572. smalltalk.addMethod(
  2573. "_testGrulCommitPathStShouldBeGrulSt",
  2574. smalltalk.method({
  2575. selector: "testGrulCommitPathStShouldBeGrulSt",
  2576. category: 'tests',
  2577. fn: function (){
  2578. var self=this;
  2579. smalltalk.send(self, "_assert_equals_", ["grul/st", smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  2580. return self;},
  2581. args: [],
  2582. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  2583. messageSends: ["assert:equals:", "commitPathSt"],
  2584. referencedClasses: []
  2585. }),
  2586. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2587. smalltalk.addMethod(
  2588. "_testZorkCommitPathJsShouldBeJavascript",
  2589. smalltalk.method({
  2590. selector: "testZorkCommitPathJsShouldBeJavascript",
  2591. category: 'tests',
  2592. fn: function (){
  2593. var self=this;
  2594. smalltalk.send(self, "_assert_equals_", ["javascripts/", smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  2595. return self;},
  2596. args: [],
  2597. source: "testZorkCommitPathJsShouldBeJavascript\x0a\x09self assert: 'javascripts/' equals: zorkPackage commitPathJs",
  2598. messageSends: ["assert:equals:", "commitPathJs"],
  2599. referencedClasses: []
  2600. }),
  2601. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2602. smalltalk.addMethod(
  2603. "_testZorkCommitPathStShouldBeSmalltalk",
  2604. smalltalk.method({
  2605. selector: "testZorkCommitPathStShouldBeSmalltalk",
  2606. category: 'tests',
  2607. fn: function (){
  2608. var self=this;
  2609. smalltalk.send(self, "_assert_equals_", ["smalltalk/", smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  2610. return self;},
  2611. args: [],
  2612. source: "testZorkCommitPathStShouldBeSmalltalk\x0a\x09self assert: 'smalltalk/' equals: zorkPackage commitPathSt",
  2613. messageSends: ["assert:equals:", "commitPathSt"],
  2614. referencedClasses: []
  2615. }),
  2616. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2617. smalltalk.addMethod(
  2618. "_shouldInheritSelectors",
  2619. smalltalk.method({
  2620. selector: "shouldInheritSelectors",
  2621. category: 'accessing',
  2622. fn: function (){
  2623. var self=this;
  2624. return false;
  2625. return self;},
  2626. args: [],
  2627. source: "shouldInheritSelectors\x0a\x09^ false",
  2628. messageSends: [],
  2629. referencedClasses: []
  2630. }),
  2631. smalltalk.PackageWithDefaultCommitPathChangedTest.klass);
  2632. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2633. smalltalk.addMethod(
  2634. "_testAccessing",
  2635. smalltalk.method({
  2636. selector: "testAccessing",
  2637. category: 'tests',
  2638. fn: function (){
  2639. var self=this;
  2640. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)]), "_x", []), (3)]);
  2641. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)]), "_y", []), (4)]);
  2642. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_new", []), "_x_", [(3)]), "_x", []), (3)]);
  2643. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_new", []), "_y_", [(4)]), "_y", []), (4)]);
  2644. return self;},
  2645. args: [],
  2646. 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",
  2647. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  2648. referencedClasses: ["Point"]
  2649. }),
  2650. smalltalk.PointTest);
  2651. smalltalk.addMethod(
  2652. "_testArithmetic",
  2653. smalltalk.method({
  2654. selector: "testArithmetic",
  2655. category: 'tests',
  2656. fn: function (){
  2657. var self=this;
  2658. 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)])]);
  2659. 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)])]);
  2660. 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)])]);
  2661. 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)])]);
  2662. return self;},
  2663. args: [],
  2664. 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)",
  2665. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  2666. referencedClasses: ["Point"]
  2667. }),
  2668. smalltalk.PointTest);
  2669. smalltalk.addMethod(
  2670. "_testAt",
  2671. smalltalk.method({
  2672. selector: "testAt",
  2673. category: 'tests',
  2674. fn: function (){
  2675. var self=this;
  2676. smalltalk.send(self, "_assert_equals_", [smalltalk.send((3), "__at", [(4)]), smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)])]);
  2677. return self;},
  2678. args: [],
  2679. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  2680. messageSends: ["assert:equals:", "@", "x:y:"],
  2681. referencedClasses: ["Point"]
  2682. }),
  2683. smalltalk.PointTest);
  2684. smalltalk.addMethod(
  2685. "_testEgality",
  2686. smalltalk.method({
  2687. selector: "testEgality",
  2688. category: 'tests',
  2689. fn: function (){
  2690. var self=this;
  2691. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "__at", [(4)]), "__eq", [smalltalk.send((3), "__at", [(4)])])]);
  2692. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send((3), "__at", [(5)]), "__eq", [smalltalk.send((3), "__at", [(6)])])]);
  2693. return self;},
  2694. args: [],
  2695. source: "testEgality\x0a\x09self assert: 3@4 = (3@4).\x0a\x09self deny: 3@5 = (3@6)",
  2696. messageSends: ["assert:", "=", "@", "deny:"],
  2697. referencedClasses: []
  2698. }),
  2699. smalltalk.PointTest);
  2700. smalltalk.addMethod(
  2701. "_testTranslateBy",
  2702. smalltalk.method({
  2703. selector: "testTranslateBy",
  2704. category: 'tests',
  2705. fn: function (){
  2706. var self=this;
  2707. smalltalk.send(self, "_assert_equals_", [smalltalk.send((3), "__at", [(4)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send((0), "__at", [(1)])])]);
  2708. 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", [])])])]);
  2709. smalltalk.send(self, "_assert_equals_", [smalltalk.send((5), "__at", [(6)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send((2), "__at", [(3)])])]);
  2710. 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)])])]);
  2711. return self;},
  2712. args: [],
  2713. 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).",
  2714. messageSends: ["assert:equals:", "@", "translateBy:", "negated"],
  2715. referencedClasses: []
  2716. }),
  2717. smalltalk.PointTest);
  2718. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2719. smalltalk.addMethod(
  2720. "_textNext",
  2721. smalltalk.method({
  2722. selector: "textNext",
  2723. category: 'tests',
  2724. fn: function (){
  2725. var self=this;
  2726. smalltalk.send((10000), "_timesRepeat_", [(function(){var current=nil;
  2727. var next=nil;
  2728. (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]);})]);
  2729. return self;},
  2730. args: [],
  2731. 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]",
  2732. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  2733. referencedClasses: ["Random"]
  2734. }),
  2735. smalltalk.RandomTest);
  2736. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2737. smalltalk.addMethod(
  2738. "_testAddRemove",
  2739. smalltalk.method({
  2740. selector: "testAddRemove",
  2741. category: 'tests',
  2742. fn: function (){
  2743. var self=this;
  2744. var set=nil;
  2745. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  2746. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_isEmpty", [])]);
  2747. smalltalk.send(set, "_add_", [(3)]);
  2748. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [(3)])]);
  2749. smalltalk.send(set, "_add_", [(5)]);
  2750. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [(5)])]);
  2751. smalltalk.send(set, "_remove_", [(3)]);
  2752. smalltalk.send(self, "_deny_", [smalltalk.send(set, "_includes_", [(3)])]);
  2753. return self;},
  2754. args: [],
  2755. 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)",
  2756. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  2757. referencedClasses: ["Set"]
  2758. }),
  2759. smalltalk.SetTest);
  2760. smalltalk.addMethod(
  2761. "_testAt",
  2762. smalltalk.method({
  2763. selector: "testAt",
  2764. category: 'tests',
  2765. fn: function (){
  2766. var self=this;
  2767. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_new", []), "_at_put_", [(1), (2)]);}), (smalltalk.Error || Error)]);
  2768. return self;},
  2769. args: [],
  2770. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  2771. messageSends: ["should:raise:", "at:put:", "new"],
  2772. referencedClasses: ["Set", "Error"]
  2773. }),
  2774. smalltalk.SetTest);
  2775. smalltalk.addMethod(
  2776. "_testPrintString",
  2777. smalltalk.method({
  2778. selector: "testPrintString",
  2779. category: 'tests',
  2780. fn: function (){
  2781. var self=this;
  2782. var set=nil;
  2783. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  2784. smalltalk.send(self, "_assert_equals_", ["a Set ()", smalltalk.send(set, "_printString", [])]);
  2785. (function($rec){smalltalk.send($rec, "_add_", [(1)]);return smalltalk.send($rec, "_add_", [(3)]);})(set);
  2786. smalltalk.send(self, "_assert_equals_", ["a Set (1 3)", smalltalk.send(set, "_printString", [])]);
  2787. smalltalk.send(set, "_add_", ["foo"]);
  2788. smalltalk.send(self, "_assert_equals_", ["a Set (1 3 'foo')", smalltalk.send(set, "_printString", [])]);
  2789. (function($rec){smalltalk.send($rec, "_remove_", [(1)]);return smalltalk.send($rec, "_remove_", [(3)]);})(set);
  2790. smalltalk.send(self, "_assert_equals_", ["a Set ('foo')", smalltalk.send(set, "_printString", [])]);
  2791. smalltalk.send(set, "_add_", [(3)]);
  2792. smalltalk.send(self, "_assert_equals_", ["a Set ('foo' 3)", smalltalk.send(set, "_printString", [])]);
  2793. smalltalk.send(set, "_add_", [(3)]);
  2794. smalltalk.send(self, "_assert_equals_", ["a Set ('foo' 3)", smalltalk.send(set, "_printString", [])]);
  2795. return self;},
  2796. args: [],
  2797. 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 ).",
  2798. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:"],
  2799. referencedClasses: ["Set"]
  2800. }),
  2801. smalltalk.SetTest);
  2802. smalltalk.addMethod(
  2803. "_testSize",
  2804. smalltalk.method({
  2805. selector: "testSize",
  2806. category: 'tests',
  2807. fn: function (){
  2808. var self=this;
  2809. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_new", []), "_size", []), (0)]);
  2810. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_withAll_", [[(1), (2), (3), (4)]]), "_size", []), (4)]);
  2811. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_withAll_", [[(1), (1), (1), (1)]]), "_size", []), (1)]);
  2812. return self;},
  2813. args: [],
  2814. 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",
  2815. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  2816. referencedClasses: ["Set"]
  2817. }),
  2818. smalltalk.SetTest);
  2819. smalltalk.addMethod(
  2820. "_testUnicity",
  2821. smalltalk.method({
  2822. selector: "testUnicity",
  2823. category: 'tests',
  2824. fn: function (){
  2825. var self=this;
  2826. var set=nil;
  2827. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  2828. smalltalk.send(set, "_add_", [(21)]);
  2829. smalltalk.send(set, "_add_", ["hello"]);
  2830. smalltalk.send(set, "_add_", [(21)]);
  2831. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [(2)])]);
  2832. smalltalk.send(set, "_add_", ["hello"]);
  2833. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [(2)])]);
  2834. smalltalk.send(self, "_assert_equals_", [smalltalk.send(set, "_asArray", []), [(21), "hello"]]);
  2835. return self;},
  2836. args: [],
  2837. 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')",
  2838. messageSends: ["new", "add:", "assert:", "=", "size", "assert:equals:", "asArray"],
  2839. referencedClasses: ["Set"]
  2840. }),
  2841. smalltalk.SetTest);
  2842. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2843. smalltalk.addMethod(
  2844. "_testCopying",
  2845. smalltalk.method({
  2846. selector: "testCopying",
  2847. category: 'tests',
  2848. fn: function (){
  2849. var self=this;
  2850. smalltalk.send(self, "_assert_equals_", [smalltalk.send(nil, "_copy", []), nil]);
  2851. return self;},
  2852. args: [],
  2853. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  2854. messageSends: ["assert:equals:", "copy"],
  2855. referencedClasses: []
  2856. }),
  2857. smalltalk.UndefinedTest);
  2858. smalltalk.addMethod(
  2859. "_testDeepCopy",
  2860. smalltalk.method({
  2861. selector: "testDeepCopy",
  2862. category: 'tests',
  2863. fn: function (){
  2864. var self=this;
  2865. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(nil, "_deepCopy", []), "__eq", [nil])]);
  2866. return self;},
  2867. args: [],
  2868. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  2869. messageSends: ["assert:", "=", "deepCopy"],
  2870. referencedClasses: []
  2871. }),
  2872. smalltalk.UndefinedTest);
  2873. smalltalk.addMethod(
  2874. "_testIfNil",
  2875. smalltalk.method({
  2876. selector: "testIfNil",
  2877. category: 'tests',
  2878. fn: function (){
  2879. var self=this;
  2880. smalltalk.send(self, "_assert_equals_", [(($receiver = nil) == nil || $receiver == undefined) ? (function(){return true;})() : $receiver, true]);
  2881. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = nil) != nil && $receiver != undefined) ? (function(){return true;})() : nil, "__eq", [true])]);
  2882. smalltalk.send(self, "_assert_equals_", [(($receiver = nil) == nil || $receiver == undefined) ? (function(){return true;})() : (function(){return false;})(), true]);
  2883. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = nil) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  2884. return self;},
  2885. args: [],
  2886. 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",
  2887. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  2888. referencedClasses: []
  2889. }),
  2890. smalltalk.UndefinedTest);
  2891. smalltalk.addMethod(
  2892. "_testIsNil",
  2893. smalltalk.method({
  2894. selector: "testIsNil",
  2895. category: 'tests',
  2896. fn: function (){
  2897. var self=this;
  2898. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "_isNil", [])]);
  2899. smalltalk.send(self, "_deny_", [smalltalk.send(nil, "_notNil", [])]);
  2900. return self;},
  2901. args: [],
  2902. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  2903. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  2904. referencedClasses: []
  2905. }),
  2906. smalltalk.UndefinedTest);
  2907. smalltalk.addMethod(
  2908. "_boxed",
  2909. smalltalk.method({
  2910. selector: "boxed",
  2911. category: '*Kernel-Tests',
  2912. fn: function (){
  2913. var self=this;
  2914. return self;
  2915. return self;},
  2916. args: [],
  2917. source: "boxed\x0a\x09^self",
  2918. messageSends: [],
  2919. referencedClasses: []
  2920. }),
  2921. smalltalk.Boolean);