1
0

Kernel-Tests.js 187 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446
  1. smalltalk.addPackage('Kernel-Tests');
  2. smalltalk.addClass('BlockClosureTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3. smalltalk.addMethod(
  4. smalltalk.method({
  5. selector: "testCanClearInterval",
  6. category: 'tests',
  7. fn: function (){
  8. var self=this;
  9. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  10. return smalltalk.withContext(function($ctx1) {
  11. _st(self)._shouldnt_raise_((function(){
  12. return smalltalk.withContext(function($ctx2) {
  13. return _st(_st((function(){
  14. return smalltalk.withContext(function($ctx3) {
  15. return _st(_st($Error())._new())._signal();
  16. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._valueWithInterval_((0)))._clearInterval();
  17. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  18. return self}, function($ctx1) {$ctx1.fill(self,"testCanClearInterval",{},smalltalk.BlockClosureTest)})},
  19. args: [],
  20. source: "testCanClearInterval\x0a\x09self shouldnt: [([Error new signal] valueWithInterval: 0) clearInterval] raise: Error",
  21. messageSends: ["shouldnt:raise:", "clearInterval", "valueWithInterval:", "signal", "new"],
  22. referencedClasses: ["Error"]
  23. }),
  24. smalltalk.BlockClosureTest);
  25. smalltalk.addMethod(
  26. smalltalk.method({
  27. selector: "testCanClearTimeout",
  28. category: 'tests',
  29. fn: function (){
  30. var self=this;
  31. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  32. return smalltalk.withContext(function($ctx1) {
  33. _st(self)._shouldnt_raise_((function(){
  34. return smalltalk.withContext(function($ctx2) {
  35. return _st(_st((function(){
  36. return smalltalk.withContext(function($ctx3) {
  37. return _st(_st($Error())._new())._signal();
  38. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._valueWithTimeout_((0)))._clearTimeout();
  39. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  40. return self}, function($ctx1) {$ctx1.fill(self,"testCanClearTimeout",{},smalltalk.BlockClosureTest)})},
  41. args: [],
  42. source: "testCanClearTimeout\x0a\x09self shouldnt: [([Error new signal] valueWithTimeout: 0) clearTimeout] raise: Error",
  43. messageSends: ["shouldnt:raise:", "clearTimeout", "valueWithTimeout:", "signal", "new"],
  44. referencedClasses: ["Error"]
  45. }),
  46. smalltalk.BlockClosureTest);
  47. smalltalk.addMethod(
  48. smalltalk.method({
  49. selector: "testCompiledSource",
  50. category: 'tests',
  51. fn: function (){
  52. var self=this;
  53. return smalltalk.withContext(function($ctx1) {
  54. _st(self)._assert_(_st(_st((function(){
  55. return smalltalk.withContext(function($ctx2) {
  56. return _st((1)).__plus((1));
  57. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._compiledSource())._includesSubString_("function"));
  58. return self}, function($ctx1) {$ctx1.fill(self,"testCompiledSource",{},smalltalk.BlockClosureTest)})},
  59. args: [],
  60. source: "testCompiledSource\x0a\x09self assert: ([1+1] compiledSource includesSubString: 'function')",
  61. messageSends: ["assert:", "includesSubString:", "compiledSource", "+"],
  62. referencedClasses: []
  63. }),
  64. smalltalk.BlockClosureTest);
  65. smalltalk.addMethod(
  66. smalltalk.method({
  67. selector: "testCurrySelf",
  68. category: 'tests',
  69. fn: function (){
  70. var self=this;
  71. var curriedMethod,array;
  72. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  73. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  74. return smalltalk.withContext(function($ctx1) {
  75. curriedMethod=_st(_st((function(selfarg,x){
  76. return smalltalk.withContext(function($ctx2) {
  77. return _st(selfarg)._at_(x);
  78. }, function($ctx2) {$ctx2.fillBlock({selfarg:selfarg,x:x},$ctx1)})}))._currySelf())._asCompiledMethod_("foo:");
  79. array=[(3), (1), (4)];
  80. _st(_st($ClassBuilder())._new())._installMethod_forClass_category_(curriedMethod,$Array(),"**test helper");
  81. _st((function(){
  82. return smalltalk.withContext(function($ctx2) {
  83. return _st(self)._assert_equals_(_st(array)._foo_((2)),(1));
  84. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  85. return smalltalk.withContext(function($ctx2) {
  86. return _st($Array())._removeCompiledMethod_(curriedMethod);
  87. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  88. return self}, function($ctx1) {$ctx1.fill(self,"testCurrySelf",{curriedMethod:curriedMethod,array:array},smalltalk.BlockClosureTest)})},
  89. args: [],
  90. source: "testCurrySelf\x0a\x09| curriedMethod array |\x0a\x09curriedMethod := [ :selfarg :x | selfarg at: x ] currySelf asCompiledMethod: 'foo:'.\x0a\x09array := #(3 1 4).\x0a\x09ClassBuilder new installMethod: curriedMethod forClass: Array category: '**test helper'.\x0a\x09[ self assert: (array foo: 2) equals: 1 ]\x0a\x09ensure: [ Array removeCompiledMethod: curriedMethod ]",
  91. messageSends: ["asCompiledMethod:", "currySelf", "at:", "installMethod:forClass:category:", "new", "ensure:", "removeCompiledMethod:", "assert:equals:", "foo:"],
  92. referencedClasses: ["Array", "ClassBuilder"]
  93. }),
  94. smalltalk.BlockClosureTest);
  95. smalltalk.addMethod(
  96. smalltalk.method({
  97. selector: "testEnsure",
  98. category: 'tests',
  99. fn: function (){
  100. var self=this;
  101. return smalltalk.withContext(function($ctx1) {
  102. _st(self)._assert_equals_(_st((function(){
  103. return smalltalk.withContext(function($ctx2) {
  104. return (3);
  105. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._ensure_((function(){
  106. return smalltalk.withContext(function($ctx2) {
  107. return (4);
  108. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),(3));
  109. return self}, function($ctx1) {$ctx1.fill(self,"testEnsure",{},smalltalk.BlockClosureTest)})},
  110. args: [],
  111. source: "testEnsure\x0a\x09self assert: ([3] ensure: [4]) equals: 3",
  112. messageSends: ["assert:equals:", "ensure:"],
  113. referencedClasses: []
  114. }),
  115. smalltalk.BlockClosureTest);
  116. smalltalk.addMethod(
  117. smalltalk.method({
  118. selector: "testEnsureRaises",
  119. category: 'tests',
  120. fn: function (){
  121. var self=this;
  122. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  123. return smalltalk.withContext(function($ctx1) {
  124. _st(self)._should_raise_((function(){
  125. return smalltalk.withContext(function($ctx2) {
  126. return _st((function(){
  127. return smalltalk.withContext(function($ctx3) {
  128. return _st(_st($Error())._new())._signal();
  129. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._ensure_((function(){
  130. return smalltalk.withContext(function($ctx3) {
  131. return true;
  132. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  133. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  134. return self}, function($ctx1) {$ctx1.fill(self,"testEnsureRaises",{},smalltalk.BlockClosureTest)})},
  135. args: [],
  136. source: "testEnsureRaises\x0a\x09self should: [[Error new signal] ensure: [true]] raise: Error",
  137. messageSends: ["should:raise:", "ensure:", "signal", "new"],
  138. referencedClasses: ["Error"]
  139. }),
  140. smalltalk.BlockClosureTest);
  141. smalltalk.addMethod(
  142. smalltalk.method({
  143. selector: "testExceptionSemantics",
  144. category: 'tests',
  145. fn: function (){
  146. var self=this;
  147. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  148. return smalltalk.withContext(function($ctx1) {
  149. _st(self)._timeout_((100));
  150. _st(_st(self)._async_((function(){
  151. return smalltalk.withContext(function($ctx2) {
  152. return _st((function(){
  153. return smalltalk.withContext(function($ctx3) {
  154. _st(self)._assert_(true);
  155. _st($Error())._signal();
  156. _st(self)._deny_(true);
  157. return _st(self)._finished();
  158. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(ex){
  159. return smalltalk.withContext(function($ctx3) {
  160. return _st(self)._finished();
  161. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx1)})}));
  162. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})))._valueWithTimeout_((0));
  163. return self}, function($ctx1) {$ctx1.fill(self,"testExceptionSemantics",{},smalltalk.BlockClosureTest)})},
  164. args: [],
  165. source: "testExceptionSemantics\x0a\x09\x22See https://github.com/NicolasPetton/amber/issues/314\x22\x0a\x09self timeout: 100.\x0a\x09\x0a\x09(self async: [\x0a\x09\x09[\x0a\x09\x09\x09self assert: true.\x0a\x09\x09\x09Error signal.\x0a\x09\x09\x09\x22The following should *not* be run\x22\x0a\x09\x09\x09self deny: true.\x0a\x09\x09\x09self finished.\x0a\x09\x09] on: Error do: [ :ex | self finished ]\x0a\x09]) valueWithTimeout: 0",
  166. messageSends: ["timeout:", "valueWithTimeout:", "async:", "on:do:", "finished", "assert:", "signal", "deny:"],
  167. referencedClasses: ["Error"]
  168. }),
  169. smalltalk.BlockClosureTest);
  170. smalltalk.addMethod(
  171. smalltalk.method({
  172. selector: "testNumArgs",
  173. category: 'tests',
  174. fn: function (){
  175. var self=this;
  176. return smalltalk.withContext(function($ctx1) {
  177. _st(self)._assert_equals_(_st((function(){
  178. return smalltalk.withContext(function($ctx2) {
  179. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._numArgs(),(0));
  180. _st(self)._assert_equals_(_st((function(a,b){
  181. return smalltalk.withContext(function($ctx2) {
  182. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}))._numArgs(),(2));
  183. return self}, function($ctx1) {$ctx1.fill(self,"testNumArgs",{},smalltalk.BlockClosureTest)})},
  184. args: [],
  185. source: "testNumArgs\x0a\x09self assert: [] numArgs equals: 0.\x0a\x09self assert: [:a :b | ] numArgs equals: 2",
  186. messageSends: ["assert:equals:", "numArgs"],
  187. referencedClasses: []
  188. }),
  189. smalltalk.BlockClosureTest);
  190. smalltalk.addMethod(
  191. smalltalk.method({
  192. selector: "testOnDo",
  193. category: 'tests',
  194. fn: function (){
  195. var self=this;
  196. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  197. return smalltalk.withContext(function($ctx1) {
  198. _st(self)._assert_(_st((function(){
  199. return smalltalk.withContext(function($ctx2) {
  200. return _st(_st($Error())._new())._signal();
  201. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(ex){
  202. return smalltalk.withContext(function($ctx2) {
  203. return true;
  204. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1)})})));
  205. return self}, function($ctx1) {$ctx1.fill(self,"testOnDo",{},smalltalk.BlockClosureTest)})},
  206. args: [],
  207. source: "testOnDo\x0a\x09self assert: ([Error new signal] on: Error do: [:ex | true])",
  208. messageSends: ["assert:", "on:do:", "signal", "new"],
  209. referencedClasses: ["Error"]
  210. }),
  211. smalltalk.BlockClosureTest);
  212. smalltalk.addMethod(
  213. smalltalk.method({
  214. selector: "testValue",
  215. category: 'tests',
  216. fn: function (){
  217. var self=this;
  218. return smalltalk.withContext(function($ctx1) {
  219. _st(self)._assert_equals_(_st((function(){
  220. return smalltalk.withContext(function($ctx2) {
  221. return _st((1)).__plus((1));
  222. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._value(),(2));
  223. _st(self)._assert_equals_(_st((function(x){
  224. return smalltalk.withContext(function($ctx2) {
  225. return _st(x).__plus((1));
  226. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})}))._value_((2)),(3));
  227. _st(self)._assert_equals_(_st((function(x,y){
  228. return smalltalk.withContext(function($ctx2) {
  229. return _st(x).__star(y);
  230. }, function($ctx2) {$ctx2.fillBlock({x:x,y:y},$ctx1)})}))._value_value_((2),(4)),(8));
  231. _st(self)._assert_equals_(_st((function(a,b,c){
  232. return smalltalk.withContext(function($ctx2) {
  233. return (1);
  234. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b,c:c},$ctx1)})}))._value(),(1));
  235. return self}, function($ctx1) {$ctx1.fill(self,"testValue",{},smalltalk.BlockClosureTest)})},
  236. args: [],
  237. 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",
  238. messageSends: ["assert:equals:", "value", "+", "value:", "value:value:", "*"],
  239. referencedClasses: []
  240. }),
  241. smalltalk.BlockClosureTest);
  242. smalltalk.addMethod(
  243. smalltalk.method({
  244. selector: "testValueWithPossibleArguments",
  245. category: 'tests',
  246. fn: function (){
  247. var self=this;
  248. return smalltalk.withContext(function($ctx1) {
  249. _st(self)._assert_equals_(_st((function(){
  250. return smalltalk.withContext(function($ctx2) {
  251. return (1);
  252. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._valueWithPossibleArguments_([(3), (4)]),(1));
  253. _st(self)._assert_equals_(_st((function(a){
  254. return smalltalk.withContext(function($ctx2) {
  255. return _st(a).__plus((4));
  256. }, function($ctx2) {$ctx2.fillBlock({a:a},$ctx1)})}))._valueWithPossibleArguments_([(3), (4)]),(7));
  257. _st(self)._assert_equals_(_st((function(a,b){
  258. return smalltalk.withContext(function($ctx2) {
  259. return _st(a).__plus(b);
  260. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1)})}))._valueWithPossibleArguments_([(3), (4), (5)]),(7));
  261. return self}, function($ctx1) {$ctx1.fill(self,"testValueWithPossibleArguments",{},smalltalk.BlockClosureTest)})},
  262. args: [],
  263. 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.",
  264. messageSends: ["assert:equals:", "valueWithPossibleArguments:", "+"],
  265. referencedClasses: []
  266. }),
  267. smalltalk.BlockClosureTest);
  268. smalltalk.addMethod(
  269. smalltalk.method({
  270. selector: "testWhileFalse",
  271. category: 'tests',
  272. fn: function (){
  273. var self=this;
  274. var i;
  275. return smalltalk.withContext(function($ctx1) {
  276. i=(0);
  277. _st((function(){
  278. return smalltalk.withContext(function($ctx2) {
  279. return _st(i).__gt((5));
  280. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse_((function(){
  281. return smalltalk.withContext(function($ctx2) {
  282. i=_st(i).__plus((1));
  283. return i;
  284. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  285. _st(self)._assert_equals_(i,(6));
  286. i=(0);
  287. _st((function(){
  288. return smalltalk.withContext(function($ctx2) {
  289. i=_st(i).__plus((1));
  290. i;
  291. return _st(i).__gt((5));
  292. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileFalse();
  293. _st(self)._assert_equals_(i,(6));
  294. return self}, function($ctx1) {$ctx1.fill(self,"testWhileFalse",{i:i},smalltalk.BlockClosureTest)})},
  295. args: [],
  296. 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",
  297. messageSends: ["whileFalse:", "+", ">", "assert:equals:", "whileFalse"],
  298. referencedClasses: []
  299. }),
  300. smalltalk.BlockClosureTest);
  301. smalltalk.addMethod(
  302. smalltalk.method({
  303. selector: "testWhileTrue",
  304. category: 'tests',
  305. fn: function (){
  306. var self=this;
  307. var i;
  308. return smalltalk.withContext(function($ctx1) {
  309. i=(0);
  310. _st((function(){
  311. return smalltalk.withContext(function($ctx2) {
  312. return _st(i).__lt((5));
  313. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue_((function(){
  314. return smalltalk.withContext(function($ctx2) {
  315. i=_st(i).__plus((1));
  316. return i;
  317. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  318. _st(self)._assert_equals_(i,(5));
  319. i=(0);
  320. _st((function(){
  321. return smalltalk.withContext(function($ctx2) {
  322. i=_st(i).__plus((1));
  323. i;
  324. return _st(i).__lt((5));
  325. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._whileTrue();
  326. _st(self)._assert_equals_(i,(5));
  327. return self}, function($ctx1) {$ctx1.fill(self,"testWhileTrue",{i:i},smalltalk.BlockClosureTest)})},
  328. args: [],
  329. 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",
  330. messageSends: ["whileTrue:", "+", "<", "assert:equals:", "whileTrue"],
  331. referencedClasses: []
  332. }),
  333. smalltalk.BlockClosureTest);
  334. smalltalk.addClass('BooleanTest', smalltalk.TestCase, [], 'Kernel-Tests');
  335. smalltalk.addMethod(
  336. smalltalk.method({
  337. selector: "testEquality",
  338. category: 'tests',
  339. fn: function (){
  340. var self=this;
  341. return smalltalk.withContext(function($ctx1) {
  342. _st(self)._deny_(_st((0)).__eq(false));
  343. _st(self)._deny_(_st(false).__eq((0)));
  344. _st(self)._deny_(_st("").__eq(false));
  345. _st(self)._deny_(_st(false).__eq(""));
  346. _st(self)._assert_(_st(true).__eq(true));
  347. _st(self)._deny_(_st(false).__eq(true));
  348. _st(self)._deny_(_st(true).__eq(false));
  349. _st(self)._assert_(_st(false).__eq(false));
  350. _st(self)._assert_(_st(_st(true)._yourself()).__eq(true));
  351. _st(self)._assert_(_st(_st(true)._yourself()).__eq(_st(true)._yourself()));
  352. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.BooleanTest)})},
  353. args: [],
  354. 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)",
  355. messageSends: ["deny:", "=", "assert:", "yourself"],
  356. referencedClasses: []
  357. }),
  358. smalltalk.BooleanTest);
  359. smalltalk.addMethod(
  360. smalltalk.method({
  361. selector: "testIdentity",
  362. category: 'tests',
  363. fn: function (){
  364. var self=this;
  365. return smalltalk.withContext(function($ctx1) {
  366. _st(self)._deny_(_st((0)).__eq_eq(false));
  367. _st(self)._deny_(_st(false).__eq_eq((0)));
  368. _st(self)._deny_(_st("").__eq_eq(false));
  369. _st(self)._deny_(_st(false).__eq_eq(""));
  370. _st(self)._assert_(_st(true).__eq_eq(true));
  371. _st(self)._deny_(_st(false).__eq_eq(true));
  372. _st(self)._deny_(_st(true).__eq_eq(false));
  373. _st(self)._assert_(_st(false).__eq_eq(false));
  374. _st(self)._assert_(_st(_st(true)._yourself()).__eq_eq(true));
  375. _st(self)._assert_(_st(_st(true)._yourself()).__eq_eq(_st(true)._yourself()));
  376. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.BooleanTest)})},
  377. args: [],
  378. 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",
  379. messageSends: ["deny:", "==", "assert:", "yourself"],
  380. referencedClasses: []
  381. }),
  382. smalltalk.BooleanTest);
  383. smalltalk.addMethod(
  384. smalltalk.method({
  385. selector: "testIfTrueIfFalse",
  386. category: 'tests',
  387. fn: function (){
  388. var self=this;
  389. return smalltalk.withContext(function($ctx1) {
  390. var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16;
  391. $1=self;
  392. if(smalltalk.assert(true)){
  393. $2="alternative block";
  394. };
  395. _st($1)._assert_equals_($2,"alternative block");
  396. $3=self;
  397. if(! smalltalk.assert(true)){
  398. $4="alternative block";
  399. };
  400. _st($3)._assert_equals_($4,nil);
  401. $5=self;
  402. if(smalltalk.assert(false)){
  403. $6="alternative block";
  404. };
  405. _st($5)._assert_equals_($6,nil);
  406. $7=self;
  407. if(! smalltalk.assert(false)){
  408. $8="alternative block";
  409. };
  410. _st($7)._assert_equals_($8,"alternative block");
  411. $9=self;
  412. if(smalltalk.assert(false)){
  413. $10="alternative block";
  414. } else {
  415. $10="alternative block2";
  416. };
  417. _st($9)._assert_equals_($10,"alternative block2");
  418. $11=self;
  419. if(smalltalk.assert(false)){
  420. $12="alternative block2";
  421. } else {
  422. $12="alternative block";
  423. };
  424. _st($11)._assert_equals_($12,"alternative block");
  425. $13=self;
  426. if(smalltalk.assert(true)){
  427. $14="alternative block";
  428. } else {
  429. $14="alternative block2";
  430. };
  431. _st($13)._assert_equals_($14,"alternative block");
  432. $15=self;
  433. if(smalltalk.assert(true)){
  434. $16="alternative block2";
  435. } else {
  436. $16="alternative block";
  437. };
  438. _st($15)._assert_equals_($16,"alternative block2");
  439. return self}, function($ctx1) {$ctx1.fill(self,"testIfTrueIfFalse",{},smalltalk.BooleanTest)})},
  440. args: [],
  441. source: "testIfTrueIfFalse\x0a\x0a\x09self assert: (true ifTrue: ['alternative block']) equals: 'alternative block'.\x0a\x09self assert: (true ifFalse: ['alternative block']) equals: nil.\x0a\x0a\x09self assert: (false ifTrue: ['alternative block']) equals: nil.\x0a\x09self assert: (false ifFalse: ['alternative block']) equals: 'alternative block'.\x0a\x0a\x09self assert: (false ifTrue: ['alternative block'] ifFalse: ['alternative block2']) equals: 'alternative block2'.\x0a\x09self assert: (false ifFalse: ['alternative block'] ifTrue: ['alternative block2']) equals: 'alternative block'.\x0a\x0a\x09self assert: (true ifTrue: ['alternative block'] ifFalse: ['alternative block2']) equals: 'alternative block'.\x0a\x09self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) equals: 'alternative block2'.",
  442. messageSends: ["assert:equals:", "ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  443. referencedClasses: []
  444. }),
  445. smalltalk.BooleanTest);
  446. smalltalk.addMethod(
  447. smalltalk.method({
  448. selector: "testIfTrueIfFalseWithBoxing",
  449. category: 'tests',
  450. fn: function (){
  451. var self=this;
  452. return smalltalk.withContext(function($ctx1) {
  453. var $1,$3,$2,$4,$6,$5,$7,$9,$8,$10,$12,$11,$13,$15,$14,$16,$18,$17,$19,$21,$20,$22,$24,$23;
  454. $1=self;
  455. $3=_st(true)._yourself();
  456. if(smalltalk.assert($3)){
  457. $2="alternative block";
  458. };
  459. _st($1)._assert_equals_($2,"alternative block");
  460. $4=self;
  461. $6=_st(true)._yourself();
  462. if(! smalltalk.assert($6)){
  463. $5="alternative block";
  464. };
  465. _st($4)._assert_equals_($5,nil);
  466. $7=self;
  467. $9=_st(false)._yourself();
  468. if(smalltalk.assert($9)){
  469. $8="alternative block";
  470. };
  471. _st($7)._assert_equals_($8,nil);
  472. $10=self;
  473. $12=_st(false)._yourself();
  474. if(! smalltalk.assert($12)){
  475. $11="alternative block";
  476. };
  477. _st($10)._assert_equals_($11,"alternative block");
  478. $13=self;
  479. $15=_st(false)._yourself();
  480. if(smalltalk.assert($15)){
  481. $14="alternative block";
  482. } else {
  483. $14="alternative block2";
  484. };
  485. _st($13)._assert_equals_($14,"alternative block2");
  486. $16=self;
  487. $18=_st(false)._yourself();
  488. if(smalltalk.assert($18)){
  489. $17="alternative block2";
  490. } else {
  491. $17="alternative block";
  492. };
  493. _st($16)._assert_equals_($17,"alternative block");
  494. $19=self;
  495. $21=_st(true)._yourself();
  496. if(smalltalk.assert($21)){
  497. $20="alternative block";
  498. } else {
  499. $20="alternative block2";
  500. };
  501. _st($19)._assert_equals_($20,"alternative block");
  502. $22=self;
  503. $24=_st(true)._yourself();
  504. if(smalltalk.assert($24)){
  505. $23="alternative block2";
  506. } else {
  507. $23="alternative block";
  508. };
  509. _st($22)._assert_equals_($23,"alternative block2");
  510. return self}, function($ctx1) {$ctx1.fill(self,"testIfTrueIfFalseWithBoxing",{},smalltalk.BooleanTest)})},
  511. args: [],
  512. source: "testIfTrueIfFalseWithBoxing\x0a\x0a\x09self assert: (true yourself ifTrue: ['alternative block']) equals: 'alternative block'.\x0a\x09self assert: (true yourself ifFalse: ['alternative block']) equals: nil.\x0a\x0a\x09self assert: (false yourself ifTrue: ['alternative block']) equals: nil.\x0a\x09self assert: (false yourself ifFalse: ['alternative block']) equals: 'alternative block'.\x0a\x0a\x09self assert: (false yourself ifTrue: ['alternative block'] ifFalse: ['alternative block2']) equals: 'alternative block2'.\x0a\x09self assert: (false yourself ifFalse: ['alternative block'] ifTrue: ['alternative block2']) equals: 'alternative block'.\x0a\x0a\x09self assert: (true yourself ifTrue: ['alternative block'] ifFalse: ['alternative block2']) equals: 'alternative block'.\x0a\x09self assert: (true yourself ifFalse: ['alternative block'] ifTrue: ['alternative block2']) equals: 'alternative block2'.",
  513. messageSends: ["assert:equals:", "ifTrue:", "yourself", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  514. referencedClasses: []
  515. }),
  516. smalltalk.BooleanTest);
  517. smalltalk.addMethod(
  518. smalltalk.method({
  519. selector: "testLogic",
  520. category: 'tests',
  521. fn: function (){
  522. var self=this;
  523. return smalltalk.withContext(function($ctx1) {
  524. var $1,$2,$3,$4,$5,$6,$7,$8;
  525. $1=self;
  526. _st($1)._assert_(_st(true).__and(true));
  527. _st($1)._deny_(_st(true).__and(false));
  528. _st($1)._deny_(_st(false).__and(true));
  529. $2=_st($1)._deny_(_st(false).__and(false));
  530. $3=self;
  531. _st($3)._assert_(_st(true).__or(true));
  532. _st($3)._assert_(_st(true).__or(false));
  533. _st($3)._assert_(_st(false).__or(true));
  534. $4=_st($3)._deny_(_st(false).__or(false));
  535. $5=self;
  536. _st($5)._assert_(_st(true).__and(_st((1)).__gt((0))));
  537. _st($5)._deny_(_st(_st((1)).__gt((0))).__and(false));
  538. $6=_st($5)._deny_(_st(_st((1)).__gt((0))).__and(_st((1)).__gt((2))));
  539. $7=self;
  540. _st($7)._assert_(_st(false).__or(_st((1)).__gt((0))));
  541. _st($7)._assert_(_st(_st((1)).__gt((0))).__or(false));
  542. $8=_st($7)._assert_(_st(_st((1)).__gt((0))).__or(_st((1)).__gt((2))));
  543. return self}, function($ctx1) {$ctx1.fill(self,"testLogic",{},smalltalk.BooleanTest)})},
  544. args: [],
  545. source: "testLogic\x0a\x09\x22Trivial logic table\x22\x0a\x09self assert: (true & true);\x0a\x09\x09deny: (true & false);\x0a\x09\x09deny: (false & true);\x0a\x09\x09deny: (false & false).\x0a\x09self assert: (true | true);\x0a\x09\x09assert: (true | false);\x0a\x09\x09assert: (false | true);\x0a\x09\x09deny: (false | false).\x0a\x09\x22Checking that expressions work fine too\x22\x0a\x09self assert: (true & (1 > 0));\x0a\x09\x09deny: ((1 > 0) & false);\x0a\x09\x09deny: ((1 > 0) & (1 > 2)).\x0a\x09self assert: (false | (1 > 0));\x0a\x09\x09assert: ((1 > 0) | false);\x0a\x09\x09assert: ((1 > 0) | (1 > 2))",
  546. messageSends: ["assert:", "&", "deny:", "|", ">"],
  547. referencedClasses: []
  548. }),
  549. smalltalk.BooleanTest);
  550. smalltalk.addMethod(
  551. smalltalk.method({
  552. selector: "testLogicKeywords",
  553. category: 'tests',
  554. fn: function (){
  555. var self=this;
  556. return smalltalk.withContext(function($ctx1) {
  557. var $1,$2,$3,$4,$5,$6,$7,$8;
  558. $1=self;
  559. _st($1)._assert_(_st(true)._and_((function(){
  560. return smalltalk.withContext(function($ctx2) {
  561. return true;
  562. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  563. _st($1)._deny_(_st(true)._and_((function(){
  564. return smalltalk.withContext(function($ctx2) {
  565. return false;
  566. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  567. _st($1)._deny_(_st(false)._and_((function(){
  568. return smalltalk.withContext(function($ctx2) {
  569. return true;
  570. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  571. $2=_st($1)._deny_(_st(false)._and_((function(){
  572. return smalltalk.withContext(function($ctx2) {
  573. return false;
  574. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  575. $3=self;
  576. _st($3)._assert_(_st(true)._or_((function(){
  577. return smalltalk.withContext(function($ctx2) {
  578. return true;
  579. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  580. _st($3)._assert_(_st(true)._or_((function(){
  581. return smalltalk.withContext(function($ctx2) {
  582. return false;
  583. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  584. _st($3)._assert_(_st(false)._or_((function(){
  585. return smalltalk.withContext(function($ctx2) {
  586. return true;
  587. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  588. $4=_st($3)._deny_(_st(false)._or_((function(){
  589. return smalltalk.withContext(function($ctx2) {
  590. return false;
  591. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  592. $5=self;
  593. _st($5)._assert_(_st(true)._and_((function(){
  594. return smalltalk.withContext(function($ctx2) {
  595. return _st((1)).__gt((0));
  596. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  597. _st($5)._deny_(_st(_st((1)).__gt((0)))._and_((function(){
  598. return smalltalk.withContext(function($ctx2) {
  599. return false;
  600. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  601. $6=_st($5)._deny_(_st(_st((1)).__gt((0)))._and_((function(){
  602. return smalltalk.withContext(function($ctx2) {
  603. return _st((1)).__gt((2));
  604. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  605. $7=self;
  606. _st($7)._assert_(_st(false)._or_((function(){
  607. return smalltalk.withContext(function($ctx2) {
  608. return _st((1)).__gt((0));
  609. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  610. _st($7)._assert_(_st(_st((1)).__gt((0)))._or_((function(){
  611. return smalltalk.withContext(function($ctx2) {
  612. return false;
  613. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  614. $8=_st($7)._assert_(_st(_st((1)).__gt((0)))._or_((function(){
  615. return smalltalk.withContext(function($ctx2) {
  616. return _st((1)).__gt((2));
  617. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})));
  618. return self}, function($ctx1) {$ctx1.fill(self,"testLogicKeywords",{},smalltalk.BooleanTest)})},
  619. args: [],
  620. source: "testLogicKeywords\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\x09\x09\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\x09self\x0a\x09\x09assert: (false or: [ 1 > 0 ]);\x0a\x09\x09assert: ((1 > 0) or: [ false ]);\x0a\x09\x09assert: ((1 > 0) or: [ 1 > 2 ])",
  621. messageSends: ["assert:", "and:", "deny:", "or:", ">"],
  622. referencedClasses: []
  623. }),
  624. smalltalk.BooleanTest);
  625. smalltalk.addMethod(
  626. smalltalk.method({
  627. selector: "testNonBooleanError",
  628. category: 'tests',
  629. fn: function (){
  630. var self=this;
  631. function $NonBooleanReceiver(){return smalltalk.NonBooleanReceiver||(typeof NonBooleanReceiver=="undefined"?nil:NonBooleanReceiver)}
  632. return smalltalk.withContext(function($ctx1) {
  633. _st(self)._should_raise_((function(){
  634. return smalltalk.withContext(function($ctx2) {
  635. if(smalltalk.assert("")){
  636. } else {
  637. };
  638. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$NonBooleanReceiver());
  639. return self}, function($ctx1) {$ctx1.fill(self,"testNonBooleanError",{},smalltalk.BooleanTest)})},
  640. args: [],
  641. source: "testNonBooleanError\x0a\x09self should: [ '' ifTrue: [] ifFalse: [] ] raise: NonBooleanReceiver",
  642. messageSends: ["should:raise:", "ifTrue:ifFalse:"],
  643. referencedClasses: ["NonBooleanReceiver"]
  644. }),
  645. smalltalk.BooleanTest);
  646. smalltalk.addClass('ClassBuilderTest', smalltalk.TestCase, ['builder', 'theClass'], 'Kernel-Tests');
  647. smalltalk.addMethod(
  648. smalltalk.method({
  649. selector: "setUp",
  650. category: 'running',
  651. fn: function (){
  652. var self=this;
  653. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  654. return smalltalk.withContext(function($ctx1) {
  655. self["@builder"]=_st($ClassBuilder())._new();
  656. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.ClassBuilderTest)})},
  657. args: [],
  658. source: "setUp\x0a\x09builder := ClassBuilder new",
  659. messageSends: ["new"],
  660. referencedClasses: ["ClassBuilder"]
  661. }),
  662. smalltalk.ClassBuilderTest);
  663. smalltalk.addMethod(
  664. smalltalk.method({
  665. selector: "tearDown",
  666. category: 'running',
  667. fn: function (){
  668. var self=this;
  669. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  670. return smalltalk.withContext(function($ctx1) {
  671. var $1;
  672. $1=self["@theClass"];
  673. if(($receiver = $1) == nil || $receiver == undefined){
  674. $1;
  675. } else {
  676. _st(_st($Smalltalk())._current())._removeClass_(self["@theClass"]);
  677. self["@theClass"]=nil;
  678. self["@theClass"];
  679. };
  680. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.ClassBuilderTest)})},
  681. args: [],
  682. source: "tearDown\x0a\x09theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]",
  683. messageSends: ["ifNotNil:", "removeClass:", "current"],
  684. referencedClasses: ["Smalltalk"]
  685. }),
  686. smalltalk.ClassBuilderTest);
  687. smalltalk.addMethod(
  688. smalltalk.method({
  689. selector: "testClassCopy",
  690. category: 'tests',
  691. fn: function (){
  692. var self=this;
  693. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  694. return smalltalk.withContext(function($ctx1) {
  695. self["@theClass"]=_st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  696. _st(self)._assert_(_st(_st(self["@theClass"])._superclass()).__eq_eq(_st($ObjectMock())._superclass()));
  697. _st(self)._assert_(_st(_st(self["@theClass"])._instanceVariableNames()).__eq_eq(_st($ObjectMock())._instanceVariableNames()));
  698. _st(self)._assert_equals_(_st(self["@theClass"])._name(),"ObjectMock2");
  699. _st(self)._assert_(_st(_st(self["@theClass"])._package()).__eq_eq(_st($ObjectMock())._package()));
  700. _st(self)._assert_equals_(_st(_st(self["@theClass"])._methodDictionary())._keys(),_st(_st($ObjectMock())._methodDictionary())._keys());
  701. return self}, function($ctx1) {$ctx1.fill(self,"testClassCopy",{},smalltalk.ClassBuilderTest)})},
  702. args: [],
  703. 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",
  704. messageSends: ["copyClass:named:", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary"],
  705. referencedClasses: ["ObjectMock"]
  706. }),
  707. smalltalk.ClassBuilderTest);
  708. smalltalk.addMethod(
  709. smalltalk.method({
  710. selector: "testClassMigration",
  711. category: 'tests',
  712. fn: function (){
  713. var self=this;
  714. var instance,oldClass;
  715. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  716. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  717. function $ObjectMock2(){return smalltalk.ObjectMock2||(typeof ObjectMock2=="undefined"?nil:ObjectMock2)}
  718. return smalltalk.withContext(function($ctx1) {
  719. oldClass=_st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  720. instance=_st(_st(_st($Smalltalk())._current())._at_("ObjectMock2"))._new();
  721. _st($ObjectMock())._subclass_instanceVariableNames_package_(_st(_st($Smalltalk())._current())._at_("ObjectMock2"),"","Kernel-Tests");
  722. _st(self)._deny_(_st(oldClass).__eq_eq($ObjectMock2()));
  723. _st(self)._assert_(_st(_st($ObjectMock2())._superclass()).__eq_eq($ObjectMock()));
  724. _st(self)._assert_(_st(_st($ObjectMock2())._instanceVariableNames())._isEmpty());
  725. _st(self)._assert_equals_(_st($ObjectMock2())._selectors(),_st(oldClass)._selectors());
  726. _st(self)._assert_equals_(_st($ObjectMock2())._comment(),_st(oldClass)._comment());
  727. _st(self)._assert_equals_(_st(_st($ObjectMock2())._package())._name(),"Kernel-Tests");
  728. _st(self)._deny_(_st(_st(instance)._class()).__eq_eq($ObjectMock2()));
  729. _st(self)._assert_(_st(_st(_st($Smalltalk())._current())._at_(_st(_st(instance)._class())._name()))._isNil());
  730. _st(_st($Smalltalk())._current())._removeClass_($ObjectMock2());
  731. return self}, function($ctx1) {$ctx1.fill(self,"testClassMigration",{instance:instance,oldClass:oldClass},smalltalk.ClassBuilderTest)})},
  732. args: [],
  733. source: "testClassMigration\x0a\x09| instance oldClass |\x0a\x09\x0a\x09oldClass := builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09instance := (Smalltalk current at: 'ObjectMock2') new.\x0a\x09\x0a\x09\x22Change the superclass of ObjectMock2\x22\x0a\x09ObjectMock subclass: (Smalltalk current at: 'ObjectMock2')\x0a\x09\x09instanceVariableNames: ''\x0a\x09\x09package: 'Kernel-Tests'.\x0a\x09\x0a\x09self deny: oldClass == ObjectMock2.\x0a\x09\x0a\x09self assert: ObjectMock2 superclass == ObjectMock.\x0a\x09self assert: ObjectMock2 instanceVariableNames isEmpty.\x0a\x09self assert: ObjectMock2 selectors equals: oldClass selectors.\x0a\x09self assert: ObjectMock2 comment equals: oldClass comment.\x0a\x09self assert: ObjectMock2 package name equals: 'Kernel-Tests'.\x0a\x09\x0a\x09self deny: instance class == ObjectMock2.\x0a\x09\x22Commeting this out. Tests implementation detail.\x22\x0a\x09\x22self assert: instance class name equals: 'OldObjectMock2'.\x22\x0a\x09\x0a\x09self assert: (Smalltalk current at: instance class name) isNil.\x0a\x09\x0a\x09Smalltalk current removeClass: ObjectMock2",
  734. messageSends: ["copyClass:named:", "new", "at:", "current", "subclass:instanceVariableNames:package:", "deny:", "==", "assert:", "superclass", "isEmpty", "instanceVariableNames", "assert:equals:", "selectors", "comment", "name", "package", "class", "isNil", "removeClass:"],
  735. referencedClasses: ["ObjectMock", "Smalltalk", "ObjectMock2"]
  736. }),
  737. smalltalk.ClassBuilderTest);
  738. smalltalk.addMethod(
  739. smalltalk.method({
  740. selector: "testClassMigrationWithClassInstanceVariables",
  741. category: 'tests',
  742. fn: function (){
  743. var self=this;
  744. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  745. function $ObjectMock2(){return smalltalk.ObjectMock2||(typeof ObjectMock2=="undefined"?nil:ObjectMock2)}
  746. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  747. return smalltalk.withContext(function($ctx1) {
  748. _st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  749. _st(_st($ObjectMock2())._class())._instanceVariableNames_("foo bar");
  750. _st($ObjectMock())._subclass_instanceVariableNames_package_(_st(_st($Smalltalk())._current())._at_("ObjectMock2"),"","Kernel-Tests");
  751. _st(self)._assert_equals_(_st(_st($ObjectMock2())._class())._instanceVariableNames(),["foo", "bar"]);
  752. _st(_st($Smalltalk())._current())._removeClass_($ObjectMock2());
  753. return self}, function($ctx1) {$ctx1.fill(self,"testClassMigrationWithClassInstanceVariables",{},smalltalk.ClassBuilderTest)})},
  754. args: [],
  755. source: "testClassMigrationWithClassInstanceVariables\x0a\x09\x0a\x09builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09ObjectMock2 class instanceVariableNames: 'foo bar'.\x0a\x09\x0a\x09\x22Change the superclass of ObjectMock2\x22\x0a\x09ObjectMock subclass: (Smalltalk current at: 'ObjectMock2')\x0a\x09\x09instanceVariableNames: ''\x0a\x09\x09package: 'Kernel-Tests'.\x0a\x09\x0a\x09self assert: ObjectMock2 class instanceVariableNames equals: #('foo' 'bar').\x0a\x09\x0a\x09Smalltalk current removeClass: ObjectMock2",
  756. messageSends: ["copyClass:named:", "instanceVariableNames:", "class", "subclass:instanceVariableNames:package:", "at:", "current", "assert:equals:", "instanceVariableNames", "removeClass:"],
  757. referencedClasses: ["ObjectMock", "ObjectMock2", "Smalltalk"]
  758. }),
  759. smalltalk.ClassBuilderTest);
  760. smalltalk.addMethod(
  761. smalltalk.method({
  762. selector: "testClassMigrationWithSubclasses",
  763. category: 'tests',
  764. fn: function (){
  765. var self=this;
  766. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  767. function $ObjectMock2(){return smalltalk.ObjectMock2||(typeof ObjectMock2=="undefined"?nil:ObjectMock2)}
  768. function $ObjectMock3(){return smalltalk.ObjectMock3||(typeof ObjectMock3=="undefined"?nil:ObjectMock3)}
  769. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  770. function $ObjectMock4(){return smalltalk.ObjectMock4||(typeof ObjectMock4=="undefined"?nil:ObjectMock4)}
  771. return smalltalk.withContext(function($ctx1) {
  772. _st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  773. _st($ObjectMock2())._subclass_instanceVariableNames_package_("ObjectMock3","","Kernel-Tests");
  774. _st($ObjectMock3())._subclass_instanceVariableNames_package_("ObjectMock4","","Kernel-Tests");
  775. _st($ObjectMock())._subclass_instanceVariableNames_package_(_st(_st($Smalltalk())._current())._at_("ObjectMock2"),"","Kernel-Tests");
  776. _st(self)._assert_(_st(_st($ObjectMock())._subclasses())._includes_($ObjectMock2()));
  777. _st(self)._assert_(_st(_st($ObjectMock2())._subclasses())._includes_($ObjectMock3()));
  778. _st(self)._assert_(_st(_st($ObjectMock3())._subclasses())._includes_($ObjectMock4()));
  779. _st(_st($ObjectMock())._allSubclasses())._do_((function(each){
  780. return smalltalk.withContext(function($ctx2) {
  781. return _st(_st($Smalltalk())._current())._removeClass_(each);
  782. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  783. return self}, function($ctx1) {$ctx1.fill(self,"testClassMigrationWithSubclasses",{},smalltalk.ClassBuilderTest)})},
  784. args: [],
  785. source: "testClassMigrationWithSubclasses\x0a\x09\x0a\x09builder copyClass: ObjectMock named: 'ObjectMock2'.\x0a\x09ObjectMock2 subclass: 'ObjectMock3' instanceVariableNames: '' package: 'Kernel-Tests'.\x0a\x09ObjectMock3 subclass: 'ObjectMock4' instanceVariableNames: '' package: 'Kernel-Tests'.\x0a\x09\x0a\x09\x22Change the superclass of ObjectMock2\x22\x0a\x09ObjectMock subclass: (Smalltalk current at: 'ObjectMock2')\x0a\x09\x09instanceVariableNames: ''\x0a\x09\x09package: 'Kernel-Tests'.\x0a\x09\x0a\x09self assert: (ObjectMock subclasses includes: ObjectMock2).\x0a\x09self assert: (ObjectMock2 subclasses includes: ObjectMock3).\x0a\x09self assert: (ObjectMock3 subclasses includes: ObjectMock4).\x0a\x09\x0a\x09ObjectMock allSubclasses do: [ :each | Smalltalk current removeClass: each ]",
  786. messageSends: ["copyClass:named:", "subclass:instanceVariableNames:package:", "at:", "current", "assert:", "includes:", "subclasses", "do:", "removeClass:", "allSubclasses"],
  787. referencedClasses: ["ObjectMock", "ObjectMock2", "ObjectMock3", "Smalltalk", "ObjectMock4"]
  788. }),
  789. smalltalk.ClassBuilderTest);
  790. smalltalk.addMethod(
  791. smalltalk.method({
  792. selector: "testInstanceVariableNames",
  793. category: 'tests',
  794. fn: function (){
  795. var self=this;
  796. return smalltalk.withContext(function($ctx1) {
  797. _st(self)._assert_equals_(_st(self["@builder"])._instanceVariableNamesFor_(" hello world "),["hello", "world"]);
  798. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVariableNames",{},smalltalk.ClassBuilderTest)})},
  799. args: [],
  800. source: "testInstanceVariableNames\x0a\x09self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')",
  801. messageSends: ["assert:equals:", "instanceVariableNamesFor:"],
  802. referencedClasses: []
  803. }),
  804. smalltalk.ClassBuilderTest);
  805. smalltalk.addClass('CollectionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  806. smalltalk.addMethod(
  807. smalltalk.method({
  808. selector: "assertSameContents:as:",
  809. category: 'convenience',
  810. fn: function (aCollection,anotherCollection){
  811. var self=this;
  812. return smalltalk.withContext(function($ctx1) {
  813. _st(self)._assert_(_st(_st(aCollection)._size()).__eq(_st(anotherCollection)._size()));
  814. _st(aCollection)._do_((function(each){
  815. return smalltalk.withContext(function($ctx2) {
  816. return _st(self)._assert_(_st(_st(aCollection)._occurrencesOf_(each)).__eq(_st(anotherCollection)._occurrencesOf_(each)));
  817. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  818. return self}, function($ctx1) {$ctx1.fill(self,"assertSameContents:as:",{aCollection:aCollection,anotherCollection:anotherCollection},smalltalk.CollectionTest)})},
  819. args: ["aCollection", "anotherCollection"],
  820. source: "assertSameContents: aCollection as: anotherCollection\x0a\x09self assert: (aCollection size = anotherCollection size).\x0a\x09aCollection do: [ :each |\x0a\x09\x09self assert: ((aCollection occurrencesOf: each) = (anotherCollection occurrencesOf: each)) ]",
  821. messageSends: ["assert:", "=", "size", "do:", "occurrencesOf:"],
  822. referencedClasses: []
  823. }),
  824. smalltalk.CollectionTest);
  825. smalltalk.addMethod(
  826. smalltalk.method({
  827. selector: "collection",
  828. category: 'accessing',
  829. fn: function (){
  830. var self=this;
  831. return smalltalk.withContext(function($ctx1) {
  832. var $1;
  833. $1=_st(_st(self)._collectionClass())._withAll_(_st(self)._defaultValues());
  834. return $1;
  835. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.CollectionTest)})},
  836. args: [],
  837. source: "collection\x0a\x09^ self collectionClass withAll: self defaultValues",
  838. messageSends: ["withAll:", "defaultValues", "collectionClass"],
  839. referencedClasses: []
  840. }),
  841. smalltalk.CollectionTest);
  842. smalltalk.addMethod(
  843. smalltalk.method({
  844. selector: "collectionClass",
  845. category: 'accessing',
  846. fn: function (){
  847. var self=this;
  848. return smalltalk.withContext(function($ctx1) {
  849. var $1;
  850. $1=_st(_st(self)._class())._collectionClass();
  851. return $1;
  852. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.CollectionTest)})},
  853. args: [],
  854. source: "collectionClass\x0a\x09^ self class collectionClass",
  855. messageSends: ["collectionClass", "class"],
  856. referencedClasses: []
  857. }),
  858. smalltalk.CollectionTest);
  859. smalltalk.addMethod(
  860. smalltalk.method({
  861. selector: "collectionWithDuplicates",
  862. category: 'accessing',
  863. fn: function (){
  864. var self=this;
  865. return smalltalk.withContext(function($ctx1) {
  866. var $1;
  867. $1=_st(_st(self)._collectionClass())._withAll_(["a", "b", "c", (1), (2), (1), "a"]);
  868. return $1;
  869. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.CollectionTest)})},
  870. args: [],
  871. source: "collectionWithDuplicates\x0a\x09^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')",
  872. messageSends: ["withAll:", "collectionClass"],
  873. referencedClasses: []
  874. }),
  875. smalltalk.CollectionTest);
  876. smalltalk.addMethod(
  877. smalltalk.method({
  878. selector: "defaultValues",
  879. category: 'accessing',
  880. fn: function (){
  881. var self=this;
  882. return smalltalk.withContext(function($ctx1) {
  883. var $1;
  884. $1=[(1), (2), (3), (-4)];
  885. return $1;
  886. }, function($ctx1) {$ctx1.fill(self,"defaultValues",{},smalltalk.CollectionTest)})},
  887. args: [],
  888. source: "defaultValues\x0a\x09^ #(1 2 3 -4)",
  889. messageSends: [],
  890. referencedClasses: []
  891. }),
  892. smalltalk.CollectionTest);
  893. smalltalk.addMethod(
  894. smalltalk.method({
  895. selector: "isCollectionReadOnly",
  896. category: 'testing',
  897. fn: function (){
  898. var self=this;
  899. return smalltalk.withContext(function($ctx1) {
  900. return false;
  901. }, function($ctx1) {$ctx1.fill(self,"isCollectionReadOnly",{},smalltalk.CollectionTest)})},
  902. args: [],
  903. source: "isCollectionReadOnly\x0a\x09^ false",
  904. messageSends: [],
  905. referencedClasses: []
  906. }),
  907. smalltalk.CollectionTest);
  908. smalltalk.addMethod(
  909. smalltalk.method({
  910. selector: "testAsArray",
  911. category: 'tests',
  912. fn: function (){
  913. var self=this;
  914. return smalltalk.withContext(function($ctx1) {
  915. _st(self)._assertSameContents_as_(_st(self)._collection(),_st(_st(self)._collection())._asArray());
  916. return self}, function($ctx1) {$ctx1.fill(self,"testAsArray",{},smalltalk.CollectionTest)})},
  917. args: [],
  918. source: "testAsArray\x0a\x09self\x0a\x09\x09assertSameContents: self collection\x0a\x09\x09as: self collection asArray",
  919. messageSends: ["assertSameContents:as:", "collection", "asArray"],
  920. referencedClasses: []
  921. }),
  922. smalltalk.CollectionTest);
  923. smalltalk.addMethod(
  924. smalltalk.method({
  925. selector: "testAsOrderedCollection",
  926. category: 'tests',
  927. fn: function (){
  928. var self=this;
  929. return smalltalk.withContext(function($ctx1) {
  930. _st(self)._assertSameContents_as_(_st(self)._collection(),_st(_st(self)._collection())._asOrderedCollection());
  931. return self}, function($ctx1) {$ctx1.fill(self,"testAsOrderedCollection",{},smalltalk.CollectionTest)})},
  932. args: [],
  933. source: "testAsOrderedCollection\x0a\x09self\x0a\x09\x09assertSameContents: self collection\x0a\x09\x09as: self collection asOrderedCollection",
  934. messageSends: ["assertSameContents:as:", "collection", "asOrderedCollection"],
  935. referencedClasses: []
  936. }),
  937. smalltalk.CollectionTest);
  938. smalltalk.addMethod(
  939. smalltalk.method({
  940. selector: "testAsSet",
  941. category: 'tests',
  942. fn: function (){
  943. var self=this;
  944. var c,set;
  945. return smalltalk.withContext(function($ctx1) {
  946. c=_st(self)._collectionWithDuplicates();
  947. set=_st(c)._asSet();
  948. _st(self)._assert_equals_(_st(set)._size(),(5));
  949. _st(c)._do_((function(each){
  950. return smalltalk.withContext(function($ctx2) {
  951. return _st(self)._assert_(_st(set)._includes_(each));
  952. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  953. return self}, function($ctx1) {$ctx1.fill(self,"testAsSet",{c:c,set:set},smalltalk.CollectionTest)})},
  954. args: [],
  955. source: "testAsSet\x0a\x09| c set |\x0a\x09c := self collectionWithDuplicates.\x0a\x09set := c asSet.\x0a\x09self assert: set size equals: 5.\x0a\x09c do: [ :each |\x0a\x09\x09self assert: (set includes: each) ]",
  956. messageSends: ["collectionWithDuplicates", "asSet", "assert:equals:", "size", "do:", "assert:", "includes:"],
  957. referencedClasses: []
  958. }),
  959. smalltalk.CollectionTest);
  960. smalltalk.addMethod(
  961. smalltalk.method({
  962. selector: "testCollect",
  963. category: 'tests',
  964. fn: function (){
  965. var self=this;
  966. var newCollection;
  967. return smalltalk.withContext(function($ctx1) {
  968. newCollection=[(1), (2), (3), (4)];
  969. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._collect_((function(each){
  970. return smalltalk.withContext(function($ctx2) {
  971. return _st(each)._abs();
  972. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})),newCollection);
  973. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{newCollection:newCollection},smalltalk.CollectionTest)})},
  974. args: [],
  975. 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",
  976. messageSends: ["assertSameContents:as:", "collect:", "abs", "collection"],
  977. referencedClasses: []
  978. }),
  979. smalltalk.CollectionTest);
  980. smalltalk.addMethod(
  981. smalltalk.method({
  982. selector: "testDetect",
  983. category: 'tests',
  984. fn: function (){
  985. var self=this;
  986. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  987. return smalltalk.withContext(function($ctx1) {
  988. _st(self)._assert_equals_(_st(_st(self)._collection())._detect_((function(each){
  989. return smalltalk.withContext(function($ctx2) {
  990. return _st(each).__lt((0));
  991. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})),(-4));
  992. _st(self)._should_raise_((function(){
  993. return smalltalk.withContext(function($ctx2) {
  994. return _st(_st(self)._collection())._detect_((function(each){
  995. return smalltalk.withContext(function($ctx3) {
  996. return _st(each).__eq((6));
  997. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  998. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  999. return self}, function($ctx1) {$ctx1.fill(self,"testDetect",{},smalltalk.CollectionTest)})},
  1000. args: [],
  1001. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each < 0 ]) equals: -4.\x0a\x09self\x0a\x09\x09should: [ self collection detect: [ :each | each = 6 ] ]\x0a\x09\x09raise: Error",
  1002. messageSends: ["assert:equals:", "detect:", "<", "collection", "should:raise:", "="],
  1003. referencedClasses: ["Error"]
  1004. }),
  1005. smalltalk.CollectionTest);
  1006. smalltalk.addMethod(
  1007. smalltalk.method({
  1008. selector: "testDo",
  1009. category: 'tests',
  1010. fn: function (){
  1011. var self=this;
  1012. var newCollection;
  1013. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1014. return smalltalk.withContext(function($ctx1) {
  1015. newCollection=_st($OrderedCollection())._new();
  1016. _st(_st(self)._collection())._do_((function(each){
  1017. return smalltalk.withContext(function($ctx2) {
  1018. return _st(newCollection)._add_(each);
  1019. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1020. _st(self)._assertSameContents_as_(_st(self)._collection(),newCollection);
  1021. return self}, function($ctx1) {$ctx1.fill(self,"testDo",{newCollection:newCollection},smalltalk.CollectionTest)})},
  1022. args: [],
  1023. 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",
  1024. messageSends: ["new", "do:", "add:", "collection", "assertSameContents:as:"],
  1025. referencedClasses: ["OrderedCollection"]
  1026. }),
  1027. smalltalk.CollectionTest);
  1028. smalltalk.addMethod(
  1029. smalltalk.method({
  1030. selector: "testIsEmpty",
  1031. category: 'tests',
  1032. fn: function (){
  1033. var self=this;
  1034. return smalltalk.withContext(function($ctx1) {
  1035. _st(self)._assert_(_st(_st(_st(self)._collectionClass())._new())._isEmpty());
  1036. _st(self)._deny_(_st(_st(self)._collection())._isEmpty());
  1037. return self}, function($ctx1) {$ctx1.fill(self,"testIsEmpty",{},smalltalk.CollectionTest)})},
  1038. args: [],
  1039. source: "testIsEmpty\x0a\x09self assert: self collectionClass new isEmpty.\x0a\x09self deny: self collection isEmpty",
  1040. messageSends: ["assert:", "isEmpty", "new", "collectionClass", "deny:", "collection"],
  1041. referencedClasses: []
  1042. }),
  1043. smalltalk.CollectionTest);
  1044. smalltalk.addMethod(
  1045. smalltalk.method({
  1046. selector: "testSelect",
  1047. category: 'tests',
  1048. fn: function (){
  1049. var self=this;
  1050. var newCollection;
  1051. return smalltalk.withContext(function($ctx1) {
  1052. newCollection=[(2), (-4)];
  1053. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._select_((function(each){
  1054. return smalltalk.withContext(function($ctx2) {
  1055. return _st(each)._even();
  1056. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})),newCollection);
  1057. return self}, function($ctx1) {$ctx1.fill(self,"testSelect",{newCollection:newCollection},smalltalk.CollectionTest)})},
  1058. args: [],
  1059. 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",
  1060. messageSends: ["assertSameContents:as:", "select:", "even", "collection"],
  1061. referencedClasses: []
  1062. }),
  1063. smalltalk.CollectionTest);
  1064. smalltalk.addMethod(
  1065. smalltalk.method({
  1066. selector: "testSize",
  1067. category: 'tests',
  1068. fn: function (){
  1069. var self=this;
  1070. return smalltalk.withContext(function($ctx1) {
  1071. _st(self)._assert_equals_(_st(_st(_st(self)._collectionClass())._new())._size(),(0));
  1072. _st(self)._assert_equals_(_st(_st(self)._collection())._size(),(4));
  1073. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.CollectionTest)})},
  1074. args: [],
  1075. source: "testSize\x0a\x09self assert: self collectionClass new size equals: 0.\x0a\x09self assert: self collection size equals: 4",
  1076. messageSends: ["assert:equals:", "size", "new", "collectionClass", "collection"],
  1077. referencedClasses: []
  1078. }),
  1079. smalltalk.CollectionTest);
  1080. smalltalk.addMethod(
  1081. smalltalk.method({
  1082. selector: "collectionClass",
  1083. category: 'accessing',
  1084. fn: function (){
  1085. var self=this;
  1086. return smalltalk.withContext(function($ctx1) {
  1087. return nil;
  1088. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.CollectionTest.klass)})},
  1089. args: [],
  1090. source: "collectionClass\x0a\x09^ nil",
  1091. messageSends: [],
  1092. referencedClasses: []
  1093. }),
  1094. smalltalk.CollectionTest.klass);
  1095. smalltalk.addMethod(
  1096. smalltalk.method({
  1097. selector: "isAbstract",
  1098. category: 'testing',
  1099. fn: function (){
  1100. var self=this;
  1101. return smalltalk.withContext(function($ctx1) {
  1102. var $1;
  1103. $1=_st(_st(self)._collectionClass())._isNil();
  1104. return $1;
  1105. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.CollectionTest.klass)})},
  1106. args: [],
  1107. source: "isAbstract\x0a\x09^ self collectionClass isNil",
  1108. messageSends: ["isNil", "collectionClass"],
  1109. referencedClasses: []
  1110. }),
  1111. smalltalk.CollectionTest.klass);
  1112. smalltalk.addClass('IndexableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
  1113. smalltalk.addMethod(
  1114. smalltalk.method({
  1115. selector: "testAt",
  1116. category: 'tests',
  1117. fn: function (){
  1118. var self=this;
  1119. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1120. return smalltalk.withContext(function($ctx1) {
  1121. _st(self)._assert_equals_(_st(_st(self)._collection())._at_((4)),(-4));
  1122. _st(self)._should_raise_((function(){
  1123. return smalltalk.withContext(function($ctx2) {
  1124. return _st(_st(self)._collection())._at_((5));
  1125. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  1126. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.IndexableCollectionTest)})},
  1127. args: [],
  1128. source: "testAt\x0a\x09self assert: (self collection at: 4) equals: -4.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
  1129. messageSends: ["assert:equals:", "at:", "collection", "should:raise:"],
  1130. referencedClasses: ["Error"]
  1131. }),
  1132. smalltalk.IndexableCollectionTest);
  1133. smalltalk.addMethod(
  1134. smalltalk.method({
  1135. selector: "testAtIfAbsent",
  1136. category: 'tests',
  1137. fn: function (){
  1138. var self=this;
  1139. return smalltalk.withContext(function($ctx1) {
  1140. _st(self)._assert_equals_(_st(_st(self)._collection())._at_ifAbsent_(_st(_st(_st(self)._collection())._size()).__plus((1)),(function(){
  1141. return smalltalk.withContext(function($ctx2) {
  1142. return "none";
  1143. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"none");
  1144. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{},smalltalk.IndexableCollectionTest)})},
  1145. args: [],
  1146. source: "testAtIfAbsent\x0a\x09self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) equals: 'none'",
  1147. messageSends: ["assert:equals:", "at:ifAbsent:", "+", "size", "collection"],
  1148. referencedClasses: []
  1149. }),
  1150. smalltalk.IndexableCollectionTest);
  1151. smalltalk.addMethod(
  1152. smalltalk.method({
  1153. selector: "testIndexOf",
  1154. category: 'tests',
  1155. fn: function (){
  1156. var self=this;
  1157. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1158. return smalltalk.withContext(function($ctx1) {
  1159. _st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_((2)),(2));
  1160. _st(self)._should_raise_((function(){
  1161. return smalltalk.withContext(function($ctx2) {
  1162. return _st(_st(self)._collection())._indexOf_((999));
  1163. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  1164. _st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
  1165. return smalltalk.withContext(function($ctx2) {
  1166. return "sentinel";
  1167. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
  1168. return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.IndexableCollectionTest)})},
  1169. args: [],
  1170. source: "testIndexOf\x0a\x09self assert: (self collection indexOf: 2) equals: 2.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
  1171. messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
  1172. referencedClasses: ["Error"]
  1173. }),
  1174. smalltalk.IndexableCollectionTest);
  1175. smalltalk.addMethod(
  1176. smalltalk.method({
  1177. selector: "testWithIndexDo",
  1178. category: 'tests',
  1179. fn: function (){
  1180. var self=this;
  1181. var collection;
  1182. return smalltalk.withContext(function($ctx1) {
  1183. collection=_st(self)._collection();
  1184. _st(_st(self)._collection())._withIndexDo_((function(each,index){
  1185. return smalltalk.withContext(function($ctx2) {
  1186. return _st(self)._assert_equals_(_st(collection)._at_(index),each);
  1187. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1)})}));
  1188. return self}, function($ctx1) {$ctx1.fill(self,"testWithIndexDo",{collection:collection},smalltalk.IndexableCollectionTest)})},
  1189. args: [],
  1190. source: "testWithIndexDo\x0a\x09| collection |\x0a\x09collection := self collection.\x0a\x09\x0a\x09self collection withIndexDo: [ :each :index |\x0a\x09\x09self assert: (collection at: index) equals: each ]",
  1191. messageSends: ["collection", "withIndexDo:", "assert:equals:", "at:"],
  1192. referencedClasses: []
  1193. }),
  1194. smalltalk.IndexableCollectionTest);
  1195. smalltalk.addClass('HashedCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
  1196. smalltalk.addMethod(
  1197. smalltalk.method({
  1198. selector: "collection",
  1199. category: 'accessing',
  1200. fn: function (){
  1201. var self=this;
  1202. return smalltalk.withContext(function($ctx1) {
  1203. var $1;
  1204. $1=smalltalk.HashedCollection._fromPairs_([_st("b").__minus_gt((1)),_st("a").__minus_gt((2)),_st("c").__minus_gt((3)),_st("d").__minus_gt((-4))]);
  1205. return $1;
  1206. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.HashedCollectionTest)})},
  1207. args: [],
  1208. source: "collection\x0a\x09^ #{ 'b' -> 1. 'a' -> 2. 'c' -> 3. 'd' -> -4 }",
  1209. messageSends: ["->"],
  1210. referencedClasses: []
  1211. }),
  1212. smalltalk.HashedCollectionTest);
  1213. smalltalk.addMethod(
  1214. smalltalk.method({
  1215. selector: "collectionWithDuplicates",
  1216. category: 'accessing',
  1217. fn: function (){
  1218. var self=this;
  1219. return smalltalk.withContext(function($ctx1) {
  1220. var $1;
  1221. $1=smalltalk.HashedCollection._fromPairs_([_st("b").__minus_gt((1)),_st("a").__minus_gt((2)),_st("c").__minus_gt((3)),_st("d").__minus_gt((-4)),_st("e").__minus_gt((1)),_st("f").__minus_gt((2)),_st("g").__minus_gt((10))]);
  1222. return $1;
  1223. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.HashedCollectionTest)})},
  1224. args: [],
  1225. source: "collectionWithDuplicates\x0a\x09^ #{ 'b' -> 1. 'a' -> 2. 'c' -> 3. 'd' -> -4. 'e' -> 1. 'f' -> 2. 'g' -> 10 }",
  1226. messageSends: ["->"],
  1227. referencedClasses: []
  1228. }),
  1229. smalltalk.HashedCollectionTest);
  1230. smalltalk.addMethod(
  1231. smalltalk.method({
  1232. selector: "testAt",
  1233. category: 'tests',
  1234. fn: function (){
  1235. var self=this;
  1236. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1237. return smalltalk.withContext(function($ctx1) {
  1238. _st(self)._assert_equals_(_st(_st(self)._collection())._at_("a"),(2));
  1239. _st(self)._should_raise_((function(){
  1240. return smalltalk.withContext(function($ctx2) {
  1241. return _st(_st(self)._collection())._at_((5));
  1242. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  1243. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.HashedCollectionTest)})},
  1244. args: [],
  1245. source: "testAt\x0a\x09self assert: (self collection at: 'a') equals: 2.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
  1246. messageSends: ["assert:equals:", "at:", "collection", "should:raise:"],
  1247. referencedClasses: ["Error"]
  1248. }),
  1249. smalltalk.HashedCollectionTest);
  1250. smalltalk.addMethod(
  1251. smalltalk.method({
  1252. selector: "testIndexOf",
  1253. category: 'tests',
  1254. fn: function (){
  1255. var self=this;
  1256. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1257. return smalltalk.withContext(function($ctx1) {
  1258. _st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_((2)),"a");
  1259. _st(self)._should_raise_((function(){
  1260. return smalltalk.withContext(function($ctx2) {
  1261. return _st(_st(self)._collection())._indexOf_((999));
  1262. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  1263. _st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
  1264. return smalltalk.withContext(function($ctx2) {
  1265. return "sentinel";
  1266. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
  1267. return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.HashedCollectionTest)})},
  1268. args: [],
  1269. source: "testIndexOf\x0a\x09self assert: (self collection indexOf: 2) equals: 'a'.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
  1270. messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
  1271. referencedClasses: ["Error"]
  1272. }),
  1273. smalltalk.HashedCollectionTest);
  1274. smalltalk.addMethod(
  1275. smalltalk.method({
  1276. selector: "collectionClass",
  1277. category: 'accessing',
  1278. fn: function (){
  1279. var self=this;
  1280. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1281. return smalltalk.withContext(function($ctx1) {
  1282. var $1;
  1283. $1=$HashedCollection();
  1284. return $1;
  1285. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.HashedCollectionTest.klass)})},
  1286. args: [],
  1287. source: "collectionClass\x0a\x09^ HashedCollection",
  1288. messageSends: [],
  1289. referencedClasses: ["HashedCollection"]
  1290. }),
  1291. smalltalk.HashedCollectionTest.klass);
  1292. smalltalk.addClass('DictionaryTest', smalltalk.HashedCollectionTest, [], 'Kernel-Tests');
  1293. smalltalk.addMethod(
  1294. smalltalk.method({
  1295. selector: "collection",
  1296. category: 'accessing',
  1297. fn: function (){
  1298. var self=this;
  1299. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1300. return smalltalk.withContext(function($ctx1) {
  1301. var $2,$3,$1;
  1302. $2=_st($Dictionary())._new();
  1303. _st($2)._at_put_((1),(1));
  1304. _st($2)._at_put_("a",(2));
  1305. _st($2)._at_put_(true,(3));
  1306. _st($2)._at_put_((4),(-4));
  1307. $3=_st($2)._yourself();
  1308. $1=$3;
  1309. return $1;
  1310. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.DictionaryTest)})},
  1311. args: [],
  1312. 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",
  1313. messageSends: ["at:put:", "new", "yourself"],
  1314. referencedClasses: ["Dictionary"]
  1315. }),
  1316. smalltalk.DictionaryTest);
  1317. smalltalk.addMethod(
  1318. smalltalk.method({
  1319. selector: "collectionWithDuplicates",
  1320. category: 'accessing',
  1321. fn: function (){
  1322. var self=this;
  1323. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1324. return smalltalk.withContext(function($ctx1) {
  1325. var $2,$3,$1;
  1326. $2=_st($Dictionary())._new();
  1327. _st($2)._at_put_((1),(1));
  1328. _st($2)._at_put_("a",(2));
  1329. _st($2)._at_put_(true,(3));
  1330. _st($2)._at_put_((4),(-4));
  1331. _st($2)._at_put_("b",(1));
  1332. _st($2)._at_put_((3),(3));
  1333. _st($2)._at_put_(false,(12));
  1334. $3=_st($2)._yourself();
  1335. $1=$3;
  1336. return $1;
  1337. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.DictionaryTest)})},
  1338. args: [],
  1339. 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",
  1340. messageSends: ["at:put:", "new", "yourself"],
  1341. referencedClasses: ["Dictionary"]
  1342. }),
  1343. smalltalk.DictionaryTest);
  1344. smalltalk.addMethod(
  1345. smalltalk.method({
  1346. selector: "testAccessing",
  1347. category: 'tests',
  1348. fn: function (){
  1349. var self=this;
  1350. var d;
  1351. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1352. return smalltalk.withContext(function($ctx1) {
  1353. d=_st($Dictionary())._new();
  1354. _st(d)._at_put_("hello","world");
  1355. _st(self)._assert_equals_(_st(d)._at_("hello"),"world");
  1356. _st(self)._assert_equals_(_st(d)._at_ifAbsent_("hello",(function(){
  1357. return smalltalk.withContext(function($ctx2) {
  1358. return nil;
  1359. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"world");
  1360. _st(self)._deny_(_st(_st(d)._at_ifAbsent_("foo",(function(){
  1361. return smalltalk.withContext(function($ctx2) {
  1362. return nil;
  1363. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))).__eq("world"));
  1364. _st(self)._assert_(_st(d)._includesKey_("hello"));
  1365. _st(self)._deny_(_st(d)._includesKey_("foo"));
  1366. _st(d)._at_put_((1),(2));
  1367. _st(self)._assert_equals_(_st(d)._at_((1)),(2));
  1368. _st(d)._at_put_(_st((1)).__at((3)),(3));
  1369. _st(self)._assert_equals_(_st(d)._at_(_st((1)).__at((3))),(3));
  1370. _st(self)._assert_(_st(d)._includesKey_(_st((1)).__at((3))));
  1371. _st(self)._deny_(_st(d)._includesKey_(_st((3)).__at((1))));
  1372. return self}, function($ctx1) {$ctx1.fill(self,"testAccessing",{d:d},smalltalk.DictionaryTest)})},
  1373. args: [],
  1374. source: "testAccessing\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x0a\x09d at: 'hello' put: 'world'.\x0a\x09self assert: (d at: 'hello') equals: 'world'.\x0a\x09self assert: (d at: 'hello' ifAbsent: [nil]) equals: 'world'.\x0a\x09self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.\x0a\x0a\x09self assert: (d includesKey: 'hello').\x0a\x09self deny: (d includesKey: 'foo').\x0a\x0a\x09d at: 1 put: 2.\x0a\x09self assert: (d at: 1) equals: 2.\x0a\x0a\x09d at: 1@3 put: 3.\x0a\x09self assert: (d at: 1@3) equals: 3.\x0a\x0a\x09self assert: (d includesKey: 1@3).\x0a\x09self deny: (d includesKey: 3@1)",
  1375. messageSends: ["new", "at:put:", "assert:equals:", "at:", "at:ifAbsent:", "deny:", "=", "assert:", "includesKey:", "@"],
  1376. referencedClasses: ["Dictionary"]
  1377. }),
  1378. smalltalk.DictionaryTest);
  1379. smalltalk.addMethod(
  1380. smalltalk.method({
  1381. selector: "testDynamicDictionaries",
  1382. category: 'tests',
  1383. fn: function (){
  1384. var self=this;
  1385. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1386. return smalltalk.withContext(function($ctx1) {
  1387. _st(self)._assert_equals_(_st(smalltalk.HashedCollection._fromPairs_([_st("hello").__minus_gt((1))]))._asDictionary(),_st($Dictionary())._with_(_st("hello").__minus_gt((1))));
  1388. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaries",{},smalltalk.DictionaryTest)})},
  1389. args: [],
  1390. source: "testDynamicDictionaries\x0a\x09self assert: #{'hello' -> 1} asDictionary equals: (Dictionary with: 'hello' -> 1)",
  1391. messageSends: ["assert:equals:", "asDictionary", "->", "with:"],
  1392. referencedClasses: ["Dictionary"]
  1393. }),
  1394. smalltalk.DictionaryTest);
  1395. smalltalk.addMethod(
  1396. smalltalk.method({
  1397. selector: "testEquality",
  1398. category: 'tests',
  1399. fn: function (){
  1400. var self=this;
  1401. var d1,d2;
  1402. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1403. return smalltalk.withContext(function($ctx1) {
  1404. var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10;
  1405. _st(self)._assert_(_st(_st($Dictionary())._new()).__eq(_st($Dictionary())._new()));
  1406. $1=_st($Dictionary())._new();
  1407. _st($1)._at_put_((1),(2));
  1408. $2=_st($1)._yourself();
  1409. d1=$2;
  1410. $3=_st($Dictionary())._new();
  1411. _st($3)._at_put_((1),(2));
  1412. $4=_st($3)._yourself();
  1413. d2=$4;
  1414. _st(self)._assert_(_st(d1).__eq(d2));
  1415. $5=_st($Dictionary())._new();
  1416. _st($5)._at_put_((1),(3));
  1417. $6=_st($5)._yourself();
  1418. d2=$6;
  1419. _st(self)._deny_(_st(d1).__eq(d2));
  1420. $7=_st($Dictionary())._new();
  1421. _st($7)._at_put_((2),(2));
  1422. $8=_st($7)._yourself();
  1423. d2=$8;
  1424. _st(self)._deny_(_st(d1).__eq(d2));
  1425. $9=_st($Dictionary())._new();
  1426. _st($9)._at_put_((1),(2));
  1427. _st($9)._at_put_((3),(4));
  1428. $10=_st($9)._yourself();
  1429. d2=$10;
  1430. _st(self)._deny_(_st(d1).__eq(d2));
  1431. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{d1:d1,d2:d2},smalltalk.DictionaryTest)})},
  1432. args: [],
  1433. 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.",
  1434. messageSends: ["assert:", "=", "new", "at:put:", "yourself", "deny:"],
  1435. referencedClasses: ["Dictionary"]
  1436. }),
  1437. smalltalk.DictionaryTest);
  1438. smalltalk.addMethod(
  1439. smalltalk.method({
  1440. selector: "testIfAbsent",
  1441. category: 'tests',
  1442. fn: function (){
  1443. var self=this;
  1444. var d,visited;
  1445. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1446. return smalltalk.withContext(function($ctx1) {
  1447. visited=false;
  1448. d=_st($Dictionary())._new();
  1449. _st(d)._at_ifAbsent_("hello",(function(){
  1450. return smalltalk.withContext(function($ctx2) {
  1451. visited=true;
  1452. return visited;
  1453. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1454. _st(self)._assert_(visited);
  1455. return self}, function($ctx1) {$ctx1.fill(self,"testIfAbsent",{d:d,visited:visited},smalltalk.DictionaryTest)})},
  1456. args: [],
  1457. 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.",
  1458. messageSends: ["new", "at:ifAbsent:", "assert:"],
  1459. referencedClasses: ["Dictionary"]
  1460. }),
  1461. smalltalk.DictionaryTest);
  1462. smalltalk.addMethod(
  1463. smalltalk.method({
  1464. selector: "testIfPresent",
  1465. category: 'tests',
  1466. fn: function (){
  1467. var self=this;
  1468. var d,visited,absent;
  1469. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1470. return smalltalk.withContext(function($ctx1) {
  1471. visited=false;
  1472. d=_st($Dictionary())._new();
  1473. _st(d)._at_put_("hello","world");
  1474. _st(d)._at_ifPresent_("hello",(function(value){
  1475. return smalltalk.withContext(function($ctx2) {
  1476. visited=value;
  1477. return visited;
  1478. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1479. _st(self)._assert_equals_(visited,"world");
  1480. absent=_st(d)._at_ifPresent_("bye",(function(value){
  1481. return smalltalk.withContext(function($ctx2) {
  1482. visited=value;
  1483. return visited;
  1484. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}));
  1485. _st(self)._assert_(_st(absent)._isNil());
  1486. return self}, function($ctx1) {$ctx1.fill(self,"testIfPresent",{d:d,visited:visited,absent:absent},smalltalk.DictionaryTest)})},
  1487. args: [],
  1488. 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 equals: 'world'.\x0a\x0a\x09absent := d at: 'bye' ifPresent: [ :value | visited := value ].\x0a\x09self assert: absent isNil.",
  1489. messageSends: ["new", "at:put:", "at:ifPresent:", "assert:equals:", "assert:", "isNil"],
  1490. referencedClasses: ["Dictionary"]
  1491. }),
  1492. smalltalk.DictionaryTest);
  1493. smalltalk.addMethod(
  1494. smalltalk.method({
  1495. selector: "testIfPresentIfAbsent",
  1496. category: 'tests',
  1497. fn: function (){
  1498. var self=this;
  1499. var d,visited;
  1500. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1501. return smalltalk.withContext(function($ctx1) {
  1502. visited=false;
  1503. d=_st($Dictionary())._new();
  1504. _st(d)._at_put_("hello","world");
  1505. _st(d)._at_ifPresent_ifAbsent_("hello",(function(value){
  1506. return smalltalk.withContext(function($ctx2) {
  1507. visited=value;
  1508. return visited;
  1509. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}),(function(){
  1510. return smalltalk.withContext(function($ctx2) {
  1511. visited=true;
  1512. return visited;
  1513. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1514. _st(self)._assert_equals_(visited,"world");
  1515. _st(d)._at_ifPresent_ifAbsent_("buy",(function(value){
  1516. return smalltalk.withContext(function($ctx2) {
  1517. visited=value;
  1518. return visited;
  1519. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1)})}),(function(){
  1520. return smalltalk.withContext(function($ctx2) {
  1521. visited=true;
  1522. return visited;
  1523. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  1524. _st(self)._assert_(visited);
  1525. return self}, function($ctx1) {$ctx1.fill(self,"testIfPresentIfAbsent",{d:d,visited:visited},smalltalk.DictionaryTest)})},
  1526. args: [],
  1527. 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 equals: 'world'.\x0a\x0a\x09d at: 'buy' ifPresent: [ :value | visited := value ] ifAbsent: [ visited := true ].\x0a\x09self assert: visited.",
  1528. messageSends: ["new", "at:put:", "at:ifPresent:ifAbsent:", "assert:equals:", "assert:"],
  1529. referencedClasses: ["Dictionary"]
  1530. }),
  1531. smalltalk.DictionaryTest);
  1532. smalltalk.addMethod(
  1533. smalltalk.method({
  1534. selector: "testKeys",
  1535. category: 'tests',
  1536. fn: function (){
  1537. var self=this;
  1538. var d;
  1539. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1540. return smalltalk.withContext(function($ctx1) {
  1541. d=_st($Dictionary())._new();
  1542. _st(d)._at_put_((1),(2));
  1543. _st(d)._at_put_((2),(3));
  1544. _st(d)._at_put_((3),(4));
  1545. _st(self)._assert_equals_(_st(d)._keys(),[(1), (2), (3)]);
  1546. return self}, function($ctx1) {$ctx1.fill(self,"testKeys",{d:d},smalltalk.DictionaryTest)})},
  1547. args: [],
  1548. 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 equals: #(1 2 3)",
  1549. messageSends: ["new", "at:put:", "assert:equals:", "keys"],
  1550. referencedClasses: ["Dictionary"]
  1551. }),
  1552. smalltalk.DictionaryTest);
  1553. smalltalk.addMethod(
  1554. smalltalk.method({
  1555. selector: "testPointKey",
  1556. category: 'tests',
  1557. fn: function (){
  1558. var self=this;
  1559. var d;
  1560. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1561. return smalltalk.withContext(function($ctx1) {
  1562. d=_st($Dictionary())._new();
  1563. _st(d)._at_put_(_st((1)).__at((1)),"foo");
  1564. _st(self)._assert_equals_(_st(d)._at_(_st((1)).__at((1))),"foo");
  1565. _st(d)._at_put_(_st((1)).__at((1)),"bar");
  1566. _st(self)._assert_equals_(_st(d)._at_(_st((1)).__at((1))),"bar");
  1567. _st(d)._removeKey_(_st((1)).__at((1)));
  1568. _st(self)._assert_equals_(_st(d)._at_ifAbsent_(_st((1)).__at((1)),(function(){
  1569. return smalltalk.withContext(function($ctx2) {
  1570. return "baz";
  1571. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"baz");
  1572. _st(self)._deny_(_st(d)._includesKey_(_st((1)).__at((1))));
  1573. return self}, function($ctx1) {$ctx1.fill(self,"testPointKey",{d:d},smalltalk.DictionaryTest)})},
  1574. args: [],
  1575. source: "testPointKey\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x09\x0a\x09d at: 1@1 put: 'foo'.\x0a\x09self assert: (d at: 1@1) equals: 'foo'.\x0a\x09d at: 1@1 put: 'bar'.\x0a\x09self assert: (d at: 1@1) equals: 'bar'.\x0a\x09d removeKey: 1@1.\x0a\x09self assert: (d at: 1@1 ifAbsent: [ 'baz' ]) equals: 'baz'.\x0a\x09self deny: (d includesKey: 1@1)",
  1576. messageSends: ["new", "at:put:", "@", "assert:equals:", "at:", "removeKey:", "at:ifAbsent:", "deny:", "includesKey:"],
  1577. referencedClasses: ["Dictionary"]
  1578. }),
  1579. smalltalk.DictionaryTest);
  1580. smalltalk.addMethod(
  1581. smalltalk.method({
  1582. selector: "testPrintString",
  1583. category: 'tests',
  1584. fn: function (){
  1585. var self=this;
  1586. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1587. return smalltalk.withContext(function($ctx1) {
  1588. var $1,$2;
  1589. $1=_st($Dictionary())._new();
  1590. _st($1)._at_put_("firstname","James");
  1591. _st($1)._at_put_("lastname","Bond");
  1592. $2=_st($1)._printString();
  1593. _st(self)._assert_equals_($2,"a Dictionary ('firstname' -> 'James' , 'lastname' -> 'Bond')");
  1594. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{},smalltalk.DictionaryTest)})},
  1595. args: [],
  1596. source: "testPrintString\x0a\x09self\x0a\x09\x09assert: (Dictionary new\x0a\x09\x09\x09\x09\x09\x09\x09at:'firstname' put: 'James';\x0a\x09\x09\x09\x09\x09\x09\x09at:'lastname' put: 'Bond';\x0a\x09\x09\x09\x09\x09\x09\x09printString)\x0a\x09\x09equals: 'a Dictionary (''firstname'' -> ''James'' , ''lastname'' -> ''Bond'')'",
  1597. messageSends: ["assert:equals:", "at:put:", "new", "printString"],
  1598. referencedClasses: ["Dictionary"]
  1599. }),
  1600. smalltalk.DictionaryTest);
  1601. smalltalk.addMethod(
  1602. smalltalk.method({
  1603. selector: "testRemoveKey",
  1604. category: 'tests',
  1605. fn: function (){
  1606. var self=this;
  1607. var d,key;
  1608. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1609. return smalltalk.withContext(function($ctx1) {
  1610. d=_st($Dictionary())._new();
  1611. _st(d)._at_put_((1),(2));
  1612. _st(d)._at_put_((2),(3));
  1613. _st(d)._at_put_((3),(4));
  1614. key=(2);
  1615. _st(self)._assert_equals_(_st(d)._keys(),[(1), (2), (3)]);
  1616. _st(d)._removeKey_(key);
  1617. _st(self)._assert_equals_(_st(d)._keys(),[(1), (3)]);
  1618. _st(self)._assert_equals_(_st(d)._values(),[(2), (4)]);
  1619. _st(self)._deny_(_st(d)._includesKey_((2)));
  1620. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveKey",{d:d,key:key},smalltalk.DictionaryTest)})},
  1621. args: [],
  1622. source: "testRemoveKey\x0a\x09| d key |\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\x09key := 2.\x0a\x0a\x09self assert: d keys equals: #(1 2 3).\x0a\x0a\x09d removeKey: key.\x0a\x09self assert: d keys equals: #(1 3).\x0a\x09self assert: d values equals: #(2 4).\x0a\x09self deny: (d includesKey: 2)",
  1623. messageSends: ["new", "at:put:", "assert:equals:", "keys", "removeKey:", "values", "deny:", "includesKey:"],
  1624. referencedClasses: ["Dictionary"]
  1625. }),
  1626. smalltalk.DictionaryTest);
  1627. smalltalk.addMethod(
  1628. smalltalk.method({
  1629. selector: "testRemoveKeyIfAbsent",
  1630. category: 'tests',
  1631. fn: function (){
  1632. var self=this;
  1633. var d,key;
  1634. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1635. return smalltalk.withContext(function($ctx1) {
  1636. d=_st($Dictionary())._new();
  1637. _st(d)._at_put_((1),(2));
  1638. _st(d)._at_put_((2),(3));
  1639. _st(d)._at_put_((3),(4));
  1640. key=(2);
  1641. _st(self)._assert_equals_(_st(d)._removeKey_(key),(3));
  1642. key=(3);
  1643. _st(self)._assert_equals_(_st(d)._removeKey_ifAbsent_(key,(function(){
  1644. return smalltalk.withContext(function($ctx2) {
  1645. return (42);
  1646. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),(4));
  1647. key="why";
  1648. _st(self)._assert_equals_(_st(d)._removeKey_ifAbsent_(key,(function(){
  1649. return smalltalk.withContext(function($ctx2) {
  1650. return (42);
  1651. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),(42));
  1652. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveKeyIfAbsent",{d:d,key:key},smalltalk.DictionaryTest)})},
  1653. args: [],
  1654. source: "testRemoveKeyIfAbsent\x0a\x09| d key |\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\x09key := 2.\x0a\x09self assert: (d removeKey: key) equals: 3.\x0a\x0a\x09key := 3.\x0a\x09self assert: (d removeKey: key ifAbsent: [42]) equals: 4.\x0a\x0a\x09key := 'why'.\x0a\x09self assert: (d removeKey: key ifAbsent: [42] ) equals: 42.",
  1655. messageSends: ["new", "at:put:", "assert:equals:", "removeKey:", "removeKey:ifAbsent:"],
  1656. referencedClasses: ["Dictionary"]
  1657. }),
  1658. smalltalk.DictionaryTest);
  1659. smalltalk.addMethod(
  1660. smalltalk.method({
  1661. selector: "testSize",
  1662. category: 'tests',
  1663. fn: function (){
  1664. var self=this;
  1665. var d;
  1666. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1667. return smalltalk.withContext(function($ctx1) {
  1668. d=_st($Dictionary())._new();
  1669. _st(self)._assert_equals_(_st(d)._size(),(0));
  1670. _st(d)._at_put_((1),(2));
  1671. _st(self)._assert_equals_(_st(d)._size(),(1));
  1672. _st(d)._at_put_((2),(3));
  1673. _st(self)._assert_equals_(_st(d)._size(),(2));
  1674. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{d:d},smalltalk.DictionaryTest)})},
  1675. args: [],
  1676. source: "testSize\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x09self assert: d size equals: 0.\x0a\x0a\x09d at: 1 put: 2.\x0a\x09self assert: d size equals: 1.\x0a\x0a\x09d at: 2 put: 3.\x0a\x09self assert: d size equals: 2.",
  1677. messageSends: ["new", "assert:equals:", "size", "at:put:"],
  1678. referencedClasses: ["Dictionary"]
  1679. }),
  1680. smalltalk.DictionaryTest);
  1681. smalltalk.addMethod(
  1682. smalltalk.method({
  1683. selector: "testValues",
  1684. category: 'tests',
  1685. fn: function (){
  1686. var self=this;
  1687. var d;
  1688. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1689. return smalltalk.withContext(function($ctx1) {
  1690. d=_st($Dictionary())._new();
  1691. _st(d)._at_put_((1),(2));
  1692. _st(d)._at_put_((2),(3));
  1693. _st(d)._at_put_((3),(4));
  1694. _st(self)._assert_equals_(_st(d)._values(),[(2), (3), (4)]);
  1695. return self}, function($ctx1) {$ctx1.fill(self,"testValues",{d:d},smalltalk.DictionaryTest)})},
  1696. args: [],
  1697. 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 equals: #(2 3 4)",
  1698. messageSends: ["new", "at:put:", "assert:equals:", "values"],
  1699. referencedClasses: ["Dictionary"]
  1700. }),
  1701. smalltalk.DictionaryTest);
  1702. smalltalk.addMethod(
  1703. smalltalk.method({
  1704. selector: "collectionClass",
  1705. category: 'accessing',
  1706. fn: function (){
  1707. var self=this;
  1708. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1709. return smalltalk.withContext(function($ctx1) {
  1710. var $1;
  1711. $1=$Dictionary();
  1712. return $1;
  1713. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.DictionaryTest.klass)})},
  1714. args: [],
  1715. source: "collectionClass\x0a\x09^ Dictionary",
  1716. messageSends: [],
  1717. referencedClasses: ["Dictionary"]
  1718. }),
  1719. smalltalk.DictionaryTest.klass);
  1720. smalltalk.addClass('SequenceableCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
  1721. smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1722. smalltalk.addMethod(
  1723. smalltalk.method({
  1724. selector: "testAtIfAbsent",
  1725. category: 'tests',
  1726. fn: function (){
  1727. var self=this;
  1728. var array;
  1729. return smalltalk.withContext(function($ctx1) {
  1730. array=["hello", "world"];
  1731. _st(self)._assert_equals_(_st(array)._at_((1)),"hello");
  1732. _st(self)._assert_equals_(_st(array)._at_((2)),"world");
  1733. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((2),(function(){
  1734. return smalltalk.withContext(function($ctx2) {
  1735. return "not found";
  1736. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"world");
  1737. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((0),(function(){
  1738. return smalltalk.withContext(function($ctx2) {
  1739. return "not found";
  1740. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"not found");
  1741. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((-10),(function(){
  1742. return smalltalk.withContext(function($ctx2) {
  1743. return "not found";
  1744. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"not found");
  1745. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((3),(function(){
  1746. return smalltalk.withContext(function($ctx2) {
  1747. return "not found";
  1748. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"not found");
  1749. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{array:array},smalltalk.ArrayTest)})},
  1750. args: [],
  1751. 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'.",
  1752. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  1753. referencedClasses: []
  1754. }),
  1755. smalltalk.ArrayTest);
  1756. smalltalk.addMethod(
  1757. smalltalk.method({
  1758. selector: "testFirstN",
  1759. category: 'tests',
  1760. fn: function (){
  1761. var self=this;
  1762. return smalltalk.withContext(function($ctx1) {
  1763. _st(self)._assert_equals_(_st([(1),(2),(3),(4),(5)])._first_((3)),[(1),(2),(3)]);
  1764. return self}, function($ctx1) {$ctx1.fill(self,"testFirstN",{},smalltalk.ArrayTest)})},
  1765. args: [],
  1766. source: "testFirstN\x0a\x09self assert: ({1. 2. 3. 4. 5} first: 3) equals: {1. 2. 3}",
  1767. messageSends: ["assert:equals:", "first:"],
  1768. referencedClasses: []
  1769. }),
  1770. smalltalk.ArrayTest);
  1771. smalltalk.addMethod(
  1772. smalltalk.method({
  1773. selector: "testIfEmpty",
  1774. category: 'tests',
  1775. fn: function (){
  1776. var self=this;
  1777. return smalltalk.withContext(function($ctx1) {
  1778. _st(self)._assert_equals_(_st("")._ifEmpty_((function(){
  1779. return smalltalk.withContext(function($ctx2) {
  1780. return "zork";
  1781. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"zork");
  1782. return self}, function($ctx1) {$ctx1.fill(self,"testIfEmpty",{},smalltalk.ArrayTest)})},
  1783. args: [],
  1784. source: "testIfEmpty\x0a\x09self assert: ( '' ifEmpty: ['zork'] ) equals: 'zork'",
  1785. messageSends: ["assert:equals:", "ifEmpty:"],
  1786. referencedClasses: []
  1787. }),
  1788. smalltalk.ArrayTest);
  1789. smalltalk.addMethod(
  1790. smalltalk.method({
  1791. selector: "testPrintString",
  1792. category: 'tests',
  1793. fn: function (){
  1794. var self=this;
  1795. var array;
  1796. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  1797. return smalltalk.withContext(function($ctx1) {
  1798. var $1,$2,$3,$4;
  1799. array=_st($Array())._new();
  1800. _st(self)._assert_equals_(_st(array)._printString(),"an Array ()");
  1801. $1=array;
  1802. _st($1)._add_((1));
  1803. $2=_st($1)._add_((3));
  1804. _st(self)._assert_equals_(_st(array)._printString(),"an Array (1 3)");
  1805. _st(array)._add_("foo");
  1806. _st(self)._assert_equals_(_st(array)._printString(),"an Array (1 3 'foo')");
  1807. $3=array;
  1808. _st($3)._remove_((1));
  1809. $4=_st($3)._remove_((3));
  1810. _st(self)._assert_equals_(_st(array)._printString(),"an Array ('foo')");
  1811. _st(array)._addLast_((3));
  1812. _st(self)._assert_equals_(_st(array)._printString(),"an Array ('foo' 3)");
  1813. _st(array)._addLast_((3));
  1814. _st(self)._assert_equals_(_st(array)._printString(),"an Array ('foo' 3 3)");
  1815. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{array:array},smalltalk.ArrayTest)})},
  1816. args: [],
  1817. source: "testPrintString\x0a\x09| array |\x0a\x09array := Array new.\x0a\x09self assert: array printString equals: 'an Array ()'.\x0a\x09array add: 1; add: 3.\x0a\x09self assert: array printString equals: 'an Array (1 3)'.\x0a\x09array add: 'foo'.\x0a\x09self assert: array printString equals: 'an Array (1 3 ''foo'')'.\x0a\x09array remove: 1; remove: 3.\x0a\x09self assert: array printString equals: 'an Array (''foo'')'.\x0a\x09array addLast: 3.\x0a\x09self assert: array printString equals: 'an Array (''foo'' 3)'.\x0a\x09array addLast: 3.\x0a\x09self assert: array printString equals: 'an Array (''foo'' 3 3)'.",
  1818. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:", "addLast:"],
  1819. referencedClasses: ["Array"]
  1820. }),
  1821. smalltalk.ArrayTest);
  1822. smalltalk.addMethod(
  1823. smalltalk.method({
  1824. selector: "collectionClass",
  1825. category: 'accessing',
  1826. fn: function (){
  1827. var self=this;
  1828. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  1829. return smalltalk.withContext(function($ctx1) {
  1830. var $1;
  1831. $1=$Array();
  1832. return $1;
  1833. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayTest.klass)})},
  1834. args: [],
  1835. source: "collectionClass\x0a\x09^ Array",
  1836. messageSends: [],
  1837. referencedClasses: ["Array"]
  1838. }),
  1839. smalltalk.ArrayTest.klass);
  1840. smalltalk.addClass('StringTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1841. smalltalk.addMethod(
  1842. smalltalk.method({
  1843. selector: "collection",
  1844. category: 'accessing',
  1845. fn: function (){
  1846. var self=this;
  1847. return smalltalk.withContext(function($ctx1) {
  1848. return "hello";
  1849. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.StringTest)})},
  1850. args: [],
  1851. source: "collection\x0a\x09^'hello'",
  1852. messageSends: [],
  1853. referencedClasses: []
  1854. }),
  1855. smalltalk.StringTest);
  1856. smalltalk.addMethod(
  1857. smalltalk.method({
  1858. selector: "collectionWithDuplicates",
  1859. category: 'accessing',
  1860. fn: function (){
  1861. var self=this;
  1862. return smalltalk.withContext(function($ctx1) {
  1863. return "abbaerte";
  1864. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.StringTest)})},
  1865. args: [],
  1866. source: "collectionWithDuplicates\x0a\x09^ 'abbaerte'",
  1867. messageSends: [],
  1868. referencedClasses: []
  1869. }),
  1870. smalltalk.StringTest);
  1871. smalltalk.addMethod(
  1872. smalltalk.method({
  1873. selector: "testAddRemove",
  1874. category: 'tests',
  1875. fn: function (){
  1876. var self=this;
  1877. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1878. return smalltalk.withContext(function($ctx1) {
  1879. _st(self)._should_raise_((function(){
  1880. return smalltalk.withContext(function($ctx2) {
  1881. return _st("hello")._add_("a");
  1882. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  1883. _st(self)._should_raise_((function(){
  1884. return smalltalk.withContext(function($ctx2) {
  1885. return _st("hello")._remove_("h");
  1886. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  1887. return self}, function($ctx1) {$ctx1.fill(self,"testAddRemove",{},smalltalk.StringTest)})},
  1888. args: [],
  1889. source: "testAddRemove\x0a\x09self should: ['hello' add: 'a'] raise: Error.\x0a\x09self should: ['hello' remove: 'h'] raise: Error",
  1890. messageSends: ["should:raise:", "add:", "remove:"],
  1891. referencedClasses: ["Error"]
  1892. }),
  1893. smalltalk.StringTest);
  1894. smalltalk.addMethod(
  1895. smalltalk.method({
  1896. selector: "testAsArray",
  1897. category: 'tests',
  1898. fn: function (){
  1899. var self=this;
  1900. return smalltalk.withContext(function($ctx1) {
  1901. _st(self)._assert_equals_(_st("hello")._asArray(),["h", "e", "l", "l", "o"]);
  1902. return self}, function($ctx1) {$ctx1.fill(self,"testAsArray",{},smalltalk.StringTest)})},
  1903. args: [],
  1904. source: "testAsArray\x0a\x09self assert: 'hello' asArray equals: #('h' 'e' 'l' 'l' 'o').",
  1905. messageSends: ["assert:equals:", "asArray"],
  1906. referencedClasses: []
  1907. }),
  1908. smalltalk.StringTest);
  1909. smalltalk.addMethod(
  1910. smalltalk.method({
  1911. selector: "testAt",
  1912. category: 'tests',
  1913. fn: function (){
  1914. var self=this;
  1915. return smalltalk.withContext(function($ctx1) {
  1916. _st(self)._assert_equals_(_st("hello")._at_((1)),"h");
  1917. _st(self)._assert_equals_(_st("hello")._at_((5)),"o");
  1918. _st(self)._assert_equals_(_st("hello")._at_ifAbsent_((6),(function(){
  1919. return smalltalk.withContext(function($ctx2) {
  1920. return nil;
  1921. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),nil);
  1922. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.StringTest)})},
  1923. args: [],
  1924. source: "testAt\x0a\x09self assert: ('hello' at: 1) equals: 'h'.\x0a\x09self assert: ('hello' at: 5) equals: 'o'.\x0a\x09self assert: ('hello' at: 6 ifAbsent: [nil]) equals: nil",
  1925. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  1926. referencedClasses: []
  1927. }),
  1928. smalltalk.StringTest);
  1929. smalltalk.addMethod(
  1930. smalltalk.method({
  1931. selector: "testAtPut",
  1932. category: 'tests',
  1933. fn: function (){
  1934. var self=this;
  1935. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1936. return smalltalk.withContext(function($ctx1) {
  1937. _st(self)._should_raise_((function(){
  1938. return smalltalk.withContext(function($ctx2) {
  1939. return _st("hello")._at_put_((1),"a");
  1940. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  1941. return self}, function($ctx1) {$ctx1.fill(self,"testAtPut",{},smalltalk.StringTest)})},
  1942. args: [],
  1943. source: "testAtPut\x0a\x09\x22String instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1944. messageSends: ["should:raise:", "at:put:"],
  1945. referencedClasses: ["Error"]
  1946. }),
  1947. smalltalk.StringTest);
  1948. smalltalk.addMethod(
  1949. smalltalk.method({
  1950. selector: "testCollect",
  1951. category: 'tests',
  1952. fn: function (){
  1953. var self=this;
  1954. var newCollection;
  1955. return smalltalk.withContext(function($ctx1) {
  1956. newCollection="hheelllloo";
  1957. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._collect_((function(each){
  1958. return smalltalk.withContext(function($ctx2) {
  1959. return _st(each).__comma(each);
  1960. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})),newCollection);
  1961. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{newCollection:newCollection},smalltalk.StringTest)})},
  1962. args: [],
  1963. 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",
  1964. messageSends: ["assertSameContents:as:", "collect:", ",", "collection"],
  1965. referencedClasses: []
  1966. }),
  1967. smalltalk.StringTest);
  1968. smalltalk.addMethod(
  1969. smalltalk.method({
  1970. selector: "testCopyWithoutAll",
  1971. category: 'tests',
  1972. fn: function (){
  1973. var self=this;
  1974. return smalltalk.withContext(function($ctx1) {
  1975. _st(self)._assert_equals_(_st("*hello* *world*")._copyWithoutAll_("*"),"hello world");
  1976. return self}, function($ctx1) {$ctx1.fill(self,"testCopyWithoutAll",{},smalltalk.StringTest)})},
  1977. args: [],
  1978. source: "testCopyWithoutAll\x0a\x09self\x0a\x09\x09assert: ('*hello* *world*' copyWithoutAll: '*')\x0a\x09\x09equals: 'hello world'",
  1979. messageSends: ["assert:equals:", "copyWithoutAll:"],
  1980. referencedClasses: []
  1981. }),
  1982. smalltalk.StringTest);
  1983. smalltalk.addMethod(
  1984. smalltalk.method({
  1985. selector: "testDetect",
  1986. category: 'tests',
  1987. fn: function (){
  1988. var self=this;
  1989. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1990. return smalltalk.withContext(function($ctx1) {
  1991. _st(self)._assert_equals_(_st(_st(self)._collection())._detect_((function(each){
  1992. return smalltalk.withContext(function($ctx2) {
  1993. return _st(each).__eq("h");
  1994. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})),"h");
  1995. _st(self)._should_raise_((function(){
  1996. return smalltalk.withContext(function($ctx2) {
  1997. return _st(_st(self)._collection())._detect_((function(each){
  1998. return smalltalk.withContext(function($ctx3) {
  1999. return _st(each).__eq((6));
  2000. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx1)})}));
  2001. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  2002. return self}, function($ctx1) {$ctx1.fill(self,"testDetect",{},smalltalk.StringTest)})},
  2003. args: [],
  2004. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each = 'h' ]) equals: 'h'.\x0a\x09self\x0a\x09\x09should: [ self collection detect: [ :each | each = 6 ] ]\x0a\x09\x09raise: Error",
  2005. messageSends: ["assert:equals:", "detect:", "=", "collection", "should:raise:"],
  2006. referencedClasses: ["Error"]
  2007. }),
  2008. smalltalk.StringTest);
  2009. smalltalk.addMethod(
  2010. smalltalk.method({
  2011. selector: "testEquality",
  2012. category: 'tests',
  2013. fn: function (){
  2014. var self=this;
  2015. return smalltalk.withContext(function($ctx1) {
  2016. _st(self)._assert_equals_("hello","hello");
  2017. _st(self)._deny_(_st("hello").__eq("world"));
  2018. _st(self)._deny_(_st("hello").__eq(_st([])._at_ifAbsent_((1),(function(){
  2019. return smalltalk.withContext(function($ctx2) {
  2020. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))));
  2021. _st(self)._assert_equals_("hello",_st("hello")._yourself());
  2022. _st(self)._assert_equals_(_st("hello")._yourself(),"hello");
  2023. _st(self)._deny_(_st("").__eq((0)));
  2024. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.StringTest)})},
  2025. args: [],
  2026. source: "testEquality\x0a\x09self assert: 'hello' equals: 'hello'.\x0a\x09self deny: 'hello' = 'world'.\x0a\x09\x0a\x09\x22Test for issue 459\x22\x0a\x09self deny: 'hello' = (#() at: 1 ifAbsent: [ ]).\x0a\x0a\x09self assert: 'hello' equals: 'hello' yourself.\x0a\x09self assert: 'hello' yourself equals: 'hello'.\x0a\x0a\x09\x22test JS falsy value\x22\x0a\x09self deny: '' = 0",
  2027. messageSends: ["assert:equals:", "deny:", "=", "at:ifAbsent:", "yourself"],
  2028. referencedClasses: []
  2029. }),
  2030. smalltalk.StringTest);
  2031. smalltalk.addMethod(
  2032. smalltalk.method({
  2033. selector: "testIdentity",
  2034. category: 'tests',
  2035. fn: function (){
  2036. var self=this;
  2037. return smalltalk.withContext(function($ctx1) {
  2038. _st(self)._assert_(_st("hello").__eq_eq("hello"));
  2039. _st(self)._deny_(_st("hello").__eq_eq("world"));
  2040. _st(self)._assert_(_st("hello").__eq_eq(_st("hello")._yourself()));
  2041. _st(self)._assert_(_st(_st("hello")._yourself()).__eq_eq("hello"));
  2042. _st(self)._deny_(_st("").__eq_eq((0)));
  2043. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.StringTest)})},
  2044. args: [],
  2045. 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",
  2046. messageSends: ["assert:", "==", "deny:", "yourself"],
  2047. referencedClasses: []
  2048. }),
  2049. smalltalk.StringTest);
  2050. smalltalk.addMethod(
  2051. smalltalk.method({
  2052. selector: "testIncludesSubString",
  2053. category: 'tests',
  2054. fn: function (){
  2055. var self=this;
  2056. return smalltalk.withContext(function($ctx1) {
  2057. _st(self)._assert_(_st("amber")._includesSubString_("ber"));
  2058. _st(self)._deny_(_st("amber")._includesSubString_("zork"));
  2059. return self}, function($ctx1) {$ctx1.fill(self,"testIncludesSubString",{},smalltalk.StringTest)})},
  2060. args: [],
  2061. source: "testIncludesSubString\x0a\x09self assert: ('amber' includesSubString: 'ber').\x0a\x09self deny: ('amber' includesSubString: 'zork').",
  2062. messageSends: ["assert:", "includesSubString:", "deny:"],
  2063. referencedClasses: []
  2064. }),
  2065. smalltalk.StringTest);
  2066. smalltalk.addMethod(
  2067. smalltalk.method({
  2068. selector: "testIndexOf",
  2069. category: 'tests',
  2070. fn: function (){
  2071. var self=this;
  2072. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2073. return smalltalk.withContext(function($ctx1) {
  2074. _st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_("e"),(2));
  2075. _st(self)._should_raise_((function(){
  2076. return smalltalk.withContext(function($ctx2) {
  2077. return _st(_st(self)._collection())._indexOf_((999));
  2078. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  2079. _st(self)._assert_equals_(_st(_st(self)._collection())._indexOf_ifAbsent_((999),(function(){
  2080. return smalltalk.withContext(function($ctx2) {
  2081. return "sentinel";
  2082. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"sentinel");
  2083. return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.StringTest)})},
  2084. args: [],
  2085. source: "testIndexOf\x0a\x09self assert: (self collection indexOf: 'e') equals: 2.\x0a\x09self should: [ self collection indexOf: 999 ] raise: Error.\x0a\x09self assert: (self collection indexOf: 999 ifAbsent: [ 'sentinel' ]) equals: 'sentinel'",
  2086. messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
  2087. referencedClasses: ["Error"]
  2088. }),
  2089. smalltalk.StringTest);
  2090. smalltalk.addMethod(
  2091. smalltalk.method({
  2092. selector: "testJoin",
  2093. category: 'tests',
  2094. fn: function (){
  2095. var self=this;
  2096. return smalltalk.withContext(function($ctx1) {
  2097. _st(self)._assert_equals_(_st(",")._join_(["hello", "world"]),"hello,world");
  2098. return self}, function($ctx1) {$ctx1.fill(self,"testJoin",{},smalltalk.StringTest)})},
  2099. args: [],
  2100. source: "testJoin\x0a\x09self assert: (',' join: #('hello' 'world')) equals: 'hello,world'",
  2101. messageSends: ["assert:equals:", "join:"],
  2102. referencedClasses: []
  2103. }),
  2104. smalltalk.StringTest);
  2105. smalltalk.addMethod(
  2106. smalltalk.method({
  2107. selector: "testSelect",
  2108. category: 'tests',
  2109. fn: function (){
  2110. var self=this;
  2111. var newCollection;
  2112. return smalltalk.withContext(function($ctx1) {
  2113. newCollection="o";
  2114. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._select_((function(each){
  2115. return smalltalk.withContext(function($ctx2) {
  2116. return _st(each).__eq("o");
  2117. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})),newCollection);
  2118. return self}, function($ctx1) {$ctx1.fill(self,"testSelect",{newCollection:newCollection},smalltalk.StringTest)})},
  2119. args: [],
  2120. 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",
  2121. messageSends: ["assertSameContents:as:", "select:", "=", "collection"],
  2122. referencedClasses: []
  2123. }),
  2124. smalltalk.StringTest);
  2125. smalltalk.addMethod(
  2126. smalltalk.method({
  2127. selector: "testSize",
  2128. category: 'tests',
  2129. fn: function (){
  2130. var self=this;
  2131. return smalltalk.withContext(function($ctx1) {
  2132. _st(self)._assert_equals_(_st("smalltalk")._size(),(9));
  2133. _st(self)._assert_equals_(_st("")._size(),(0));
  2134. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.StringTest)})},
  2135. args: [],
  2136. source: "testSize\x0a\x09self assert: 'smalltalk' size equals: 9.\x0a\x09self assert: '' size equals: 0",
  2137. messageSends: ["assert:equals:", "size"],
  2138. referencedClasses: []
  2139. }),
  2140. smalltalk.StringTest);
  2141. smalltalk.addMethod(
  2142. smalltalk.method({
  2143. selector: "testStreamContents",
  2144. category: 'tests',
  2145. fn: function (){
  2146. var self=this;
  2147. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2148. return smalltalk.withContext(function($ctx1) {
  2149. var $1,$2;
  2150. _st(self)._assert_equals_(_st($String())._streamContents_((function(aStream){
  2151. return smalltalk.withContext(function($ctx2) {
  2152. $1=aStream;
  2153. _st($1)._nextPutAll_("hello");
  2154. _st($1)._space();
  2155. $2=_st($1)._nextPutAll_("world");
  2156. return $2;
  2157. }, function($ctx2) {$ctx2.fillBlock({aStream:aStream},$ctx1)})})),"hello world");
  2158. return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StringTest)})},
  2159. args: [],
  2160. source: "testStreamContents\x0a\x09self\x0a\x09\x09assert: (String streamContents: [ :aStream |\x0a\x09\x09\x09aStream\x0a\x09\x09\x09\x09nextPutAll: 'hello'; space;\x0a\x09\x09\x09\x09nextPutAll: 'world' ])\x0a\x09\x09equals: 'hello world'",
  2161. messageSends: ["assert:equals:", "streamContents:", "nextPutAll:", "space"],
  2162. referencedClasses: ["String"]
  2163. }),
  2164. smalltalk.StringTest);
  2165. smalltalk.addMethod(
  2166. smalltalk.method({
  2167. selector: "collectionClass",
  2168. category: 'accessing',
  2169. fn: function (){
  2170. var self=this;
  2171. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2172. return smalltalk.withContext(function($ctx1) {
  2173. var $1;
  2174. $1=$String();
  2175. return $1;
  2176. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringTest.klass)})},
  2177. args: [],
  2178. source: "collectionClass\x0a\x09^ String",
  2179. messageSends: [],
  2180. referencedClasses: ["String"]
  2181. }),
  2182. smalltalk.StringTest.klass);
  2183. smalltalk.addClass('JSObjectProxyTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2184. smalltalk.addMethod(
  2185. smalltalk.method({
  2186. selector: "jsObject",
  2187. category: 'accessing',
  2188. fn: function (){
  2189. var self=this;
  2190. return smalltalk.withContext(function($ctx1) {
  2191. return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null, 'f': undefined};
  2192. return self}, function($ctx1) {$ctx1.fill(self,"jsObject",{},smalltalk.JSObjectProxyTest)})},
  2193. args: [],
  2194. source: "jsObject\x0a\x09<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null, 'f': undefined}>",
  2195. messageSends: [],
  2196. referencedClasses: []
  2197. }),
  2198. smalltalk.JSObjectProxyTest);
  2199. smalltalk.addMethod(
  2200. smalltalk.method({
  2201. selector: "testAtIfAbsent",
  2202. category: 'tests',
  2203. fn: function (){
  2204. var self=this;
  2205. var testObject;
  2206. return smalltalk.withContext(function($ctx1) {
  2207. testObject=_st(self)._jsObject();
  2208. _st(self)._assert_equals_(_st(testObject)._at_ifAbsent_("abc",(function(){
  2209. return smalltalk.withContext(function($ctx2) {
  2210. return "Property does not exist";
  2211. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"Property does not exist");
  2212. _st(self)._assert_equals_(_st(testObject)._at_ifAbsent_("e",(function(){
  2213. return smalltalk.withContext(function($ctx2) {
  2214. return "Property does not exist";
  2215. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),nil);
  2216. _st(self)._assert_equals_(_st(testObject)._at_ifAbsent_("a",(function(){
  2217. return smalltalk.withContext(function($ctx2) {
  2218. return "Property does not exist";
  2219. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),(1));
  2220. _st(self)._assert_equals_(_st(testObject)._at_ifAbsent_("f",(function(){
  2221. return smalltalk.withContext(function($ctx2) {
  2222. return "Property does not exist";
  2223. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),nil);
  2224. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2225. args: [],
  2226. source: "testAtIfAbsent\x0a\x09| testObject |\x0a\x09testObject := self jsObject.\x0a\x09self assert: (testObject at: 'abc' ifAbsent: ['Property does not exist']) equals: 'Property does not exist'.\x0a\x09self assert: (testObject at: 'e' ifAbsent: ['Property does not exist']) equals: nil.\x0a\x09self assert: (testObject at: 'a' ifAbsent: ['Property does not exist']) equals: 1.\x0a\x09self assert: (testObject at: 'f' ifAbsent: ['Property does not exist']) equals: nil.",
  2227. messageSends: ["jsObject", "assert:equals:", "at:ifAbsent:"],
  2228. referencedClasses: []
  2229. }),
  2230. smalltalk.JSObjectProxyTest);
  2231. smalltalk.addMethod(
  2232. smalltalk.method({
  2233. selector: "testAtIfPresent",
  2234. category: 'tests',
  2235. fn: function (){
  2236. var self=this;
  2237. var testObject;
  2238. return smalltalk.withContext(function($ctx1) {
  2239. testObject=_st(self)._jsObject();
  2240. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_("abc",(function(x){
  2241. return smalltalk.withContext(function($ctx2) {
  2242. return _st("hello ").__comma(_st(x)._asString());
  2243. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})})),nil);
  2244. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_("e",(function(x){
  2245. return smalltalk.withContext(function($ctx2) {
  2246. return _st("hello ").__comma(_st(x)._asString());
  2247. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})})),"hello nil");
  2248. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_("a",(function(x){
  2249. return smalltalk.withContext(function($ctx2) {
  2250. return _st("hello ").__comma(_st(x)._asString());
  2251. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})})),"hello 1");
  2252. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_("f",(function(x){
  2253. return smalltalk.withContext(function($ctx2) {
  2254. return _st("hello ").__comma(_st(x)._asString());
  2255. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})})),"hello nil");
  2256. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfPresent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2257. args: [],
  2258. source: "testAtIfPresent\x0a\x09| testObject |\x0a\x09\x0a\x09testObject := self jsObject.\x0a\x09\x0a\x09self assert: (testObject at: 'abc' ifPresent: [ :x | 'hello ',x asString ]) equals: nil.\x0a\x09self assert: (testObject at: 'e' ifPresent: [:x | 'hello ',x asString ]) equals: 'hello nil'.\x0a\x09self assert: (testObject at: 'a' ifPresent: [:x | 'hello ',x asString ]) equals: 'hello 1'.\x0a\x09self assert: (testObject at: 'f' ifPresent: [:x | 'hello ',x asString ]) equals: 'hello nil'.",
  2259. messageSends: ["jsObject", "assert:equals:", "at:ifPresent:", ",", "asString"],
  2260. referencedClasses: []
  2261. }),
  2262. smalltalk.JSObjectProxyTest);
  2263. smalltalk.addMethod(
  2264. smalltalk.method({
  2265. selector: "testAtIfPresentIfAbsent",
  2266. category: 'tests',
  2267. fn: function (){
  2268. var self=this;
  2269. var testObject;
  2270. return smalltalk.withContext(function($ctx1) {
  2271. testObject=_st(self)._jsObject();
  2272. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("abc",(function(x){
  2273. return smalltalk.withContext(function($ctx2) {
  2274. return _st("hello ").__comma(_st(x)._asString());
  2275. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})}),(function(){
  2276. return smalltalk.withContext(function($ctx2) {
  2277. return "not present";
  2278. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"not present");
  2279. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("e",(function(x){
  2280. return smalltalk.withContext(function($ctx2) {
  2281. return _st("hello ").__comma(_st(x)._asString());
  2282. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})}),(function(){
  2283. return smalltalk.withContext(function($ctx2) {
  2284. return "not present";
  2285. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"hello nil");
  2286. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("a",(function(x){
  2287. return smalltalk.withContext(function($ctx2) {
  2288. return _st("hello ").__comma(_st(x)._asString());
  2289. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})}),(function(){
  2290. return smalltalk.withContext(function($ctx2) {
  2291. return "not present";
  2292. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"hello 1");
  2293. _st(self)._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("f",(function(x){
  2294. return smalltalk.withContext(function($ctx2) {
  2295. return _st("hello ").__comma(_st(x)._asString());
  2296. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})}),(function(){
  2297. return smalltalk.withContext(function($ctx2) {
  2298. return "not present";
  2299. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})})),"hello nil");
  2300. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfPresentIfAbsent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2301. args: [],
  2302. source: "testAtIfPresentIfAbsent\x0a\x09| testObject |\x0a\x09testObject := self jsObject.\x0a\x09self assert: (testObject at: 'abc' ifPresent: [:x|'hello ',x asString] ifAbsent: ['not present']) equals: 'not present'.\x0a\x09self assert: (testObject at: 'e' ifPresent: [:x|'hello ',x asString] ifAbsent: ['not present']) equals: 'hello nil'.\x0a\x09self assert: (testObject at: 'a' ifPresent: [:x|'hello ',x asString] ifAbsent: ['not present']) equals: 'hello 1'.\x0a\x09self assert: (testObject at: 'f' ifPresent: [:x|'hello ',x asString] ifAbsent: ['not present']) equals: 'hello nil'.",
  2303. messageSends: ["jsObject", "assert:equals:", "at:ifPresent:ifAbsent:", ",", "asString"],
  2304. referencedClasses: []
  2305. }),
  2306. smalltalk.JSObjectProxyTest);
  2307. smalltalk.addMethod(
  2308. smalltalk.method({
  2309. selector: "testDNU",
  2310. category: 'tests',
  2311. fn: function (){
  2312. var self=this;
  2313. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  2314. return smalltalk.withContext(function($ctx1) {
  2315. _st(self)._should_raise_((function(){
  2316. return smalltalk.withContext(function($ctx2) {
  2317. return _st(_st(self)._jsObject())._foo();
  2318. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2319. return self}, function($ctx1) {$ctx1.fill(self,"testDNU",{},smalltalk.JSObjectProxyTest)})},
  2320. args: [],
  2321. source: "testDNU\x0a\x09self should: [self jsObject foo] raise: MessageNotUnderstood",
  2322. messageSends: ["should:raise:", "foo", "jsObject"],
  2323. referencedClasses: ["MessageNotUnderstood"]
  2324. }),
  2325. smalltalk.JSObjectProxyTest);
  2326. smalltalk.addMethod(
  2327. smalltalk.method({
  2328. selector: "testMessageSend",
  2329. category: 'tests',
  2330. fn: function (){
  2331. var self=this;
  2332. return smalltalk.withContext(function($ctx1) {
  2333. _st(self)._assert_equals_(_st(_st(self)._jsObject())._a(),(1));
  2334. _st(self)._assert_equals_(_st(_st(self)._jsObject())._b(),(2));
  2335. _st(self)._assert_equals_(_st(_st(self)._jsObject())._c_((3)),(3));
  2336. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.JSObjectProxyTest)})},
  2337. args: [],
  2338. 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",
  2339. messageSends: ["assert:equals:", "a", "jsObject", "b", "c:"],
  2340. referencedClasses: []
  2341. }),
  2342. smalltalk.JSObjectProxyTest);
  2343. smalltalk.addMethod(
  2344. smalltalk.method({
  2345. selector: "testMethodWithArguments",
  2346. category: 'tests',
  2347. fn: function (){
  2348. var self=this;
  2349. return smalltalk.withContext(function($ctx1) {
  2350. _st(self)._assert_equals_(_st(_st(self)._jsObject())._c_((1)),(1));
  2351. return self}, function($ctx1) {$ctx1.fill(self,"testMethodWithArguments",{},smalltalk.JSObjectProxyTest)})},
  2352. args: [],
  2353. source: "testMethodWithArguments\x0a\x09self assert: (self jsObject c: 1) equals: 1",
  2354. messageSends: ["assert:equals:", "c:", "jsObject"],
  2355. referencedClasses: []
  2356. }),
  2357. smalltalk.JSObjectProxyTest);
  2358. smalltalk.addMethod(
  2359. smalltalk.method({
  2360. selector: "testPrinting",
  2361. category: 'tests',
  2362. fn: function (){
  2363. var self=this;
  2364. return smalltalk.withContext(function($ctx1) {
  2365. _st(self)._assert_equals_(_st(_st(self)._jsObject())._printString(),"[object Object]");
  2366. return self}, function($ctx1) {$ctx1.fill(self,"testPrinting",{},smalltalk.JSObjectProxyTest)})},
  2367. args: [],
  2368. source: "testPrinting\x0a\x09self assert: self jsObject printString equals: '[object Object]'",
  2369. messageSends: ["assert:equals:", "printString", "jsObject"],
  2370. referencedClasses: []
  2371. }),
  2372. smalltalk.JSObjectProxyTest);
  2373. smalltalk.addMethod(
  2374. smalltalk.method({
  2375. selector: "testPropertyThatReturnsEmptyString",
  2376. category: 'tests',
  2377. fn: function (){
  2378. var self=this;
  2379. var object;
  2380. return smalltalk.withContext(function($ctx1) {
  2381. object=_st(self)._jsObject();
  2382. _st(self)._assert_equals_(_st(object)._d(),"");
  2383. _st(object)._d_("hello");
  2384. _st(self)._assert_equals_(_st(object)._d(),"hello");
  2385. return self}, function($ctx1) {$ctx1.fill(self,"testPropertyThatReturnsEmptyString",{object:object},smalltalk.JSObjectProxyTest)})},
  2386. args: [],
  2387. source: "testPropertyThatReturnsEmptyString\x0a\x09| object |\x0a\x0a\x09object := self jsObject.\x0a\x09self assert: object d equals: ''.\x0a\x0a\x09object d: 'hello'.\x0a\x09self assert: object d equals: 'hello'",
  2388. messageSends: ["jsObject", "assert:equals:", "d", "d:"],
  2389. referencedClasses: []
  2390. }),
  2391. smalltalk.JSObjectProxyTest);
  2392. smalltalk.addMethod(
  2393. smalltalk.method({
  2394. selector: "testPropertyThatReturnsUndefined",
  2395. category: 'tests',
  2396. fn: function (){
  2397. var self=this;
  2398. var object;
  2399. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  2400. return smalltalk.withContext(function($ctx1) {
  2401. object=_st(self)._jsObject();
  2402. _st(self)._shouldnt_raise_((function(){
  2403. return smalltalk.withContext(function($ctx2) {
  2404. return _st(object)._e();
  2405. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2406. _st(self)._assert_(_st(_st(object)._e())._isNil());
  2407. return self}, function($ctx1) {$ctx1.fill(self,"testPropertyThatReturnsUndefined",{object:object},smalltalk.JSObjectProxyTest)})},
  2408. args: [],
  2409. source: "testPropertyThatReturnsUndefined\x0a\x09| object |\x0a\x0a\x09object := self jsObject.\x0a\x09self shouldnt: [ object e ] raise: MessageNotUnderstood.\x0a\x09self assert: object e isNil",
  2410. messageSends: ["jsObject", "shouldnt:raise:", "e", "assert:", "isNil"],
  2411. referencedClasses: ["MessageNotUnderstood"]
  2412. }),
  2413. smalltalk.JSObjectProxyTest);
  2414. smalltalk.addMethod(
  2415. smalltalk.method({
  2416. selector: "testValue",
  2417. category: 'tests',
  2418. fn: function (){
  2419. var self=this;
  2420. var testObject;
  2421. return smalltalk.withContext(function($ctx1) {
  2422. testObject=_st(self)._jsObject();
  2423. _st(self)._assert_equals_(_st(_st(testObject)._value())._printString(),"[object Object]");
  2424. _st(testObject)._at_put_("value","aValue");
  2425. _st(self)._assert_equals_(_st(testObject)._value(),"aValue");
  2426. return self}, function($ctx1) {$ctx1.fill(self,"testValue",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2427. args: [],
  2428. source: "testValue\x0a\x09| testObject |\x0a\x09testObject := self jsObject.\x0a\x09self assert: testObject value printString equals: '[object Object]'.\x0a\x09testObject at: 'value' put: 'aValue'.\x0a\x09self assert: testObject value equals: 'aValue'",
  2429. messageSends: ["jsObject", "assert:equals:", "printString", "value", "at:put:"],
  2430. referencedClasses: []
  2431. }),
  2432. smalltalk.JSObjectProxyTest);
  2433. smalltalk.addMethod(
  2434. smalltalk.method({
  2435. selector: "testYourself",
  2436. category: 'tests',
  2437. fn: function (){
  2438. var self=this;
  2439. var object;
  2440. return smalltalk.withContext(function($ctx1) {
  2441. var $1,$2;
  2442. $1=_st(self)._jsObject();
  2443. _st($1)._d_("test");
  2444. $2=_st($1)._yourself();
  2445. object=$2;
  2446. _st(self)._assert_equals_(_st(object)._d(),"test");
  2447. return self}, function($ctx1) {$ctx1.fill(self,"testYourself",{object:object},smalltalk.JSObjectProxyTest)})},
  2448. args: [],
  2449. source: "testYourself\x0a\x09| object |\x0a\x09object := self jsObject\x0a\x09\x09d: 'test';\x0a\x09\x09yourself.\x0a\x0a\x09self assert: object d equals: 'test'",
  2450. messageSends: ["d:", "jsObject", "yourself", "assert:equals:", "d"],
  2451. referencedClasses: []
  2452. }),
  2453. smalltalk.JSObjectProxyTest);
  2454. smalltalk.addClass('JavaScriptExceptionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2455. smalltalk.addMethod(
  2456. smalltalk.method({
  2457. selector: "testCatchingException",
  2458. category: 'tests',
  2459. fn: function (){
  2460. var self=this;
  2461. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2462. return smalltalk.withContext(function($ctx1) {
  2463. _st((function(){
  2464. return smalltalk.withContext(function($ctx2) {
  2465. return _st(self)._throwException();
  2466. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}))._on_do_($Error(),(function(error){
  2467. return smalltalk.withContext(function($ctx2) {
  2468. return _st(self)._assert_(_st(_st(error)._exception()).__eq("test"));
  2469. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1)})}));
  2470. return self}, function($ctx1) {$ctx1.fill(self,"testCatchingException",{},smalltalk.JavaScriptExceptionTest)})},
  2471. args: [],
  2472. source: "testCatchingException\x0a\x09[ self throwException ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :error |\x0a\x09\x09\x09self assert: error exception = 'test' ]",
  2473. messageSends: ["on:do:", "assert:", "=", "exception", "throwException"],
  2474. referencedClasses: ["Error"]
  2475. }),
  2476. smalltalk.JavaScriptExceptionTest);
  2477. smalltalk.addMethod(
  2478. smalltalk.method({
  2479. selector: "testRaisingException",
  2480. category: 'tests',
  2481. fn: function (){
  2482. var self=this;
  2483. function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
  2484. return smalltalk.withContext(function($ctx1) {
  2485. _st(self)._should_raise_((function(){
  2486. return smalltalk.withContext(function($ctx2) {
  2487. return _st(self)._throwException();
  2488. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$JavaScriptException());
  2489. return self}, function($ctx1) {$ctx1.fill(self,"testRaisingException",{},smalltalk.JavaScriptExceptionTest)})},
  2490. args: [],
  2491. source: "testRaisingException\x0a\x09self should: [ self throwException ] raise: JavaScriptException",
  2492. messageSends: ["should:raise:", "throwException"],
  2493. referencedClasses: ["JavaScriptException"]
  2494. }),
  2495. smalltalk.JavaScriptExceptionTest);
  2496. smalltalk.addMethod(
  2497. smalltalk.method({
  2498. selector: "throwException",
  2499. category: 'helpers',
  2500. fn: function (){
  2501. var self=this;
  2502. return smalltalk.withContext(function($ctx1) {
  2503. throw 'test';
  2504. return self}, function($ctx1) {$ctx1.fill(self,"throwException",{},smalltalk.JavaScriptExceptionTest)})},
  2505. args: [],
  2506. source: "throwException\x0a\x09<throw 'test'>",
  2507. messageSends: [],
  2508. referencedClasses: []
  2509. }),
  2510. smalltalk.JavaScriptExceptionTest);
  2511. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2512. smalltalk.addMethod(
  2513. smalltalk.method({
  2514. selector: "testAbs",
  2515. category: 'tests',
  2516. fn: function (){
  2517. var self=this;
  2518. return smalltalk.withContext(function($ctx1) {
  2519. _st(self)._assert_equals_(_st((4))._abs(),(4));
  2520. _st(self)._assert_equals_(_st((-4))._abs(),(4));
  2521. return self}, function($ctx1) {$ctx1.fill(self,"testAbs",{},smalltalk.NumberTest)})},
  2522. args: [],
  2523. source: "testAbs\x0a\x09self assert: 4 abs equals: 4.\x0a\x09self assert: -4 abs equals: 4",
  2524. messageSends: ["assert:equals:", "abs"],
  2525. referencedClasses: []
  2526. }),
  2527. smalltalk.NumberTest);
  2528. smalltalk.addMethod(
  2529. smalltalk.method({
  2530. selector: "testArithmetic",
  2531. category: 'tests',
  2532. fn: function (){
  2533. var self=this;
  2534. return smalltalk.withContext(function($ctx1) {
  2535. _st(self)._assert_equals_(_st((1.5)).__plus((1)),(2.5));
  2536. _st(self)._assert_equals_(_st((2)).__minus((1)),(1));
  2537. _st(self)._assert_equals_(_st((-2)).__minus((1)),(-3));
  2538. _st(self)._assert_equals_(_st((12)).__slash((2)),(6));
  2539. _st(self)._assert_equals_(_st((3)).__star((4)),(12));
  2540. _st(self)._assert_equals_(_st(_st((1)).__plus((2))).__star((3)),(9));
  2541. _st(self)._assert_equals_(_st((1)).__plus(_st((2)).__star((3))),(7));
  2542. return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.NumberTest)})},
  2543. args: [],
  2544. 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 equals: 2.5.\x0a\x09self assert: 2 - 1 equals: 1.\x0a\x09self assert: -2 - 1 equals: -3.\x0a\x09self assert: 12 / 2 equals: 6.\x0a\x09self assert: 3 * 4 equals: 12.\x0a\x0a\x09\x22Simple parenthesis and execution order\x22\x0a\x09self assert: 1 + 2 * 3 equals: 9.\x0a\x09self assert: 1 + (2 * 3) equals: 7",
  2545. messageSends: ["assert:equals:", "+", "-", "/", "*"],
  2546. referencedClasses: []
  2547. }),
  2548. smalltalk.NumberTest);
  2549. smalltalk.addMethod(
  2550. smalltalk.method({
  2551. selector: "testComparison",
  2552. category: 'tests',
  2553. fn: function (){
  2554. var self=this;
  2555. return smalltalk.withContext(function($ctx1) {
  2556. _st(self)._assert_(_st((3)).__gt((2)));
  2557. _st(self)._assert_(_st((2)).__lt((3)));
  2558. _st(self)._deny_(_st((3)).__lt((2)));
  2559. _st(self)._deny_(_st((2)).__gt((3)));
  2560. _st(self)._assert_(_st((3)).__gt_eq((3)));
  2561. _st(self)._assert_(_st((3.1)).__gt_eq((3)));
  2562. _st(self)._assert_(_st((3)).__lt_eq((3)));
  2563. _st(self)._assert_(_st((3)).__lt_eq((3.1)));
  2564. return self}, function($ctx1) {$ctx1.fill(self,"testComparison",{},smalltalk.NumberTest)})},
  2565. args: [],
  2566. 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",
  2567. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  2568. referencedClasses: []
  2569. }),
  2570. smalltalk.NumberTest);
  2571. smalltalk.addMethod(
  2572. smalltalk.method({
  2573. selector: "testCopying",
  2574. category: 'tests',
  2575. fn: function (){
  2576. var self=this;
  2577. return smalltalk.withContext(function($ctx1) {
  2578. _st(self)._assert_(_st(_st((1))._copy()).__eq_eq((1)));
  2579. _st(self)._assert_(_st(_st((1))._deepCopy()).__eq_eq((1)));
  2580. return self}, function($ctx1) {$ctx1.fill(self,"testCopying",{},smalltalk.NumberTest)})},
  2581. args: [],
  2582. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  2583. messageSends: ["assert:", "==", "copy", "deepCopy"],
  2584. referencedClasses: []
  2585. }),
  2586. smalltalk.NumberTest);
  2587. smalltalk.addMethod(
  2588. smalltalk.method({
  2589. selector: "testEquality",
  2590. category: 'tests',
  2591. fn: function (){
  2592. var self=this;
  2593. return smalltalk.withContext(function($ctx1) {
  2594. _st(self)._assert_(_st((1)).__eq((1)));
  2595. _st(self)._assert_(_st((0)).__eq((0)));
  2596. _st(self)._deny_(_st((1)).__eq((0)));
  2597. _st(self)._assert_(_st(_st((1))._yourself()).__eq((1)));
  2598. _st(self)._assert_(_st((1)).__eq(_st((1))._yourself()));
  2599. _st(self)._assert_(_st(_st((1))._yourself()).__eq(_st((1))._yourself()));
  2600. _st(self)._deny_(_st((0)).__eq(false));
  2601. _st(self)._deny_(_st(false).__eq((0)));
  2602. _st(self)._deny_(_st("").__eq((0)));
  2603. _st(self)._deny_(_st((0)).__eq(""));
  2604. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.NumberTest)})},
  2605. args: [],
  2606. 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 = ''",
  2607. messageSends: ["assert:", "=", "deny:", "yourself"],
  2608. referencedClasses: []
  2609. }),
  2610. smalltalk.NumberTest);
  2611. smalltalk.addMethod(
  2612. smalltalk.method({
  2613. selector: "testHexNumbers",
  2614. category: 'tests',
  2615. fn: function (){
  2616. var self=this;
  2617. return smalltalk.withContext(function($ctx1) {
  2618. _st(self)._assert_equals_((9),(9));
  2619. _st(self)._assert_equals_(_st((10))._truncated(),(10));
  2620. _st(self)._assert_equals_(_st((11))._truncated(),(11));
  2621. _st(self)._assert_equals_(_st((12))._truncated(),(12));
  2622. _st(self)._assert_equals_(_st((13))._truncated(),(13));
  2623. _st(self)._assert_equals_(_st((14))._truncated(),(14));
  2624. _st(self)._assert_equals_(_st((15))._truncated(),(15));
  2625. return self}, function($ctx1) {$ctx1.fill(self,"testHexNumbers",{},smalltalk.NumberTest)})},
  2626. args: [],
  2627. source: "testHexNumbers\x0a\x0a\x09self assert: 16r9 equals: 9.\x0a\x09self assert: 16rA truncated equals: 10.\x0a\x09self assert: 16rB truncated equals: 11.\x0a\x09self assert: 16rC truncated equals: 12.\x0a\x09self assert: 16rD truncated equals: 13.\x0a\x09self assert: 16rE truncated equals: 14.\x0a\x09self assert: 16rF truncated equals: 15",
  2628. messageSends: ["assert:equals:", "truncated"],
  2629. referencedClasses: []
  2630. }),
  2631. smalltalk.NumberTest);
  2632. smalltalk.addMethod(
  2633. smalltalk.method({
  2634. selector: "testIdentity",
  2635. category: 'tests',
  2636. fn: function (){
  2637. var self=this;
  2638. return smalltalk.withContext(function($ctx1) {
  2639. _st(self)._assert_(_st((1)).__eq_eq((1)));
  2640. _st(self)._assert_(_st((0)).__eq_eq((0)));
  2641. _st(self)._deny_(_st((1)).__eq_eq((0)));
  2642. _st(self)._assert_(_st(_st((1))._yourself()).__eq_eq((1)));
  2643. _st(self)._assert_(_st((1)).__eq_eq(_st((1))._yourself()));
  2644. _st(self)._assert_(_st(_st((1))._yourself()).__eq_eq(_st((1))._yourself()));
  2645. _st(self)._deny_(_st((1)).__eq_eq((2)));
  2646. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.NumberTest)})},
  2647. args: [],
  2648. 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",
  2649. messageSends: ["assert:", "==", "deny:", "yourself"],
  2650. referencedClasses: []
  2651. }),
  2652. smalltalk.NumberTest);
  2653. smalltalk.addMethod(
  2654. smalltalk.method({
  2655. selector: "testInvalidHexNumbers",
  2656. category: 'tests',
  2657. fn: function (){
  2658. var self=this;
  2659. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  2660. return smalltalk.withContext(function($ctx1) {
  2661. _st(self)._should_raise_((function(){
  2662. return smalltalk.withContext(function($ctx2) {
  2663. return _st((16))._rG();
  2664. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2665. _st(self)._should_raise_((function(){
  2666. return smalltalk.withContext(function($ctx2) {
  2667. return _st((16))._rg();
  2668. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2669. _st(self)._should_raise_((function(){
  2670. return smalltalk.withContext(function($ctx2) {
  2671. return _st((16))._rH();
  2672. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2673. _st(self)._should_raise_((function(){
  2674. return smalltalk.withContext(function($ctx2) {
  2675. return _st((16))._rh();
  2676. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2677. _st(self)._should_raise_((function(){
  2678. return smalltalk.withContext(function($ctx2) {
  2679. return _st((16))._rI();
  2680. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2681. _st(self)._should_raise_((function(){
  2682. return smalltalk.withContext(function($ctx2) {
  2683. return _st((16))._ri();
  2684. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2685. _st(self)._should_raise_((function(){
  2686. return smalltalk.withContext(function($ctx2) {
  2687. return _st((16))._rJ();
  2688. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2689. _st(self)._should_raise_((function(){
  2690. return smalltalk.withContext(function($ctx2) {
  2691. return _st((16))._rj();
  2692. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2693. _st(self)._should_raise_((function(){
  2694. return smalltalk.withContext(function($ctx2) {
  2695. return _st((16))._rK();
  2696. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2697. _st(self)._should_raise_((function(){
  2698. return smalltalk.withContext(function($ctx2) {
  2699. return _st((16))._rk();
  2700. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2701. _st(self)._should_raise_((function(){
  2702. return smalltalk.withContext(function($ctx2) {
  2703. return _st((16))._rL();
  2704. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2705. _st(self)._should_raise_((function(){
  2706. return smalltalk.withContext(function($ctx2) {
  2707. return _st((16))._rl();
  2708. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2709. _st(self)._should_raise_((function(){
  2710. return smalltalk.withContext(function($ctx2) {
  2711. return _st((16))._rM();
  2712. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2713. _st(self)._should_raise_((function(){
  2714. return smalltalk.withContext(function($ctx2) {
  2715. return _st((16))._rm();
  2716. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2717. _st(self)._should_raise_((function(){
  2718. return smalltalk.withContext(function($ctx2) {
  2719. return _st((16))._rN();
  2720. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2721. _st(self)._should_raise_((function(){
  2722. return smalltalk.withContext(function($ctx2) {
  2723. return _st((16))._rn();
  2724. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2725. _st(self)._should_raise_((function(){
  2726. return smalltalk.withContext(function($ctx2) {
  2727. return _st((16))._rO();
  2728. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2729. _st(self)._should_raise_((function(){
  2730. return smalltalk.withContext(function($ctx2) {
  2731. return _st((16))._ro();
  2732. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2733. _st(self)._should_raise_((function(){
  2734. return smalltalk.withContext(function($ctx2) {
  2735. return _st((16))._rP();
  2736. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2737. _st(self)._should_raise_((function(){
  2738. return smalltalk.withContext(function($ctx2) {
  2739. return _st((16))._rp();
  2740. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2741. _st(self)._should_raise_((function(){
  2742. return smalltalk.withContext(function($ctx2) {
  2743. return _st((16))._rQ();
  2744. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2745. _st(self)._should_raise_((function(){
  2746. return smalltalk.withContext(function($ctx2) {
  2747. return _st((16))._rq();
  2748. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2749. _st(self)._should_raise_((function(){
  2750. return smalltalk.withContext(function($ctx2) {
  2751. return _st((16))._rR();
  2752. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2753. _st(self)._should_raise_((function(){
  2754. return smalltalk.withContext(function($ctx2) {
  2755. return _st((16))._rr();
  2756. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2757. _st(self)._should_raise_((function(){
  2758. return smalltalk.withContext(function($ctx2) {
  2759. return _st((16))._rS();
  2760. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2761. _st(self)._should_raise_((function(){
  2762. return smalltalk.withContext(function($ctx2) {
  2763. return _st((16))._rs();
  2764. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2765. _st(self)._should_raise_((function(){
  2766. return smalltalk.withContext(function($ctx2) {
  2767. return _st((16))._rT();
  2768. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2769. _st(self)._should_raise_((function(){
  2770. return smalltalk.withContext(function($ctx2) {
  2771. return _st((16))._rt();
  2772. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2773. _st(self)._should_raise_((function(){
  2774. return smalltalk.withContext(function($ctx2) {
  2775. return _st((16))._rU();
  2776. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2777. _st(self)._should_raise_((function(){
  2778. return smalltalk.withContext(function($ctx2) {
  2779. return _st((16))._ru();
  2780. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2781. _st(self)._should_raise_((function(){
  2782. return smalltalk.withContext(function($ctx2) {
  2783. return _st((16))._rV();
  2784. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2785. _st(self)._should_raise_((function(){
  2786. return smalltalk.withContext(function($ctx2) {
  2787. return _st((16))._rv();
  2788. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2789. _st(self)._should_raise_((function(){
  2790. return smalltalk.withContext(function($ctx2) {
  2791. return _st((16))._rW();
  2792. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2793. _st(self)._should_raise_((function(){
  2794. return smalltalk.withContext(function($ctx2) {
  2795. return _st((16))._rw();
  2796. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2797. _st(self)._should_raise_((function(){
  2798. return smalltalk.withContext(function($ctx2) {
  2799. return _st((16))._rX();
  2800. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2801. _st(self)._should_raise_((function(){
  2802. return smalltalk.withContext(function($ctx2) {
  2803. return _st((16))._rx();
  2804. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2805. _st(self)._should_raise_((function(){
  2806. return smalltalk.withContext(function($ctx2) {
  2807. return _st((16))._rY();
  2808. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2809. _st(self)._should_raise_((function(){
  2810. return smalltalk.withContext(function($ctx2) {
  2811. return _st((16))._ry();
  2812. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2813. _st(self)._should_raise_((function(){
  2814. return smalltalk.withContext(function($ctx2) {
  2815. return _st((16))._rZ();
  2816. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2817. _st(self)._should_raise_((function(){
  2818. return smalltalk.withContext(function($ctx2) {
  2819. return _st((16))._rz();
  2820. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2821. _st(self)._should_raise_((function(){
  2822. return smalltalk.withContext(function($ctx2) {
  2823. return _st((11259375))._Z();
  2824. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  2825. return self}, function($ctx1) {$ctx1.fill(self,"testInvalidHexNumbers",{},smalltalk.NumberTest)})},
  2826. args: [],
  2827. 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\x09self should: [16rABcdEfZ] raise: MessageNotUnderstood.",
  2828. 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"],
  2829. referencedClasses: ["MessageNotUnderstood"]
  2830. }),
  2831. smalltalk.NumberTest);
  2832. smalltalk.addMethod(
  2833. smalltalk.method({
  2834. selector: "testMinMax",
  2835. category: 'tests',
  2836. fn: function (){
  2837. var self=this;
  2838. return smalltalk.withContext(function($ctx1) {
  2839. _st(self)._assert_equals_(_st((2))._max_((5)),(5));
  2840. _st(self)._assert_equals_(_st((2))._min_((5)),(2));
  2841. return self}, function($ctx1) {$ctx1.fill(self,"testMinMax",{},smalltalk.NumberTest)})},
  2842. args: [],
  2843. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  2844. messageSends: ["assert:equals:", "max:", "min:"],
  2845. referencedClasses: []
  2846. }),
  2847. smalltalk.NumberTest);
  2848. smalltalk.addMethod(
  2849. smalltalk.method({
  2850. selector: "testNegated",
  2851. category: 'tests',
  2852. fn: function (){
  2853. var self=this;
  2854. return smalltalk.withContext(function($ctx1) {
  2855. _st(self)._assert_equals_(_st((3))._negated(),(-3));
  2856. _st(self)._assert_equals_(_st((-3))._negated(),(3));
  2857. return self}, function($ctx1) {$ctx1.fill(self,"testNegated",{},smalltalk.NumberTest)})},
  2858. args: [],
  2859. source: "testNegated\x0a\x09self assert: 3 negated equals: -3.\x0a\x09self assert: -3 negated equals: 3",
  2860. messageSends: ["assert:equals:", "negated"],
  2861. referencedClasses: []
  2862. }),
  2863. smalltalk.NumberTest);
  2864. smalltalk.addMethod(
  2865. smalltalk.method({
  2866. selector: "testPrintShowingDecimalPlaces",
  2867. category: 'tests',
  2868. fn: function (){
  2869. var self=this;
  2870. return smalltalk.withContext(function($ctx1) {
  2871. _st(self)._assert_equals_(_st((23))._printShowingDecimalPlaces_((2)),"23.00");
  2872. _st(self)._assert_equals_(_st((23.5698))._printShowingDecimalPlaces_((2)),"23.57");
  2873. _st(self)._assert_equals_(_st(_st((234.567))._negated())._printShowingDecimalPlaces_((5)),"-234.56700");
  2874. _st(self)._assert_equals_(_st((23.4567))._printShowingDecimalPlaces_((0)),"23");
  2875. _st(self)._assert_equals_(_st((23.5567))._printShowingDecimalPlaces_((0)),"24");
  2876. _st(self)._assert_equals_(_st(_st((23.4567))._negated())._printShowingDecimalPlaces_((0)),"-23");
  2877. _st(self)._assert_equals_(_st(_st((23.5567))._negated())._printShowingDecimalPlaces_((0)),"-24");
  2878. _st(self)._assert_equals_(_st((100000000))._printShowingDecimalPlaces_((1)),"100000000.0");
  2879. _st(self)._assert_equals_(_st((0.98))._printShowingDecimalPlaces_((5)),"0.98000");
  2880. _st(self)._assert_equals_(_st(_st((0.98))._negated())._printShowingDecimalPlaces_((2)),"-0.98");
  2881. _st(self)._assert_equals_(_st((2.567))._printShowingDecimalPlaces_((2)),"2.57");
  2882. _st(self)._assert_equals_(_st((-2.567))._printShowingDecimalPlaces_((2)),"-2.57");
  2883. _st(self)._assert_equals_(_st((0))._printShowingDecimalPlaces_((2)),"0.00");
  2884. return self}, function($ctx1) {$ctx1.fill(self,"testPrintShowingDecimalPlaces",{},smalltalk.NumberTest)})},
  2885. args: [],
  2886. source: "testPrintShowingDecimalPlaces\x0a\x09self assert: (23 printShowingDecimalPlaces: 2) equals: '23.00'.\x0a\x09self assert: (23.5698 printShowingDecimalPlaces: 2) equals: '23.57'.\x0a\x09self assert: (234.567 negated printShowingDecimalPlaces: 5) equals: '-234.56700'.\x0a\x09self assert: (23.4567 printShowingDecimalPlaces: 0) equals: '23'.\x0a\x09self assert: (23.5567 printShowingDecimalPlaces: 0) equals: '24'.\x0a\x09self assert: (23.4567 negated printShowingDecimalPlaces: 0) equals: '-23'.\x0a\x09self assert: (23.5567 negated printShowingDecimalPlaces: 0) equals: '-24'.\x0a\x09self assert: (100000000 printShowingDecimalPlaces: 1) equals: '100000000.0'.\x0a\x09self assert: (0.98 printShowingDecimalPlaces: 5) equals: '0.98000'.\x0a\x09self assert: (0.98 negated printShowingDecimalPlaces: 2) equals: '-0.98'.\x0a\x09self assert: (2.567 printShowingDecimalPlaces: 2) equals: '2.57'.\x0a\x09self assert: (-2.567 printShowingDecimalPlaces: 2) equals: '-2.57'.\x0a\x09self assert: (0 printShowingDecimalPlaces: 2) equals: '0.00'.",
  2887. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  2888. referencedClasses: []
  2889. }),
  2890. smalltalk.NumberTest);
  2891. smalltalk.addMethod(
  2892. smalltalk.method({
  2893. selector: "testRounded",
  2894. category: 'tests',
  2895. fn: function (){
  2896. var self=this;
  2897. return smalltalk.withContext(function($ctx1) {
  2898. _st(self)._assert_equals_(_st((3))._rounded(),(3));
  2899. _st(self)._assert_equals_(_st((3.212))._rounded(),(3));
  2900. _st(self)._assert_equals_(_st((3.51))._rounded(),(4));
  2901. return self}, function($ctx1) {$ctx1.fill(self,"testRounded",{},smalltalk.NumberTest)})},
  2902. args: [],
  2903. source: "testRounded\x0a\x09\x0a\x09self assert: 3 rounded equals: 3.\x0a\x09self assert: 3.212 rounded equals: 3.\x0a\x09self assert: 3.51 rounded equals: 4",
  2904. messageSends: ["assert:equals:", "rounded"],
  2905. referencedClasses: []
  2906. }),
  2907. smalltalk.NumberTest);
  2908. smalltalk.addMethod(
  2909. smalltalk.method({
  2910. selector: "testSqrt",
  2911. category: 'tests',
  2912. fn: function (){
  2913. var self=this;
  2914. return smalltalk.withContext(function($ctx1) {
  2915. _st(self)._assert_equals_(_st((4))._sqrt(),(2));
  2916. _st(self)._assert_equals_(_st((16))._sqrt(),(4));
  2917. return self}, function($ctx1) {$ctx1.fill(self,"testSqrt",{},smalltalk.NumberTest)})},
  2918. args: [],
  2919. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt equals: 2.\x0a\x09self assert: 16 sqrt equals: 4",
  2920. messageSends: ["assert:equals:", "sqrt"],
  2921. referencedClasses: []
  2922. }),
  2923. smalltalk.NumberTest);
  2924. smalltalk.addMethod(
  2925. smalltalk.method({
  2926. selector: "testSquared",
  2927. category: 'tests',
  2928. fn: function (){
  2929. var self=this;
  2930. return smalltalk.withContext(function($ctx1) {
  2931. _st(self)._assert_equals_(_st((4))._squared(),(16));
  2932. return self}, function($ctx1) {$ctx1.fill(self,"testSquared",{},smalltalk.NumberTest)})},
  2933. args: [],
  2934. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared equals: 16",
  2935. messageSends: ["assert:equals:", "squared"],
  2936. referencedClasses: []
  2937. }),
  2938. smalltalk.NumberTest);
  2939. smalltalk.addMethod(
  2940. smalltalk.method({
  2941. selector: "testTimesRepeat",
  2942. category: 'tests',
  2943. fn: function (){
  2944. var self=this;
  2945. var i;
  2946. return smalltalk.withContext(function($ctx1) {
  2947. i=(0);
  2948. _st((0))._timesRepeat_((function(){
  2949. return smalltalk.withContext(function($ctx2) {
  2950. i=_st(i).__plus((1));
  2951. return i;
  2952. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2953. _st(self)._assert_equals_(i,(0));
  2954. _st((5))._timesRepeat_((function(){
  2955. return smalltalk.withContext(function($ctx2) {
  2956. i=_st(i).__plus((1));
  2957. return i;
  2958. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  2959. _st(self)._assert_equals_(i,(5));
  2960. return self}, function($ctx1) {$ctx1.fill(self,"testTimesRepeat",{i:i},smalltalk.NumberTest)})},
  2961. args: [],
  2962. 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",
  2963. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  2964. referencedClasses: []
  2965. }),
  2966. smalltalk.NumberTest);
  2967. smalltalk.addMethod(
  2968. smalltalk.method({
  2969. selector: "testTo",
  2970. category: 'tests',
  2971. fn: function (){
  2972. var self=this;
  2973. return smalltalk.withContext(function($ctx1) {
  2974. _st(self)._assert_equals_(_st((1))._to_((5)),[(1), (2), (3), (4), (5)]);
  2975. return self}, function($ctx1) {$ctx1.fill(self,"testTo",{},smalltalk.NumberTest)})},
  2976. args: [],
  2977. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  2978. messageSends: ["assert:equals:", "to:"],
  2979. referencedClasses: []
  2980. }),
  2981. smalltalk.NumberTest);
  2982. smalltalk.addMethod(
  2983. smalltalk.method({
  2984. selector: "testToBy",
  2985. category: 'tests',
  2986. fn: function (){
  2987. var self=this;
  2988. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2989. return smalltalk.withContext(function($ctx1) {
  2990. _st(self)._assert_equals_(_st((0))._to_by_((6),(2)),[(0), (2), (4), (6)]);
  2991. _st(self)._should_raise_((function(){
  2992. return smalltalk.withContext(function($ctx2) {
  2993. return _st((1))._to_by_((4),(0));
  2994. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  2995. return self}, function($ctx1) {$ctx1.fill(self,"testToBy",{},smalltalk.NumberTest)})},
  2996. args: [],
  2997. 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",
  2998. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  2999. referencedClasses: ["Error"]
  3000. }),
  3001. smalltalk.NumberTest);
  3002. smalltalk.addMethod(
  3003. smalltalk.method({
  3004. selector: "testTruncated",
  3005. category: 'tests',
  3006. fn: function (){
  3007. var self=this;
  3008. return smalltalk.withContext(function($ctx1) {
  3009. _st(self)._assert_equals_(_st((3))._truncated(),(3));
  3010. _st(self)._assert_equals_(_st((3.212))._truncated(),(3));
  3011. _st(self)._assert_equals_(_st((3.51))._truncated(),(3));
  3012. return self}, function($ctx1) {$ctx1.fill(self,"testTruncated",{},smalltalk.NumberTest)})},
  3013. args: [],
  3014. source: "testTruncated\x0a\x09\x0a\x09self assert: 3 truncated equals: 3.\x0a\x09self assert: 3.212 truncated equals: 3.\x0a\x09self assert: 3.51 truncated equals: 3",
  3015. messageSends: ["assert:equals:", "truncated"],
  3016. referencedClasses: []
  3017. }),
  3018. smalltalk.NumberTest);
  3019. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  3020. smalltalk.ObjectMock.comment="ObjectMock is there only to perform tests on classes."
  3021. smalltalk.addMethod(
  3022. smalltalk.method({
  3023. selector: "foo",
  3024. category: 'not yet classified',
  3025. fn: function (){
  3026. var self=this;
  3027. return smalltalk.withContext(function($ctx1) {
  3028. var $1;
  3029. $1=self["@foo"];
  3030. return $1;
  3031. }, function($ctx1) {$ctx1.fill(self,"foo",{},smalltalk.ObjectMock)})},
  3032. args: [],
  3033. source: "foo\x0a\x09^foo",
  3034. messageSends: [],
  3035. referencedClasses: []
  3036. }),
  3037. smalltalk.ObjectMock);
  3038. smalltalk.addMethod(
  3039. smalltalk.method({
  3040. selector: "foo:",
  3041. category: 'not yet classified',
  3042. fn: function (anObject){
  3043. var self=this;
  3044. return smalltalk.withContext(function($ctx1) {
  3045. self["@foo"]=anObject;
  3046. return self}, function($ctx1) {$ctx1.fill(self,"foo:",{anObject:anObject},smalltalk.ObjectMock)})},
  3047. args: ["anObject"],
  3048. source: "foo: anObject\x0a\x09foo := anObject",
  3049. messageSends: [],
  3050. referencedClasses: []
  3051. }),
  3052. smalltalk.ObjectMock);
  3053. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3054. smalltalk.addMethod(
  3055. smalltalk.method({
  3056. selector: "notDefined",
  3057. category: 'tests',
  3058. fn: function (){
  3059. var self=this;
  3060. return smalltalk.withContext(function($ctx1) {
  3061. return undefined;;
  3062. return self}, function($ctx1) {$ctx1.fill(self,"notDefined",{},smalltalk.ObjectTest)})},
  3063. args: [],
  3064. source: "notDefined\x0a\x09<return undefined;>",
  3065. messageSends: [],
  3066. referencedClasses: []
  3067. }),
  3068. smalltalk.ObjectTest);
  3069. smalltalk.addMethod(
  3070. smalltalk.method({
  3071. selector: "testBasicAccess",
  3072. category: 'tests',
  3073. fn: function (){
  3074. var self=this;
  3075. var o;
  3076. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3077. return smalltalk.withContext(function($ctx1) {
  3078. o=_st($Object())._new();
  3079. _st(o)._basicAt_put_("a",(1));
  3080. _st(self)._assert_equals_(_st(o)._basicAt_("a"),(1));
  3081. _st(self)._assert_equals_(_st(o)._basicAt_("b"),nil);
  3082. return self}, function($ctx1) {$ctx1.fill(self,"testBasicAccess",{o:o},smalltalk.ObjectTest)})},
  3083. args: [],
  3084. 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",
  3085. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  3086. referencedClasses: ["Object"]
  3087. }),
  3088. smalltalk.ObjectTest);
  3089. smalltalk.addMethod(
  3090. smalltalk.method({
  3091. selector: "testBasicPerform",
  3092. category: 'tests',
  3093. fn: function (){
  3094. var self=this;
  3095. var o;
  3096. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3097. return smalltalk.withContext(function($ctx1) {
  3098. o=_st($Object())._new();
  3099. _st(o)._basicAt_put_("func",(function(){
  3100. return smalltalk.withContext(function($ctx2) {
  3101. return "hello";
  3102. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  3103. _st(o)._basicAt_put_("func2",(function(a){
  3104. return smalltalk.withContext(function($ctx2) {
  3105. return _st(a).__plus((1));
  3106. }, function($ctx2) {$ctx2.fillBlock({a:a},$ctx1)})}));
  3107. _st(self)._assert_equals_(_st(o)._basicPerform_("func"),"hello");
  3108. _st(self)._assert_equals_(_st(o)._basicPerform_withArguments_("func2",[(3)]),(4));
  3109. return self}, function($ctx1) {$ctx1.fill(self,"testBasicPerform",{o:o},smalltalk.ObjectTest)})},
  3110. args: [],
  3111. source: "testBasicPerform\x0a\x09| o |\x0a\x09o := Object new.\x0a\x09o basicAt: 'func' put: ['hello'].\x0a\x09o basicAt: 'func2' put: [:a | a + 1].\x0a\x0a\x09self assert: (o basicPerform: 'func') equals: 'hello'.\x0a\x09self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4",
  3112. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  3113. referencedClasses: ["Object"]
  3114. }),
  3115. smalltalk.ObjectTest);
  3116. smalltalk.addMethod(
  3117. smalltalk.method({
  3118. selector: "testDNU",
  3119. category: 'tests',
  3120. fn: function (){
  3121. var self=this;
  3122. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3123. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3124. return smalltalk.withContext(function($ctx1) {
  3125. _st(self)._should_raise_((function(){
  3126. return smalltalk.withContext(function($ctx2) {
  3127. return _st(_st($Object())._new())._foo();
  3128. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$MessageNotUnderstood());
  3129. return self}, function($ctx1) {$ctx1.fill(self,"testDNU",{},smalltalk.ObjectTest)})},
  3130. args: [],
  3131. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  3132. messageSends: ["should:raise:", "foo", "new"],
  3133. referencedClasses: ["Object", "MessageNotUnderstood"]
  3134. }),
  3135. smalltalk.ObjectTest);
  3136. smalltalk.addMethod(
  3137. smalltalk.method({
  3138. selector: "testEquality",
  3139. category: 'tests',
  3140. fn: function (){
  3141. var self=this;
  3142. var o;
  3143. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3144. return smalltalk.withContext(function($ctx1) {
  3145. o=_st($Object())._new();
  3146. _st(self)._deny_(_st(o).__eq(_st($Object())._new()));
  3147. _st(self)._assert_(_st(o).__eq(o));
  3148. _st(self)._assert_(_st(_st(o)._yourself()).__eq(o));
  3149. _st(self)._assert_(_st(o).__eq(_st(o)._yourself()));
  3150. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{o:o},smalltalk.ObjectTest)})},
  3151. args: [],
  3152. 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)",
  3153. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  3154. referencedClasses: ["Object"]
  3155. }),
  3156. smalltalk.ObjectTest);
  3157. smalltalk.addMethod(
  3158. smalltalk.method({
  3159. selector: "testHalt",
  3160. category: 'tests',
  3161. fn: function (){
  3162. var self=this;
  3163. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3164. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3165. return smalltalk.withContext(function($ctx1) {
  3166. _st(self)._should_raise_((function(){
  3167. return smalltalk.withContext(function($ctx2) {
  3168. return _st(_st($Object())._new())._halt();
  3169. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  3170. return self}, function($ctx1) {$ctx1.fill(self,"testHalt",{},smalltalk.ObjectTest)})},
  3171. args: [],
  3172. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  3173. messageSends: ["should:raise:", "halt", "new"],
  3174. referencedClasses: ["Object", "Error"]
  3175. }),
  3176. smalltalk.ObjectTest);
  3177. smalltalk.addMethod(
  3178. smalltalk.method({
  3179. selector: "testIdentity",
  3180. category: 'tests',
  3181. fn: function (){
  3182. var self=this;
  3183. var o;
  3184. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3185. return smalltalk.withContext(function($ctx1) {
  3186. o=_st($Object())._new();
  3187. _st(self)._deny_(_st(o).__eq_eq(_st($Object())._new()));
  3188. _st(self)._assert_(_st(o).__eq_eq(o));
  3189. _st(self)._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  3190. _st(self)._assert_(_st(o).__eq_eq(_st(o)._yourself()));
  3191. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{o:o},smalltalk.ObjectTest)})},
  3192. args: [],
  3193. 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",
  3194. messageSends: ["new", "deny:", "==", "assert:", "yourself"],
  3195. referencedClasses: ["Object"]
  3196. }),
  3197. smalltalk.ObjectTest);
  3198. smalltalk.addMethod(
  3199. smalltalk.method({
  3200. selector: "testIfNil",
  3201. category: 'tests',
  3202. fn: function (){
  3203. var self=this;
  3204. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3205. return smalltalk.withContext(function($ctx1) {
  3206. var $1,$4,$3,$2,$5,$7,$6,$8,$10,$9,$11,$13,$12;
  3207. _st(self)._deny_(_st(_st($Object())._new())._isNil());
  3208. $1=self;
  3209. $4=_st($Object())._new();
  3210. if(($receiver = $4) == nil || $receiver == undefined){
  3211. $3=true;
  3212. } else {
  3213. $3=$4;
  3214. };
  3215. $2=_st($3).__eq(true);
  3216. _st($1)._deny_($2);
  3217. $5=self;
  3218. $7=_st($Object())._new();
  3219. if(($receiver = $7) == nil || $receiver == undefined){
  3220. $6=$7;
  3221. } else {
  3222. $6=true;
  3223. };
  3224. _st($5)._assert_equals_($6,true);
  3225. $8=self;
  3226. $10=_st($Object())._new();
  3227. if(($receiver = $10) == nil || $receiver == undefined){
  3228. $9=false;
  3229. } else {
  3230. $9=true;
  3231. };
  3232. _st($8)._assert_equals_($9,true);
  3233. $11=self;
  3234. $13=_st($Object())._new();
  3235. if(($receiver = $13) == nil || $receiver == undefined){
  3236. $12=false;
  3237. } else {
  3238. $12=true;
  3239. };
  3240. _st($11)._assert_equals_($12,true);
  3241. return self}, function($ctx1) {$ctx1.fill(self,"testIfNil",{},smalltalk.ObjectTest)})},
  3242. args: [],
  3243. source: "testIfNil\x0a\x09self deny: Object new isNil.\x0a\x09self deny: (Object new ifNil: [true]) = true.\x0a\x09self assert: (Object new ifNotNil: [true]) equals: true.\x0a\x0a\x09self assert: (Object new ifNil: [false] ifNotNil: [true]) equals: true.\x0a\x09self assert: (Object new ifNotNil: [true] ifNil: [false]) equals: true",
  3244. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:equals:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  3245. referencedClasses: ["Object"]
  3246. }),
  3247. smalltalk.ObjectTest);
  3248. smalltalk.addMethod(
  3249. smalltalk.method({
  3250. selector: "testInstVars",
  3251. category: 'tests',
  3252. fn: function (){
  3253. var self=this;
  3254. var o;
  3255. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  3256. return smalltalk.withContext(function($ctx1) {
  3257. o=_st($ObjectMock())._new();
  3258. _st(self)._assert_equals_(_st(o)._instVarAt_("foo"),nil);
  3259. _st(o)._instVarAt_put_("foo",(1));
  3260. _st(self)._assert_equals_(_st(o)._instVarAt_("foo"),(1));
  3261. _st(self)._assert_equals_(_st(o)._instVarAt_("foo"),(1));
  3262. return self}, function($ctx1) {$ctx1.fill(self,"testInstVars",{o:o},smalltalk.ObjectTest)})},
  3263. args: [],
  3264. 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",
  3265. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  3266. referencedClasses: ["ObjectMock"]
  3267. }),
  3268. smalltalk.ObjectTest);
  3269. smalltalk.addMethod(
  3270. smalltalk.method({
  3271. selector: "testNilUndefined",
  3272. category: 'tests',
  3273. fn: function (){
  3274. var self=this;
  3275. return smalltalk.withContext(function($ctx1) {
  3276. _st(self)._assert_equals_(_st(self)._notDefined(),nil);
  3277. return self}, function($ctx1) {$ctx1.fill(self,"testNilUndefined",{},smalltalk.ObjectTest)})},
  3278. args: [],
  3279. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09self assert: self notDefined equals: nil",
  3280. messageSends: ["assert:equals:", "notDefined"],
  3281. referencedClasses: []
  3282. }),
  3283. smalltalk.ObjectTest);
  3284. smalltalk.addMethod(
  3285. smalltalk.method({
  3286. selector: "testYourself",
  3287. category: 'tests',
  3288. fn: function (){
  3289. var self=this;
  3290. var o;
  3291. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  3292. return smalltalk.withContext(function($ctx1) {
  3293. o=_st($ObjectMock())._new();
  3294. _st(self)._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  3295. return self}, function($ctx1) {$ctx1.fill(self,"testYourself",{o:o},smalltalk.ObjectTest)})},
  3296. args: [],
  3297. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  3298. messageSends: ["new", "assert:", "==", "yourself"],
  3299. referencedClasses: ["ObjectMock"]
  3300. }),
  3301. smalltalk.ObjectTest);
  3302. smalltalk.addMethod(
  3303. smalltalk.method({
  3304. selector: "testidentityHash",
  3305. category: 'tests',
  3306. fn: function (){
  3307. var self=this;
  3308. var o1,o2;
  3309. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3310. return smalltalk.withContext(function($ctx1) {
  3311. o1=_st($Object())._new();
  3312. o2=_st($Object())._new();
  3313. _st(self)._assert_(_st(_st(o1)._identityHash()).__eq_eq(_st(o1)._identityHash()));
  3314. _st(self)._deny_(_st(_st(o1)._identityHash()).__eq_eq(_st(o2)._identityHash()));
  3315. return self}, function($ctx1) {$ctx1.fill(self,"testidentityHash",{o1:o1,o2:o2},smalltalk.ObjectTest)})},
  3316. args: [],
  3317. 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",
  3318. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  3319. referencedClasses: ["Object"]
  3320. }),
  3321. smalltalk.ObjectTest);
  3322. smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
  3323. smalltalk.addMethod(
  3324. smalltalk.method({
  3325. selector: "setUp",
  3326. category: 'running',
  3327. fn: function (){
  3328. var self=this;
  3329. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  3330. return smalltalk.withContext(function($ctx1) {
  3331. var $1,$2;
  3332. self["@backUpCommitPathJs"]=_st($Package())._defaultCommitPathJs();
  3333. self["@backUpCommitPathSt"]=_st($Package())._defaultCommitPathSt();
  3334. _st($Package())._resetCommitPaths();
  3335. self["@zorkPackage"]=_st(_st($Package())._new())._name_("Zork");
  3336. $1=_st($Package())._new();
  3337. _st($1)._name_("Grul");
  3338. _st($1)._commitPathJs_("server/grul/js");
  3339. _st($1)._commitPathSt_("grul/st");
  3340. $2=_st($1)._yourself();
  3341. self["@grulPackage"]=$2;
  3342. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.PackageTest)})},
  3343. args: [],
  3344. 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",
  3345. messageSends: ["defaultCommitPathJs", "defaultCommitPathSt", "resetCommitPaths", "name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
  3346. referencedClasses: ["Package"]
  3347. }),
  3348. smalltalk.PackageTest);
  3349. smalltalk.addMethod(
  3350. smalltalk.method({
  3351. selector: "tearDown",
  3352. category: 'running',
  3353. fn: function (){
  3354. var self=this;
  3355. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  3356. return smalltalk.withContext(function($ctx1) {
  3357. var $1,$2;
  3358. $1=$Package();
  3359. _st($1)._defaultCommitPathJs_(self["@backUpCommitPathJs"]);
  3360. $2=_st($1)._defaultCommitPathSt_(self["@backUpCommitPathSt"]);
  3361. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.PackageTest)})},
  3362. args: [],
  3363. source: "tearDown\x0a\x09Package\x0a\x09\x09defaultCommitPathJs: backUpCommitPathJs;\x0a\x09\x09defaultCommitPathSt: backUpCommitPathSt",
  3364. messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
  3365. referencedClasses: ["Package"]
  3366. }),
  3367. smalltalk.PackageTest);
  3368. smalltalk.addMethod(
  3369. smalltalk.method({
  3370. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  3371. category: 'tests',
  3372. fn: function (){
  3373. var self=this;
  3374. return smalltalk.withContext(function($ctx1) {
  3375. _st(self)._assert_equals_(_st(self["@grulPackage"])._commitPathJs(),"server/grul/js");
  3376. return self}, function($ctx1) {$ctx1.fill(self,"testGrulCommitPathJsShouldBeServerGrulJs",{},smalltalk.PackageTest)})},
  3377. args: [],
  3378. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: grulPackage commitPathJs equals: 'server/grul/js'",
  3379. messageSends: ["assert:equals:", "commitPathJs"],
  3380. referencedClasses: []
  3381. }),
  3382. smalltalk.PackageTest);
  3383. smalltalk.addMethod(
  3384. smalltalk.method({
  3385. selector: "testGrulCommitPathStShouldBeGrulSt",
  3386. category: 'tests',
  3387. fn: function (){
  3388. var self=this;
  3389. return smalltalk.withContext(function($ctx1) {
  3390. _st(self)._assert_equals_(_st(self["@grulPackage"])._commitPathSt(),"grul/st");
  3391. return self}, function($ctx1) {$ctx1.fill(self,"testGrulCommitPathStShouldBeGrulSt",{},smalltalk.PackageTest)})},
  3392. args: [],
  3393. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: grulPackage commitPathSt equals: 'grul/st'",
  3394. messageSends: ["assert:equals:", "commitPathSt"],
  3395. referencedClasses: []
  3396. }),
  3397. smalltalk.PackageTest);
  3398. smalltalk.addMethod(
  3399. smalltalk.method({
  3400. selector: "testZorkCommitPathJsShouldBeJs",
  3401. category: 'tests',
  3402. fn: function (){
  3403. var self=this;
  3404. return smalltalk.withContext(function($ctx1) {
  3405. _st(self)._assert_equals_(_st(self["@zorkPackage"])._commitPathJs(),"js");
  3406. return self}, function($ctx1) {$ctx1.fill(self,"testZorkCommitPathJsShouldBeJs",{},smalltalk.PackageTest)})},
  3407. args: [],
  3408. source: "testZorkCommitPathJsShouldBeJs\x0a\x09self assert: zorkPackage commitPathJs equals: 'js'",
  3409. messageSends: ["assert:equals:", "commitPathJs"],
  3410. referencedClasses: []
  3411. }),
  3412. smalltalk.PackageTest);
  3413. smalltalk.addMethod(
  3414. smalltalk.method({
  3415. selector: "testZorkCommitPathStShouldBeSt",
  3416. category: 'tests',
  3417. fn: function (){
  3418. var self=this;
  3419. return smalltalk.withContext(function($ctx1) {
  3420. _st(self)._assert_equals_(_st(self["@zorkPackage"])._commitPathSt(),"st");
  3421. return self}, function($ctx1) {$ctx1.fill(self,"testZorkCommitPathStShouldBeSt",{},smalltalk.PackageTest)})},
  3422. args: [],
  3423. source: "testZorkCommitPathStShouldBeSt\x0a\x09self assert: zorkPackage commitPathSt equals: 'st'",
  3424. messageSends: ["assert:equals:", "commitPathSt"],
  3425. referencedClasses: []
  3426. }),
  3427. smalltalk.PackageTest);
  3428. smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
  3429. smalltalk.addMethod(
  3430. smalltalk.method({
  3431. selector: "setUp",
  3432. category: 'running',
  3433. fn: function (){
  3434. var self=this;
  3435. function $Package(){return smalltalk.Package||(typeof Package=="undefined"?nil:Package)}
  3436. return smalltalk.withContext(function($ctx1) {
  3437. var $1,$2;
  3438. smalltalk.PackageTest.fn.prototype._setUp.apply(_st(self), []);
  3439. $1=$Package();
  3440. _st($1)._defaultCommitPathJs_("javascripts/");
  3441. $2=_st($1)._defaultCommitPathSt_("smalltalk/");
  3442. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.PackageWithDefaultCommitPathChangedTest)})},
  3443. args: [],
  3444. source: "setUp\x0a\x09super setUp.\x0a\x0a\x09Package\x0a\x09\x09defaultCommitPathJs: 'javascripts/';\x0a\x09\x09defaultCommitPathSt: 'smalltalk/'.",
  3445. messageSends: ["setUp", "defaultCommitPathJs:", "defaultCommitPathSt:"],
  3446. referencedClasses: ["Package"]
  3447. }),
  3448. smalltalk.PackageWithDefaultCommitPathChangedTest);
  3449. smalltalk.addMethod(
  3450. smalltalk.method({
  3451. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  3452. category: 'tests',
  3453. fn: function (){
  3454. var self=this;
  3455. return smalltalk.withContext(function($ctx1) {
  3456. _st(self)._assert_equals_(_st(self["@grulPackage"])._commitPathJs(),"server/grul/js");
  3457. return self}, function($ctx1) {$ctx1.fill(self,"testGrulCommitPathJsShouldBeServerGrulJs",{},smalltalk.PackageWithDefaultCommitPathChangedTest)})},
  3458. args: [],
  3459. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: grulPackage commitPathJs equals: 'server/grul/js'",
  3460. messageSends: ["assert:equals:", "commitPathJs"],
  3461. referencedClasses: []
  3462. }),
  3463. smalltalk.PackageWithDefaultCommitPathChangedTest);
  3464. smalltalk.addMethod(
  3465. smalltalk.method({
  3466. selector: "testGrulCommitPathStShouldBeGrulSt",
  3467. category: 'tests',
  3468. fn: function (){
  3469. var self=this;
  3470. return smalltalk.withContext(function($ctx1) {
  3471. _st(self)._assert_equals_(_st(self["@grulPackage"])._commitPathSt(),"grul/st");
  3472. return self}, function($ctx1) {$ctx1.fill(self,"testGrulCommitPathStShouldBeGrulSt",{},smalltalk.PackageWithDefaultCommitPathChangedTest)})},
  3473. args: [],
  3474. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: grulPackage commitPathSt equals: 'grul/st'",
  3475. messageSends: ["assert:equals:", "commitPathSt"],
  3476. referencedClasses: []
  3477. }),
  3478. smalltalk.PackageWithDefaultCommitPathChangedTest);
  3479. smalltalk.addMethod(
  3480. smalltalk.method({
  3481. selector: "testZorkCommitPathJsShouldBeJavascript",
  3482. category: 'tests',
  3483. fn: function (){
  3484. var self=this;
  3485. return smalltalk.withContext(function($ctx1) {
  3486. _st(self)._assert_equals_(_st(self["@zorkPackage"])._commitPathJs(),"javascripts/");
  3487. return self}, function($ctx1) {$ctx1.fill(self,"testZorkCommitPathJsShouldBeJavascript",{},smalltalk.PackageWithDefaultCommitPathChangedTest)})},
  3488. args: [],
  3489. source: "testZorkCommitPathJsShouldBeJavascript\x0a\x09self assert: zorkPackage commitPathJs equals: 'javascripts/'",
  3490. messageSends: ["assert:equals:", "commitPathJs"],
  3491. referencedClasses: []
  3492. }),
  3493. smalltalk.PackageWithDefaultCommitPathChangedTest);
  3494. smalltalk.addMethod(
  3495. smalltalk.method({
  3496. selector: "testZorkCommitPathStShouldBeSmalltalk",
  3497. category: 'tests',
  3498. fn: function (){
  3499. var self=this;
  3500. return smalltalk.withContext(function($ctx1) {
  3501. _st(self)._assert_equals_(_st(self["@zorkPackage"])._commitPathSt(),"smalltalk/");
  3502. return self}, function($ctx1) {$ctx1.fill(self,"testZorkCommitPathStShouldBeSmalltalk",{},smalltalk.PackageWithDefaultCommitPathChangedTest)})},
  3503. args: [],
  3504. source: "testZorkCommitPathStShouldBeSmalltalk\x0a\x09self assert: zorkPackage commitPathSt equals: 'smalltalk/'",
  3505. messageSends: ["assert:equals:", "commitPathSt"],
  3506. referencedClasses: []
  3507. }),
  3508. smalltalk.PackageWithDefaultCommitPathChangedTest);
  3509. smalltalk.addMethod(
  3510. smalltalk.method({
  3511. selector: "shouldInheritSelectors",
  3512. category: 'accessing',
  3513. fn: function (){
  3514. var self=this;
  3515. return smalltalk.withContext(function($ctx1) {
  3516. return false;
  3517. }, function($ctx1) {$ctx1.fill(self,"shouldInheritSelectors",{},smalltalk.PackageWithDefaultCommitPathChangedTest.klass)})},
  3518. args: [],
  3519. source: "shouldInheritSelectors\x0a\x09^ false",
  3520. messageSends: [],
  3521. referencedClasses: []
  3522. }),
  3523. smalltalk.PackageWithDefaultCommitPathChangedTest.klass);
  3524. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3525. smalltalk.addMethod(
  3526. smalltalk.method({
  3527. selector: "testAccessing",
  3528. category: 'tests',
  3529. fn: function (){
  3530. var self=this;
  3531. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  3532. return smalltalk.withContext(function($ctx1) {
  3533. _st(self)._assert_equals_(_st(_st($Point())._x_y_((3),(4)))._x(),(3));
  3534. _st(self)._assert_equals_(_st(_st($Point())._x_y_((3),(4)))._y(),(4));
  3535. _st(self)._assert_equals_(_st(_st(_st($Point())._new())._x_((3)))._x(),(3));
  3536. _st(self)._assert_equals_(_st(_st(_st($Point())._new())._y_((4)))._y(),(4));
  3537. return self}, function($ctx1) {$ctx1.fill(self,"testAccessing",{},smalltalk.PointTest)})},
  3538. args: [],
  3539. 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",
  3540. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  3541. referencedClasses: ["Point"]
  3542. }),
  3543. smalltalk.PointTest);
  3544. smalltalk.addMethod(
  3545. smalltalk.method({
  3546. selector: "testArithmetic",
  3547. category: 'tests',
  3548. fn: function (){
  3549. var self=this;
  3550. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  3551. return smalltalk.withContext(function($ctx1) {
  3552. _st(self)._assert_equals_(_st(_st((3)).__at((4))).__star(_st((3)).__at((4))),_st($Point())._x_y_((9),(16)));
  3553. _st(self)._assert_equals_(_st(_st((3)).__at((4))).__plus(_st((3)).__at((4))),_st($Point())._x_y_((6),(8)));
  3554. _st(self)._assert_equals_(_st(_st((3)).__at((4))).__minus(_st((3)).__at((4))),_st($Point())._x_y_((0),(0)));
  3555. _st(self)._assert_equals_(_st(_st((6)).__at((8))).__slash(_st((3)).__at((4))),_st($Point())._x_y_((2),(2)));
  3556. return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.PointTest)})},
  3557. args: [],
  3558. 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)",
  3559. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  3560. referencedClasses: ["Point"]
  3561. }),
  3562. smalltalk.PointTest);
  3563. smalltalk.addMethod(
  3564. smalltalk.method({
  3565. selector: "testAt",
  3566. category: 'tests',
  3567. fn: function (){
  3568. var self=this;
  3569. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  3570. return smalltalk.withContext(function($ctx1) {
  3571. _st(self)._assert_equals_(_st((3)).__at((4)),_st($Point())._x_y_((3),(4)));
  3572. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.PointTest)})},
  3573. args: [],
  3574. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  3575. messageSends: ["assert:equals:", "@", "x:y:"],
  3576. referencedClasses: ["Point"]
  3577. }),
  3578. smalltalk.PointTest);
  3579. smalltalk.addMethod(
  3580. smalltalk.method({
  3581. selector: "testEgality",
  3582. category: 'tests',
  3583. fn: function (){
  3584. var self=this;
  3585. return smalltalk.withContext(function($ctx1) {
  3586. _st(self)._assert_(_st(_st((3)).__at((4))).__eq(_st((3)).__at((4))));
  3587. _st(self)._deny_(_st(_st((3)).__at((5))).__eq(_st((3)).__at((6))));
  3588. return self}, function($ctx1) {$ctx1.fill(self,"testEgality",{},smalltalk.PointTest)})},
  3589. args: [],
  3590. source: "testEgality\x0a\x09self assert: (3@4 = (3@4)).\x0a\x09self deny: 3@5 = (3@6)",
  3591. messageSends: ["assert:", "=", "@", "deny:"],
  3592. referencedClasses: []
  3593. }),
  3594. smalltalk.PointTest);
  3595. smalltalk.addMethod(
  3596. smalltalk.method({
  3597. selector: "testTranslateBy",
  3598. category: 'tests',
  3599. fn: function (){
  3600. var self=this;
  3601. return smalltalk.withContext(function($ctx1) {
  3602. _st(self)._assert_equals_(_st(_st((3)).__at((3)))._translateBy_(_st((0)).__at((1))),_st((3)).__at((4)));
  3603. _st(self)._assert_equals_(_st(_st((3)).__at((3)))._translateBy_(_st((0)).__at(_st((1))._negated())),_st((3)).__at((2)));
  3604. _st(self)._assert_equals_(_st(_st((3)).__at((3)))._translateBy_(_st((2)).__at((3))),_st((5)).__at((6)));
  3605. _st(self)._assert_equals_(_st(_st((3)).__at((3)))._translateBy_(_st(_st((3))._negated()).__at((0))),_st((0)).__at((3)));
  3606. return self}, function($ctx1) {$ctx1.fill(self,"testTranslateBy",{},smalltalk.PointTest)})},
  3607. args: [],
  3608. source: "testTranslateBy\x0a\x09self assert: (3@3 translateBy: 0@1) equals: 3@4.\x0a\x09self assert: (3@3 translateBy: 0@1 negated) equals: 3@2.\x0a\x09self assert: (3@3 translateBy: 2@3) equals: 5@6.\x0a\x09self assert: (3@3 translateBy: 3 negated @0) equals: 0@3.",
  3609. messageSends: ["assert:equals:", "translateBy:", "@", "negated"],
  3610. referencedClasses: []
  3611. }),
  3612. smalltalk.PointTest);
  3613. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3614. smalltalk.addMethod(
  3615. smalltalk.method({
  3616. selector: "textNext",
  3617. category: 'tests',
  3618. fn: function (){
  3619. var self=this;
  3620. function $Random(){return smalltalk.Random||(typeof Random=="undefined"?nil:Random)}
  3621. return smalltalk.withContext(function($ctx1) {
  3622. _st((10000))._timesRepeat_((function(){
  3623. var current,next;
  3624. return smalltalk.withContext(function($ctx2) {
  3625. next=_st(_st($Random())._new())._next();
  3626. next;
  3627. _st(self)._assert_(_st(next).__gt_eq((0)));
  3628. _st(self)._assert_(_st(next).__lt((1)));
  3629. _st(self)._deny_(_st(current).__eq(next));
  3630. return _st(next).__eq(current);
  3631. }, function($ctx2) {$ctx2.fillBlock({current:current,next:next},$ctx1)})}));
  3632. return self}, function($ctx1) {$ctx1.fill(self,"textNext",{},smalltalk.RandomTest)})},
  3633. args: [],
  3634. 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]",
  3635. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  3636. referencedClasses: ["Random"]
  3637. }),
  3638. smalltalk.RandomTest);
  3639. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3640. smalltalk.addMethod(
  3641. smalltalk.method({
  3642. selector: "testAddRemove",
  3643. category: 'tests',
  3644. fn: function (){
  3645. var self=this;
  3646. var set;
  3647. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  3648. return smalltalk.withContext(function($ctx1) {
  3649. set=_st($Set())._new();
  3650. _st(self)._assert_(_st(set)._isEmpty());
  3651. _st(set)._add_((3));
  3652. _st(self)._assert_(_st(set)._includes_((3)));
  3653. _st(set)._add_((5));
  3654. _st(self)._assert_(_st(set)._includes_((5)));
  3655. _st(set)._remove_((3));
  3656. _st(self)._deny_(_st(set)._includes_((3)));
  3657. return self}, function($ctx1) {$ctx1.fill(self,"testAddRemove",{set:set},smalltalk.SetTest)})},
  3658. args: [],
  3659. 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)",
  3660. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  3661. referencedClasses: ["Set"]
  3662. }),
  3663. smalltalk.SetTest);
  3664. smalltalk.addMethod(
  3665. smalltalk.method({
  3666. selector: "testAt",
  3667. category: 'tests',
  3668. fn: function (){
  3669. var self=this;
  3670. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  3671. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3672. return smalltalk.withContext(function($ctx1) {
  3673. _st(self)._should_raise_((function(){
  3674. return smalltalk.withContext(function($ctx2) {
  3675. return _st(_st($Set())._new())._at_put_((1),(2));
  3676. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$Error());
  3677. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.SetTest)})},
  3678. args: [],
  3679. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  3680. messageSends: ["should:raise:", "at:put:", "new"],
  3681. referencedClasses: ["Set", "Error"]
  3682. }),
  3683. smalltalk.SetTest);
  3684. smalltalk.addMethod(
  3685. smalltalk.method({
  3686. selector: "testCollect",
  3687. category: 'tests',
  3688. fn: function (){
  3689. var self=this;
  3690. return smalltalk.withContext(function($ctx1) {
  3691. _st(self)._assert_equals_(_st(_st([(5), (6), (8)])._asSet())._collect_((function(x){
  3692. return smalltalk.withContext(function($ctx2) {
  3693. return _st(x).__backslash_backslash((3));
  3694. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1)})})),_st([(0), (2)])._asSet());
  3695. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{},smalltalk.SetTest)})},
  3696. args: [],
  3697. source: "testCollect\x0a\x09self assert: (#(5 6 8) asSet collect: [ :x | x \x5c\x5c 3 ]) equals: #(0 2) asSet",
  3698. messageSends: ["assert:equals:", "collect:", "\x5c\x5c", "asSet"],
  3699. referencedClasses: []
  3700. }),
  3701. smalltalk.SetTest);
  3702. smalltalk.addMethod(
  3703. smalltalk.method({
  3704. selector: "testComparing",
  3705. category: 'tests',
  3706. fn: function (){
  3707. var self=this;
  3708. return smalltalk.withContext(function($ctx1) {
  3709. _st(self)._assert_equals_(_st([(0), (2)])._asSet(),_st([(0), (2)])._asSet());
  3710. _st(self)._assert_equals_(_st([(2), (0)])._asSet(),_st([(0), (2)])._asSet());
  3711. _st(self)._deny_(_st(_st([(0), (2), (3)])._asSet()).__eq(_st([(0), (2)])._asSet()));
  3712. _st(self)._deny_(_st(_st([(1), (2)])._asSet()).__eq(_st([(0), (2)])._asSet()));
  3713. return self}, function($ctx1) {$ctx1.fill(self,"testComparing",{},smalltalk.SetTest)})},
  3714. args: [],
  3715. source: "testComparing\x0a\x09self assert: #(0 2) asSet equals: #(0 2) asSet.\x0a\x09self assert: #(2 0) asSet equals: #(0 2) asSet.\x0a\x09self deny: #(0 2 3) asSet = #(0 2) asSet.\x0a\x09self deny: #(1 2) asSet = #(0 2) asSet",
  3716. messageSends: ["assert:equals:", "asSet", "deny:", "="],
  3717. referencedClasses: []
  3718. }),
  3719. smalltalk.SetTest);
  3720. smalltalk.addMethod(
  3721. smalltalk.method({
  3722. selector: "testPrintString",
  3723. category: 'tests',
  3724. fn: function (){
  3725. var self=this;
  3726. var set;
  3727. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  3728. return smalltalk.withContext(function($ctx1) {
  3729. var $1,$2,$3,$4;
  3730. set=_st($Set())._new();
  3731. _st(self)._assert_equals_(_st(set)._printString(),"a Set ()");
  3732. $1=set;
  3733. _st($1)._add_((1));
  3734. $2=_st($1)._add_((3));
  3735. _st(self)._assert_equals_(_st(set)._printString(),"a Set (1 3)");
  3736. _st(set)._add_("foo");
  3737. _st(self)._assert_equals_(_st(set)._printString(),"a Set (1 3 'foo')");
  3738. $3=set;
  3739. _st($3)._remove_((1));
  3740. $4=_st($3)._remove_((3));
  3741. _st(self)._assert_equals_(_st(set)._printString(),"a Set ('foo')");
  3742. _st(set)._add_((3));
  3743. _st(self)._assert_equals_(_st(set)._printString(),"a Set ('foo' 3)");
  3744. _st(set)._add_((3));
  3745. _st(self)._assert_equals_(_st(set)._printString(),"a Set ('foo' 3)");
  3746. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{set:set},smalltalk.SetTest)})},
  3747. args: [],
  3748. source: "testPrintString\x0a\x09| set |\x0a\x09set := Set new.\x0a\x09self assert: set printString equals: 'a Set ()'.\x0a\x09set add: 1; add: 3.\x0a\x09self assert: set printString equals: 'a Set (1 3)'.\x0a\x09set add: 'foo'.\x0a\x09self assert: set printString equals: 'a Set (1 3 ''foo'')'.\x0a\x09set remove: 1; remove: 3.\x0a\x09self assert: set printString equals: 'a Set (''foo'')'.\x0a\x09set add: 3.\x0a\x09self assert: set printString equals: 'a Set (''foo'' 3)'.\x0a\x09set add: 3.\x0a\x09self assert: set printString equals: 'a Set (''foo'' 3)'",
  3749. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:"],
  3750. referencedClasses: ["Set"]
  3751. }),
  3752. smalltalk.SetTest);
  3753. smalltalk.addMethod(
  3754. smalltalk.method({
  3755. selector: "testSize",
  3756. category: 'tests',
  3757. fn: function (){
  3758. var self=this;
  3759. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  3760. return smalltalk.withContext(function($ctx1) {
  3761. _st(self)._assert_equals_(_st(_st($Set())._new())._size(),(0));
  3762. _st(self)._assert_equals_(_st(_st($Set())._withAll_([(1), (2), (3), (4)]))._size(),(4));
  3763. _st(self)._assert_equals_(_st(_st($Set())._withAll_([(1), (1), (1), (1)]))._size(),(1));
  3764. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.SetTest)})},
  3765. args: [],
  3766. 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",
  3767. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  3768. referencedClasses: ["Set"]
  3769. }),
  3770. smalltalk.SetTest);
  3771. smalltalk.addMethod(
  3772. smalltalk.method({
  3773. selector: "testUnicity",
  3774. category: 'tests',
  3775. fn: function (){
  3776. var self=this;
  3777. var set;
  3778. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  3779. return smalltalk.withContext(function($ctx1) {
  3780. set=_st($Set())._new();
  3781. _st(set)._add_((21));
  3782. _st(set)._add_("hello");
  3783. _st(set)._add_((21));
  3784. _st(self)._assert_equals_(_st(set)._size(),(2));
  3785. _st(set)._add_("hello");
  3786. _st(self)._assert_equals_(_st(set)._size(),(2));
  3787. _st(self)._assert_equals_(_st(set)._asArray(),[(21), "hello"]);
  3788. return self}, function($ctx1) {$ctx1.fill(self,"testUnicity",{set:set},smalltalk.SetTest)})},
  3789. args: [],
  3790. 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 equals: 2.\x0a\x09\x0a\x09set add: 'hello'.\x0a\x09self assert: set size equals: 2.\x0a\x0a\x09self assert: set asArray equals: #(21 'hello')",
  3791. messageSends: ["new", "add:", "assert:equals:", "size", "asArray"],
  3792. referencedClasses: ["Set"]
  3793. }),
  3794. smalltalk.SetTest);
  3795. smalltalk.addClass('StreamTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3796. smalltalk.addMethod(
  3797. smalltalk.method({
  3798. selector: "collectionClass",
  3799. category: 'accessing',
  3800. fn: function (){
  3801. var self=this;
  3802. return smalltalk.withContext(function($ctx1) {
  3803. var $1;
  3804. $1=_st(_st(self)._class())._collectionClass();
  3805. return $1;
  3806. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest)})},
  3807. args: [],
  3808. source: "collectionClass\x0a\x09^ self class collectionClass",
  3809. messageSends: ["collectionClass", "class"],
  3810. referencedClasses: []
  3811. }),
  3812. smalltalk.StreamTest);
  3813. smalltalk.addMethod(
  3814. smalltalk.method({
  3815. selector: "newCollection",
  3816. category: 'accessing',
  3817. fn: function (){
  3818. var self=this;
  3819. return smalltalk.withContext(function($ctx1) {
  3820. var $1;
  3821. $1=_st(_st(self)._collectionClass())._new();
  3822. return $1;
  3823. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StreamTest)})},
  3824. args: [],
  3825. source: "newCollection\x0a\x09^ self collectionClass new",
  3826. messageSends: ["new", "collectionClass"],
  3827. referencedClasses: []
  3828. }),
  3829. smalltalk.StreamTest);
  3830. smalltalk.addMethod(
  3831. smalltalk.method({
  3832. selector: "newStream",
  3833. category: 'accessing',
  3834. fn: function (){
  3835. var self=this;
  3836. return smalltalk.withContext(function($ctx1) {
  3837. var $1;
  3838. $1=_st(_st(_st(self)._collectionClass())._new())._stream();
  3839. return $1;
  3840. }, function($ctx1) {$ctx1.fill(self,"newStream",{},smalltalk.StreamTest)})},
  3841. args: [],
  3842. source: "newStream\x0a\x09^ self collectionClass new stream",
  3843. messageSends: ["stream", "new", "collectionClass"],
  3844. referencedClasses: []
  3845. }),
  3846. smalltalk.StreamTest);
  3847. smalltalk.addMethod(
  3848. smalltalk.method({
  3849. selector: "testAtStartAtEnd",
  3850. category: 'tests',
  3851. fn: function (){
  3852. var self=this;
  3853. var stream;
  3854. return smalltalk.withContext(function($ctx1) {
  3855. stream=_st(self)._newStream();
  3856. _st(self)._assert_(_st(stream)._atStart());
  3857. _st(self)._assert_(_st(stream)._atEnd());
  3858. _st(stream)._nextPutAll_(_st(self)._newCollection());
  3859. _st(self)._assert_(_st(stream)._atEnd());
  3860. _st(self)._deny_(_st(stream)._atStart());
  3861. _st(stream)._position_((1));
  3862. _st(self)._deny_(_st(stream)._atEnd());
  3863. _st(self)._deny_(_st(stream)._atStart());
  3864. return self}, function($ctx1) {$ctx1.fill(self,"testAtStartAtEnd",{stream:stream},smalltalk.StreamTest)})},
  3865. args: [],
  3866. source: "testAtStartAtEnd\x0a\x09| stream |\x0a\x09\x0a\x09stream := self newStream.\x0a\x09self assert: stream atStart.\x0a\x09self assert: stream atEnd.\x0a\x09\x0a\x09stream nextPutAll: self newCollection.\x0a\x09self assert: stream atEnd.\x0a\x09self deny: stream atStart.\x0a\x09\x0a\x09stream position: 1.\x0a\x09self deny: stream atEnd.\x0a\x09self deny: stream atStart",
  3867. messageSends: ["newStream", "assert:", "atStart", "atEnd", "nextPutAll:", "newCollection", "deny:", "position:"],
  3868. referencedClasses: []
  3869. }),
  3870. smalltalk.StreamTest);
  3871. smalltalk.addMethod(
  3872. smalltalk.method({
  3873. selector: "testContents",
  3874. category: 'tests',
  3875. fn: function (){
  3876. var self=this;
  3877. var stream;
  3878. return smalltalk.withContext(function($ctx1) {
  3879. stream=_st(self)._newStream();
  3880. _st(stream)._nextPutAll_(_st(self)._newCollection());
  3881. _st(self)._assert_equals_(_st(stream)._contents(),_st(self)._newCollection());
  3882. return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
  3883. args: [],
  3884. source: "testContents\x0a\x09| stream |\x0a\x09\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: self newCollection.\x0a\x09\x0a\x09self assert: stream contents equals: self newCollection",
  3885. messageSends: ["newStream", "nextPutAll:", "newCollection", "assert:equals:", "contents"],
  3886. referencedClasses: []
  3887. }),
  3888. smalltalk.StreamTest);
  3889. smalltalk.addMethod(
  3890. smalltalk.method({
  3891. selector: "testIsEmpty",
  3892. category: 'tests',
  3893. fn: function (){
  3894. var self=this;
  3895. var stream;
  3896. return smalltalk.withContext(function($ctx1) {
  3897. stream=_st(self)._newStream();
  3898. _st(self)._assert_(_st(stream)._isEmpty());
  3899. _st(stream)._nextPutAll_(_st(self)._newCollection());
  3900. _st(self)._deny_(_st(stream)._isEmpty());
  3901. return self}, function($ctx1) {$ctx1.fill(self,"testIsEmpty",{stream:stream},smalltalk.StreamTest)})},
  3902. args: [],
  3903. source: "testIsEmpty\x0a\x09| stream |\x0a\x09\x0a\x09stream := self newStream.\x0a\x09self assert: stream isEmpty.\x0a\x09\x0a\x09stream nextPutAll: self newCollection.\x0a\x09self deny: stream isEmpty",
  3904. messageSends: ["newStream", "assert:", "isEmpty", "nextPutAll:", "newCollection", "deny:"],
  3905. referencedClasses: []
  3906. }),
  3907. smalltalk.StreamTest);
  3908. smalltalk.addMethod(
  3909. smalltalk.method({
  3910. selector: "testPosition",
  3911. category: 'tests',
  3912. fn: function (){
  3913. var self=this;
  3914. var collection,stream;
  3915. return smalltalk.withContext(function($ctx1) {
  3916. collection=_st(self)._newCollection();
  3917. stream=_st(self)._newStream();
  3918. _st(stream)._nextPutAll_(collection);
  3919. _st(self)._assert_equals_(_st(stream)._position(),_st(collection)._size());
  3920. _st(stream)._position_((0));
  3921. _st(self)._assert_equals_(_st(stream)._position(),(0));
  3922. _st(stream)._next();
  3923. _st(self)._assert_equals_(_st(stream)._position(),(1));
  3924. _st(stream)._next();
  3925. _st(self)._assert_equals_(_st(stream)._position(),(2));
  3926. return self}, function($ctx1) {$ctx1.fill(self,"testPosition",{collection:collection,stream:stream},smalltalk.StreamTest)})},
  3927. args: [],
  3928. source: "testPosition\x0a\x09| collection stream |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09stream nextPutAll: collection.\x0a\x09self assert: stream position equals: collection size.\x0a\x09\x0a\x09stream position: 0.\x0a\x09self assert: stream position equals: 0.\x0a\x09\x0a\x09stream next.\x0a\x09self assert: stream position equals: 1.\x0a\x09\x0a\x09stream next.\x0a\x09self assert: stream position equals: 2",
  3929. messageSends: ["newCollection", "newStream", "nextPutAll:", "assert:equals:", "position", "size", "position:", "next"],
  3930. referencedClasses: []
  3931. }),
  3932. smalltalk.StreamTest);
  3933. smalltalk.addMethod(
  3934. smalltalk.method({
  3935. selector: "testReading",
  3936. category: 'tests',
  3937. fn: function (){
  3938. var self=this;
  3939. var stream,collection;
  3940. return smalltalk.withContext(function($ctx1) {
  3941. var $1,$2;
  3942. collection=_st(self)._newCollection();
  3943. stream=_st(self)._newStream();
  3944. $1=stream;
  3945. _st($1)._nextPutAll_(collection);
  3946. $2=_st($1)._position_((0));
  3947. _st(collection)._do_((function(each){
  3948. return smalltalk.withContext(function($ctx2) {
  3949. return _st(self)._assert_equals_(_st(stream)._next(),each);
  3950. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  3951. _st(self)._assert_(_st(_st(stream)._next())._isNil());
  3952. return self}, function($ctx1) {$ctx1.fill(self,"testReading",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  3953. args: [],
  3954. source: "testReading\x0a\x09| stream collection |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09stream \x0a\x09\x09nextPutAll: collection;\x0a\x09\x09position: 0.\x0a\x09\x0a\x09collection do: [ :each |\x0a\x09\x09self assert: stream next equals: each ].\x0a\x09\x09\x0a\x09self assert: stream next isNil",
  3955. messageSends: ["newCollection", "newStream", "nextPutAll:", "position:", "do:", "assert:equals:", "next", "assert:", "isNil"],
  3956. referencedClasses: []
  3957. }),
  3958. smalltalk.StreamTest);
  3959. smalltalk.addMethod(
  3960. smalltalk.method({
  3961. selector: "testStreamContents",
  3962. category: 'tests',
  3963. fn: function (){
  3964. var self=this;
  3965. return smalltalk.withContext(function($ctx1) {
  3966. return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StreamTest)})},
  3967. args: [],
  3968. source: "testStreamContents",
  3969. messageSends: [],
  3970. referencedClasses: []
  3971. }),
  3972. smalltalk.StreamTest);
  3973. smalltalk.addMethod(
  3974. smalltalk.method({
  3975. selector: "testWrite",
  3976. category: 'tests',
  3977. fn: function (){
  3978. var self=this;
  3979. var stream,collection;
  3980. return smalltalk.withContext(function($ctx1) {
  3981. collection=_st(self)._newCollection();
  3982. stream=_st(self)._newStream();
  3983. _st(collection)._do_((function(each){
  3984. return smalltalk.withContext(function($ctx2) {
  3985. return _st(stream).__lt_lt(each);
  3986. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  3987. _st(self)._assert_equals_(_st(stream)._contents(),collection);
  3988. return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  3989. args: [],
  3990. source: "testWrite\x0a\x09| stream collection |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09collection do: [ :each | stream << each ].\x0a\x09self assert: stream contents equals: collection",
  3991. messageSends: ["newCollection", "newStream", "do:", "<<", "assert:equals:", "contents"],
  3992. referencedClasses: []
  3993. }),
  3994. smalltalk.StreamTest);
  3995. smalltalk.addMethod(
  3996. smalltalk.method({
  3997. selector: "testWriting",
  3998. category: 'tests',
  3999. fn: function (){
  4000. var self=this;
  4001. var stream,collection;
  4002. return smalltalk.withContext(function($ctx1) {
  4003. collection=_st(self)._newCollection();
  4004. stream=_st(self)._newStream();
  4005. _st(collection)._do_((function(each){
  4006. return smalltalk.withContext(function($ctx2) {
  4007. return _st(stream)._nextPut_(each);
  4008. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  4009. _st(self)._assert_equals_(_st(stream)._contents(),collection);
  4010. stream=_st(self)._newStream();
  4011. _st(stream)._nextPutAll_(collection);
  4012. _st(self)._assert_equals_(_st(stream)._contents(),collection);
  4013. return self}, function($ctx1) {$ctx1.fill(self,"testWriting",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  4014. args: [],
  4015. source: "testWriting\x0a\x09| stream collection |\x0a\x09\x0a\x09collection := self newCollection.\x0a\x09stream := self newStream.\x0a\x09\x0a\x09collection do: [ :each | stream nextPut: each ].\x0a\x09self assert: stream contents equals: collection.\x0a\x09\x0a\x09stream := self newStream.\x0a\x09stream nextPutAll: collection.\x0a\x09self assert: stream contents equals: collection",
  4016. messageSends: ["newCollection", "newStream", "do:", "nextPut:", "assert:equals:", "contents", "nextPutAll:"],
  4017. referencedClasses: []
  4018. }),
  4019. smalltalk.StreamTest);
  4020. smalltalk.addMethod(
  4021. smalltalk.method({
  4022. selector: "collectionClass",
  4023. category: 'accessing',
  4024. fn: function (){
  4025. var self=this;
  4026. return smalltalk.withContext(function($ctx1) {
  4027. return nil;
  4028. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest.klass)})},
  4029. args: [],
  4030. source: "collectionClass\x0a\x09^ nil",
  4031. messageSends: [],
  4032. referencedClasses: []
  4033. }),
  4034. smalltalk.StreamTest.klass);
  4035. smalltalk.addMethod(
  4036. smalltalk.method({
  4037. selector: "isAbstract",
  4038. category: 'testing',
  4039. fn: function (){
  4040. var self=this;
  4041. return smalltalk.withContext(function($ctx1) {
  4042. var $1;
  4043. $1=_st(_st(self)._collectionClass())._isNil();
  4044. return $1;
  4045. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.StreamTest.klass)})},
  4046. args: [],
  4047. source: "isAbstract\x0a\x09^ self collectionClass isNil",
  4048. messageSends: ["isNil", "collectionClass"],
  4049. referencedClasses: []
  4050. }),
  4051. smalltalk.StreamTest.klass);
  4052. smalltalk.addClass('ArrayStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
  4053. smalltalk.addMethod(
  4054. smalltalk.method({
  4055. selector: "newCollection",
  4056. category: 'accessing',
  4057. fn: function (){
  4058. var self=this;
  4059. return smalltalk.withContext(function($ctx1) {
  4060. var $1;
  4061. $1=[true,(1),_st((3)).__at((4)),"foo"];
  4062. return $1;
  4063. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.ArrayStreamTest)})},
  4064. args: [],
  4065. source: "newCollection\x0a\x09^ { true. 1. 3@4. 'foo' }",
  4066. messageSends: ["@"],
  4067. referencedClasses: []
  4068. }),
  4069. smalltalk.ArrayStreamTest);
  4070. smalltalk.addMethod(
  4071. smalltalk.method({
  4072. selector: "collectionClass",
  4073. category: 'accessing',
  4074. fn: function (){
  4075. var self=this;
  4076. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  4077. return smalltalk.withContext(function($ctx1) {
  4078. var $1;
  4079. $1=$Array();
  4080. return $1;
  4081. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayStreamTest.klass)})},
  4082. args: [],
  4083. source: "collectionClass\x0a\x09^ Array",
  4084. messageSends: [],
  4085. referencedClasses: ["Array"]
  4086. }),
  4087. smalltalk.ArrayStreamTest.klass);
  4088. smalltalk.addClass('StringStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
  4089. smalltalk.addMethod(
  4090. smalltalk.method({
  4091. selector: "newCollection",
  4092. category: 'accessing',
  4093. fn: function (){
  4094. var self=this;
  4095. return smalltalk.withContext(function($ctx1) {
  4096. return "hello world";
  4097. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StringStreamTest)})},
  4098. args: [],
  4099. source: "newCollection\x0a\x09^ 'hello world'",
  4100. messageSends: [],
  4101. referencedClasses: []
  4102. }),
  4103. smalltalk.StringStreamTest);
  4104. smalltalk.addMethod(
  4105. smalltalk.method({
  4106. selector: "collectionClass",
  4107. category: 'accessing',
  4108. fn: function (){
  4109. var self=this;
  4110. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  4111. return smalltalk.withContext(function($ctx1) {
  4112. var $1;
  4113. $1=$String();
  4114. return $1;
  4115. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringStreamTest.klass)})},
  4116. args: [],
  4117. source: "collectionClass\x0a\x09^ String",
  4118. messageSends: [],
  4119. referencedClasses: ["String"]
  4120. }),
  4121. smalltalk.StringStreamTest.klass);
  4122. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4123. smalltalk.addMethod(
  4124. smalltalk.method({
  4125. selector: "testCopying",
  4126. category: 'tests',
  4127. fn: function (){
  4128. var self=this;
  4129. return smalltalk.withContext(function($ctx1) {
  4130. _st(self)._assert_equals_(_st(nil)._copy(),nil);
  4131. return self}, function($ctx1) {$ctx1.fill(self,"testCopying",{},smalltalk.UndefinedTest)})},
  4132. args: [],
  4133. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  4134. messageSends: ["assert:equals:", "copy"],
  4135. referencedClasses: []
  4136. }),
  4137. smalltalk.UndefinedTest);
  4138. smalltalk.addMethod(
  4139. smalltalk.method({
  4140. selector: "testDeepCopy",
  4141. category: 'tests',
  4142. fn: function (){
  4143. var self=this;
  4144. return smalltalk.withContext(function($ctx1) {
  4145. _st(self)._assert_(_st(_st(nil)._deepCopy()).__eq(nil));
  4146. return self}, function($ctx1) {$ctx1.fill(self,"testDeepCopy",{},smalltalk.UndefinedTest)})},
  4147. args: [],
  4148. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  4149. messageSends: ["assert:", "=", "deepCopy"],
  4150. referencedClasses: []
  4151. }),
  4152. smalltalk.UndefinedTest);
  4153. smalltalk.addMethod(
  4154. smalltalk.method({
  4155. selector: "testIfNil",
  4156. category: 'tests',
  4157. fn: function (){
  4158. var self=this;
  4159. return smalltalk.withContext(function($ctx1) {
  4160. var $1,$2,$3,$5,$4,$6,$7,$8,$10,$9;
  4161. $1=self;
  4162. if(($receiver = nil) == nil || $receiver == undefined){
  4163. $2=true;
  4164. } else {
  4165. $2=nil;
  4166. };
  4167. _st($1)._assert_equals_($2,true);
  4168. $3=self;
  4169. if(($receiver = nil) == nil || $receiver == undefined){
  4170. $5=nil;
  4171. } else {
  4172. $5=true;
  4173. };
  4174. $4=_st($5).__eq(true);
  4175. _st($3)._deny_($4);
  4176. $6=self;
  4177. if(($receiver = nil) == nil || $receiver == undefined){
  4178. $7=true;
  4179. } else {
  4180. $7=false;
  4181. };
  4182. _st($6)._assert_equals_($7,true);
  4183. $8=self;
  4184. if(($receiver = nil) == nil || $receiver == undefined){
  4185. $10=false;
  4186. } else {
  4187. $10=true;
  4188. };
  4189. $9=_st($10).__eq(true);
  4190. _st($8)._deny_($9);
  4191. return self}, function($ctx1) {$ctx1.fill(self,"testIfNil",{},smalltalk.UndefinedTest)})},
  4192. args: [],
  4193. 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",
  4194. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  4195. referencedClasses: []
  4196. }),
  4197. smalltalk.UndefinedTest);
  4198. smalltalk.addMethod(
  4199. smalltalk.method({
  4200. selector: "testIsNil",
  4201. category: 'tests',
  4202. fn: function (){
  4203. var self=this;
  4204. return smalltalk.withContext(function($ctx1) {
  4205. _st(self)._assert_(_st(nil)._isNil());
  4206. _st(self)._deny_(_st(nil)._notNil());
  4207. return self}, function($ctx1) {$ctx1.fill(self,"testIsNil",{},smalltalk.UndefinedTest)})},
  4208. args: [],
  4209. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  4210. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  4211. referencedClasses: []
  4212. }),
  4213. smalltalk.UndefinedTest);