Kernel-Tests.js 235 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673
  1. define("amber_core/Kernel-Tests", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/SUnit", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Kernel-Tests');
  3. smalltalk.packages["Kernel-Tests"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('AnnouncementSubscriptionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "testHandlesAnnouncement",
  8. category: 'tests',
  9. fn: function (){
  10. var self=this;
  11. var subscription,announcementClass1,announcementClass2,classBuilder;
  12. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  13. function $SystemAnnouncement(){return smalltalk.SystemAnnouncement||(typeof SystemAnnouncement=="undefined"?nil:SystemAnnouncement)}
  14. function $AnnouncementSubscription(){return smalltalk.AnnouncementSubscription||(typeof AnnouncementSubscription=="undefined"?nil:AnnouncementSubscription)}
  15. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  16. return smalltalk.withContext(function($ctx1) {
  17. classBuilder=_st($ClassBuilder())._new();
  18. announcementClass1=_st(classBuilder)._basicAddSubclassOf_named_instanceVariableNames_package_($SystemAnnouncement(),"TestAnnouncement1",[],"Kernel-Tests");
  19. subscription=_st(_st($AnnouncementSubscription())._new())._announcementClass_($SystemAnnouncement());
  20. self._assert_equals_(_st(subscription)._handlesAnnouncement_($SystemAnnouncement()),true);
  21. self._assert_equals_(_st(subscription)._handlesAnnouncement_(announcementClass1),true);
  22. self._assert_equals_(_st(subscription)._handlesAnnouncement_($Object()),false);
  23. _st(classBuilder)._basicRemoveClass_(announcementClass1);
  24. return self}, function($ctx1) {$ctx1.fill(self,"testHandlesAnnouncement",{subscription:subscription,announcementClass1:announcementClass1,announcementClass2:announcementClass2,classBuilder:classBuilder},smalltalk.AnnouncementSubscriptionTest)})},
  25. args: [],
  26. source: "testHandlesAnnouncement\x0a\x09| subscription announcementClass1 announcementClass2 classBuilder |\x0a\x09\x0a\x09classBuilder := ClassBuilder new.\x0a\x09announcementClass1 := classBuilder basicAddSubclassOf: SystemAnnouncement named: 'TestAnnouncement1' instanceVariableNames: #() package: 'Kernel-Tests'.\x0a\x09\x0a\x09subscription := AnnouncementSubscription new announcementClass: SystemAnnouncement.\x0a\x09\x22Test whether the same class triggers the announcement\x22\x0a\x09self assert: (subscription handlesAnnouncement: SystemAnnouncement) equals: true.\x0a\x09\x22Test whether a subclass triggers the announcement\x22\x0a\x09self assert: (subscription handlesAnnouncement: announcementClass1) equals: true.\x0a\x09\x22Test whether an unrelated class does not trigger the announcement\x22\x0a\x09self assert: (subscription handlesAnnouncement: Object) equals: false.\x0a\x09\x0a\x09classBuilder basicRemoveClass: announcementClass1.",
  27. messageSends: ["new", "basicAddSubclassOf:named:instanceVariableNames:package:", "announcementClass:", "assert:equals:", "handlesAnnouncement:", "basicRemoveClass:"],
  28. referencedClasses: ["ClassBuilder", "SystemAnnouncement", "AnnouncementSubscription", "Object"]
  29. }),
  30. smalltalk.AnnouncementSubscriptionTest);
  31. smalltalk.addClass('BlockClosureTest', smalltalk.TestCase, [], 'Kernel-Tests');
  32. smalltalk.addMethod(
  33. smalltalk.method({
  34. selector: "testCanClearInterval",
  35. category: 'tests',
  36. fn: function (){
  37. var self=this;
  38. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  39. return smalltalk.withContext(function($ctx1) {
  40. self._shouldnt_raise_((function(){
  41. return smalltalk.withContext(function($ctx2) {
  42. return _st(_st((function(){
  43. return smalltalk.withContext(function($ctx3) {
  44. return _st(_st($Error())._new())._signal();
  45. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}))._valueWithInterval_((0)))._clearInterval();
  46. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  47. return self}, function($ctx1) {$ctx1.fill(self,"testCanClearInterval",{},smalltalk.BlockClosureTest)})},
  48. args: [],
  49. source: "testCanClearInterval\x0a\x09self shouldnt: [([Error new signal] valueWithInterval: 0) clearInterval] raise: Error",
  50. messageSends: ["shouldnt:raise:", "clearInterval", "valueWithInterval:", "signal", "new"],
  51. referencedClasses: ["Error"]
  52. }),
  53. smalltalk.BlockClosureTest);
  54. smalltalk.addMethod(
  55. smalltalk.method({
  56. selector: "testCanClearTimeout",
  57. category: 'tests',
  58. fn: function (){
  59. var self=this;
  60. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  61. return smalltalk.withContext(function($ctx1) {
  62. self._shouldnt_raise_((function(){
  63. return smalltalk.withContext(function($ctx2) {
  64. return _st(_st((function(){
  65. return smalltalk.withContext(function($ctx3) {
  66. return _st(_st($Error())._new())._signal();
  67. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}))._valueWithTimeout_((0)))._clearTimeout();
  68. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  69. return self}, function($ctx1) {$ctx1.fill(self,"testCanClearTimeout",{},smalltalk.BlockClosureTest)})},
  70. args: [],
  71. source: "testCanClearTimeout\x0a\x09self shouldnt: [([Error new signal] valueWithTimeout: 0) clearTimeout] raise: Error",
  72. messageSends: ["shouldnt:raise:", "clearTimeout", "valueWithTimeout:", "signal", "new"],
  73. referencedClasses: ["Error"]
  74. }),
  75. smalltalk.BlockClosureTest);
  76. smalltalk.addMethod(
  77. smalltalk.method({
  78. selector: "testCompiledSource",
  79. category: 'tests',
  80. fn: function (){
  81. var self=this;
  82. return smalltalk.withContext(function($ctx1) {
  83. self._assert_(_st(_st((function(){
  84. return smalltalk.withContext(function($ctx2) {
  85. return (1).__plus((1));
  86. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._compiledSource())._includesSubString_("function"));
  87. return self}, function($ctx1) {$ctx1.fill(self,"testCompiledSource",{},smalltalk.BlockClosureTest)})},
  88. args: [],
  89. source: "testCompiledSource\x0a\x09self assert: ([1+1] compiledSource includesSubString: 'function')",
  90. messageSends: ["assert:", "includesSubString:", "compiledSource", "+"],
  91. referencedClasses: []
  92. }),
  93. smalltalk.BlockClosureTest);
  94. smalltalk.addMethod(
  95. smalltalk.method({
  96. selector: "testCurrySelf",
  97. category: 'tests',
  98. fn: function (){
  99. var self=this;
  100. var curriedMethod,array;
  101. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  102. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  103. return smalltalk.withContext(function($ctx1) {
  104. curriedMethod=_st(_st((function(selfarg,x){
  105. return smalltalk.withContext(function($ctx2) {
  106. return _st(selfarg)._at_(x);
  107. }, function($ctx2) {$ctx2.fillBlock({selfarg:selfarg,x:x},$ctx1,1)})}))._currySelf())._asCompiledMethod_("foo:");
  108. array=[(3), (1), (4)];
  109. _st(_st($ClassBuilder())._new())._installMethod_forClass_category_(curriedMethod,$Array(),"**test helper");
  110. _st((function(){
  111. return smalltalk.withContext(function($ctx2) {
  112. return self._assert_equals_(_st(array)._foo_((2)),(1));
  113. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}))._ensure_((function(){
  114. return smalltalk.withContext(function($ctx2) {
  115. return _st($Array())._removeCompiledMethod_(curriedMethod);
  116. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  117. return self}, function($ctx1) {$ctx1.fill(self,"testCurrySelf",{curriedMethod:curriedMethod,array:array},smalltalk.BlockClosureTest)})},
  118. args: [],
  119. 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 ]",
  120. messageSends: ["asCompiledMethod:", "currySelf", "at:", "installMethod:forClass:category:", "new", "ensure:", "assert:equals:", "foo:", "removeCompiledMethod:"],
  121. referencedClasses: ["ClassBuilder", "Array"]
  122. }),
  123. smalltalk.BlockClosureTest);
  124. smalltalk.addMethod(
  125. smalltalk.method({
  126. selector: "testEnsure",
  127. category: 'tests',
  128. fn: function (){
  129. var self=this;
  130. return smalltalk.withContext(function($ctx1) {
  131. self._assert_equals_(_st((function(){
  132. return smalltalk.withContext(function($ctx2) {
  133. return (3);
  134. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._ensure_((function(){
  135. return smalltalk.withContext(function($ctx2) {
  136. return (4);
  137. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),(3));
  138. return self}, function($ctx1) {$ctx1.fill(self,"testEnsure",{},smalltalk.BlockClosureTest)})},
  139. args: [],
  140. source: "testEnsure\x0a\x09self assert: ([3] ensure: [4]) equals: 3",
  141. messageSends: ["assert:equals:", "ensure:"],
  142. referencedClasses: []
  143. }),
  144. smalltalk.BlockClosureTest);
  145. smalltalk.addMethod(
  146. smalltalk.method({
  147. selector: "testEnsureRaises",
  148. category: 'tests',
  149. fn: function (){
  150. var self=this;
  151. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  152. return smalltalk.withContext(function($ctx1) {
  153. self._should_raise_((function(){
  154. return smalltalk.withContext(function($ctx2) {
  155. return _st((function(){
  156. return smalltalk.withContext(function($ctx3) {
  157. return _st(_st($Error())._new())._signal();
  158. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}))._ensure_((function(){
  159. return smalltalk.withContext(function($ctx3) {
  160. return true;
  161. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)})}));
  162. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  163. return self}, function($ctx1) {$ctx1.fill(self,"testEnsureRaises",{},smalltalk.BlockClosureTest)})},
  164. args: [],
  165. source: "testEnsureRaises\x0a\x09self should: [[Error new signal] ensure: [true]] raise: Error",
  166. messageSends: ["should:raise:", "ensure:", "signal", "new"],
  167. referencedClasses: ["Error"]
  168. }),
  169. smalltalk.BlockClosureTest);
  170. smalltalk.addMethod(
  171. smalltalk.method({
  172. selector: "testExceptionSemantics",
  173. category: 'tests',
  174. fn: function (){
  175. var self=this;
  176. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  177. return smalltalk.withContext(function($ctx1) {
  178. self._timeout_((100));
  179. _st(self._async_((function(){
  180. return smalltalk.withContext(function($ctx2) {
  181. return _st((function(){
  182. return smalltalk.withContext(function($ctx3) {
  183. self._assert_(true);
  184. _st($Error())._signal();
  185. self._deny_(true);
  186. return self._finished();
  187. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}))._on_do_($Error(),(function(ex){
  188. return smalltalk.withContext(function($ctx3) {
  189. return self._finished();
  190. }, function($ctx3) {$ctx3.fillBlock({ex:ex},$ctx2,3)})}));
  191. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))._valueWithTimeout_((0));
  192. return self}, function($ctx1) {$ctx1.fill(self,"testExceptionSemantics",{},smalltalk.BlockClosureTest)})},
  193. args: [],
  194. 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",
  195. messageSends: ["timeout:", "valueWithTimeout:", "async:", "on:do:", "assert:", "signal", "deny:", "finished"],
  196. referencedClasses: ["Error"]
  197. }),
  198. smalltalk.BlockClosureTest);
  199. smalltalk.addMethod(
  200. smalltalk.method({
  201. selector: "testNewWithValues",
  202. category: 'tests',
  203. fn: function (){
  204. var self=this;
  205. return smalltalk.withContext(function($ctx1) {
  206. function theTestPrototype() {this.name = "theTestPrototype";}
  207. function theTestConstructor(arg1, arg2, arg3) {}
  208. theTestConstructor.prototype = new theTestPrototype;
  209. var theWrappedConstructor = _st(theTestConstructor);
  210. var theResult = theWrappedConstructor._newWithValues_([1, 2, 3]);
  211. self._assert_equals_(Object.getPrototypeOf(theResult).name, 'theTestPrototype');
  212. "newWithValues: cannot help if the argument list is wrong, and should warn that a mistake was made."
  213. function constructionShouldFail() {var anotherResult = theWrappedConstructor._newWithValues_('This is so wrong');}
  214. self._should_raise_(_st(constructionShouldFail), smalltalk.Error);;
  215. return self}, function($ctx1) {$ctx1.fill(self,"testNewWithValues",{},smalltalk.BlockClosureTest)})},
  216. args: [],
  217. source: "testNewWithValues\x0a<\x0a\x09function theTestPrototype() {this.name = \x22theTestPrototype\x22;}\x0a\x09function theTestConstructor(arg1, arg2, arg3) {}\x0a\x09theTestConstructor.prototype = new theTestPrototype;\x0a\x0a\x09var theWrappedConstructor = _st(theTestConstructor);\x0a\x09var theResult = theWrappedConstructor._newWithValues_([1, 2, 3]);\x0a\x09self._assert_equals_(Object.getPrototypeOf(theResult).name, 'theTestPrototype');\x0a\x0a\x09\x22newWithValues: cannot help if the argument list is wrong, and should warn that a mistake was made.\x22\x0a\x09function constructionShouldFail() {var anotherResult = theWrappedConstructor._newWithValues_('This is so wrong');}\x0a\x09self._should_raise_(_st(constructionShouldFail), smalltalk.Error);\x0a>",
  218. messageSends: [],
  219. referencedClasses: []
  220. }),
  221. smalltalk.BlockClosureTest);
  222. smalltalk.addMethod(
  223. smalltalk.method({
  224. selector: "testNumArgs",
  225. category: 'tests',
  226. fn: function (){
  227. var self=this;
  228. return smalltalk.withContext(function($ctx1) {
  229. self._assert_equals_(_st((function(){
  230. return smalltalk.withContext(function($ctx2) {
  231. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._numArgs(),(0));
  232. self._assert_equals_(_st((function(a,b){
  233. return smalltalk.withContext(function($ctx2) {
  234. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,2)})}))._numArgs(),(2));
  235. return self}, function($ctx1) {$ctx1.fill(self,"testNumArgs",{},smalltalk.BlockClosureTest)})},
  236. args: [],
  237. source: "testNumArgs\x0a\x09self assert: [] numArgs equals: 0.\x0a\x09self assert: [:a :b | ] numArgs equals: 2",
  238. messageSends: ["assert:equals:", "numArgs"],
  239. referencedClasses: []
  240. }),
  241. smalltalk.BlockClosureTest);
  242. smalltalk.addMethod(
  243. smalltalk.method({
  244. selector: "testOnDo",
  245. category: 'tests',
  246. fn: function (){
  247. var self=this;
  248. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  249. return smalltalk.withContext(function($ctx1) {
  250. self._assert_(_st((function(){
  251. return smalltalk.withContext(function($ctx2) {
  252. return _st(_st($Error())._new())._signal();
  253. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(ex){
  254. return smalltalk.withContext(function($ctx2) {
  255. return true;
  256. }, function($ctx2) {$ctx2.fillBlock({ex:ex},$ctx1,2)})})));
  257. return self}, function($ctx1) {$ctx1.fill(self,"testOnDo",{},smalltalk.BlockClosureTest)})},
  258. args: [],
  259. source: "testOnDo\x0a\x09self assert: ([Error new signal] on: Error do: [:ex | true])",
  260. messageSends: ["assert:", "on:do:", "signal", "new"],
  261. referencedClasses: ["Error"]
  262. }),
  263. smalltalk.BlockClosureTest);
  264. smalltalk.addMethod(
  265. smalltalk.method({
  266. selector: "testValue",
  267. category: 'tests',
  268. fn: function (){
  269. var self=this;
  270. return smalltalk.withContext(function($ctx1) {
  271. self._assert_equals_(_st((function(){
  272. return smalltalk.withContext(function($ctx2) {
  273. return (1).__plus((1));
  274. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._value(),(2));
  275. self._assert_equals_(_st((function(x){
  276. return smalltalk.withContext(function($ctx2) {
  277. return _st(x).__plus((1));
  278. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,2)})}))._value_((2)),(3));
  279. self._assert_equals_(_st((function(x,y){
  280. return smalltalk.withContext(function($ctx2) {
  281. return _st(x).__star(y);
  282. }, function($ctx2) {$ctx2.fillBlock({x:x,y:y},$ctx1,3)})}))._value_value_((2),(4)),(8));
  283. self._assert_equals_(_st((function(a,b,c){
  284. return smalltalk.withContext(function($ctx2) {
  285. return (1);
  286. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b,c:c},$ctx1,4)})}))._value(),(1));
  287. return self}, function($ctx1) {$ctx1.fill(self,"testValue",{},smalltalk.BlockClosureTest)})},
  288. args: [],
  289. 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",
  290. messageSends: ["assert:equals:", "value", "+", "value:", "value:value:", "*"],
  291. referencedClasses: []
  292. }),
  293. smalltalk.BlockClosureTest);
  294. smalltalk.addMethod(
  295. smalltalk.method({
  296. selector: "testValueWithPossibleArguments",
  297. category: 'tests',
  298. fn: function (){
  299. var self=this;
  300. return smalltalk.withContext(function($ctx1) {
  301. self._assert_equals_(_st((function(){
  302. return smalltalk.withContext(function($ctx2) {
  303. return (1);
  304. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._valueWithPossibleArguments_([(3), (4)]),(1));
  305. self._assert_equals_(_st((function(a){
  306. return smalltalk.withContext(function($ctx2) {
  307. return _st(a).__plus((4));
  308. }, function($ctx2) {$ctx2.fillBlock({a:a},$ctx1,2)})}))._valueWithPossibleArguments_([(3), (4)]),(7));
  309. self._assert_equals_(_st((function(a,b){
  310. return smalltalk.withContext(function($ctx2) {
  311. return _st(a).__plus(b);
  312. }, function($ctx2) {$ctx2.fillBlock({a:a,b:b},$ctx1,3)})}))._valueWithPossibleArguments_([(3), (4), (5)]),(7));
  313. return self}, function($ctx1) {$ctx1.fill(self,"testValueWithPossibleArguments",{},smalltalk.BlockClosureTest)})},
  314. args: [],
  315. 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.",
  316. messageSends: ["assert:equals:", "valueWithPossibleArguments:", "+"],
  317. referencedClasses: []
  318. }),
  319. smalltalk.BlockClosureTest);
  320. smalltalk.addMethod(
  321. smalltalk.method({
  322. selector: "testWhileFalse",
  323. category: 'tests',
  324. fn: function (){
  325. var self=this;
  326. var i;
  327. return smalltalk.withContext(function($ctx1) {
  328. i=(0);
  329. _st((function(){
  330. return smalltalk.withContext(function($ctx2) {
  331. return _st(i).__gt((5));
  332. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileFalse_((function(){
  333. return smalltalk.withContext(function($ctx2) {
  334. i=_st(i).__plus((1));
  335. return i;
  336. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  337. self._assert_equals_(i,(6));
  338. i=(0);
  339. _st((function(){
  340. return smalltalk.withContext(function($ctx2) {
  341. i=_st(i).__plus((1));
  342. i;
  343. return _st(i).__gt((5));
  344. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}))._whileFalse();
  345. self._assert_equals_(i,(6));
  346. return self}, function($ctx1) {$ctx1.fill(self,"testWhileFalse",{i:i},smalltalk.BlockClosureTest)})},
  347. args: [],
  348. 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",
  349. messageSends: ["whileFalse:", ">", "+", "assert:equals:", "whileFalse"],
  350. referencedClasses: []
  351. }),
  352. smalltalk.BlockClosureTest);
  353. smalltalk.addMethod(
  354. smalltalk.method({
  355. selector: "testWhileTrue",
  356. category: 'tests',
  357. fn: function (){
  358. var self=this;
  359. var i;
  360. return smalltalk.withContext(function($ctx1) {
  361. i=(0);
  362. _st((function(){
  363. return smalltalk.withContext(function($ctx2) {
  364. return _st(i).__lt((5));
  365. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._whileTrue_((function(){
  366. return smalltalk.withContext(function($ctx2) {
  367. i=_st(i).__plus((1));
  368. return i;
  369. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  370. self._assert_equals_(i,(5));
  371. i=(0);
  372. _st((function(){
  373. return smalltalk.withContext(function($ctx2) {
  374. i=_st(i).__plus((1));
  375. i;
  376. return _st(i).__lt((5));
  377. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}))._whileTrue();
  378. self._assert_equals_(i,(5));
  379. return self}, function($ctx1) {$ctx1.fill(self,"testWhileTrue",{i:i},smalltalk.BlockClosureTest)})},
  380. args: [],
  381. 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",
  382. messageSends: ["whileTrue:", "<", "+", "assert:equals:", "whileTrue"],
  383. referencedClasses: []
  384. }),
  385. smalltalk.BlockClosureTest);
  386. smalltalk.addClass('BooleanTest', smalltalk.TestCase, [], 'Kernel-Tests');
  387. smalltalk.addMethod(
  388. smalltalk.method({
  389. selector: "testEquality",
  390. category: 'tests',
  391. fn: function (){
  392. var self=this;
  393. return smalltalk.withContext(function($ctx1) {
  394. self._deny_((0).__eq(false));
  395. self._deny_(false.__eq((0)));
  396. self._deny_("".__eq(false));
  397. self._deny_(false.__eq(""));
  398. self._assert_(true.__eq(true));
  399. self._deny_(false.__eq(true));
  400. self._deny_(true.__eq(false));
  401. self._assert_(false.__eq(false));
  402. self._assert_(_st(true._yourself()).__eq(true));
  403. self._assert_(_st(true._yourself()).__eq(true._yourself()));
  404. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.BooleanTest)})},
  405. args: [],
  406. 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)",
  407. messageSends: ["deny:", "=", "assert:", "yourself"],
  408. referencedClasses: []
  409. }),
  410. smalltalk.BooleanTest);
  411. smalltalk.addMethod(
  412. smalltalk.method({
  413. selector: "testIdentity",
  414. category: 'tests',
  415. fn: function (){
  416. var self=this;
  417. return smalltalk.withContext(function($ctx1) {
  418. self._deny_((0).__eq_eq(false));
  419. self._deny_(false.__eq_eq((0)));
  420. self._deny_("".__eq_eq(false));
  421. self._deny_(false.__eq_eq(""));
  422. self._assert_(true.__eq_eq(true));
  423. self._deny_(false.__eq_eq(true));
  424. self._deny_(true.__eq_eq(false));
  425. self._assert_(false.__eq_eq(false));
  426. self._assert_(_st(true._yourself()).__eq_eq(true));
  427. self._assert_(_st(true._yourself()).__eq_eq(true._yourself()));
  428. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.BooleanTest)})},
  429. args: [],
  430. 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",
  431. messageSends: ["deny:", "==", "assert:", "yourself"],
  432. referencedClasses: []
  433. }),
  434. smalltalk.BooleanTest);
  435. smalltalk.addMethod(
  436. smalltalk.method({
  437. selector: "testIfTrueIfFalse",
  438. category: 'tests',
  439. fn: function (){
  440. var self=this;
  441. return smalltalk.withContext(function($ctx1) {
  442. var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16;
  443. $1=self;
  444. if(smalltalk.assert(true)){
  445. $2="alternative block";
  446. };
  447. _st($1)._assert_equals_($2,"alternative block");
  448. $3=self;
  449. if(! smalltalk.assert(true)){
  450. $4="alternative block";
  451. };
  452. _st($3)._assert_equals_($4,nil);
  453. $5=self;
  454. if(smalltalk.assert(false)){
  455. $6="alternative block";
  456. };
  457. _st($5)._assert_equals_($6,nil);
  458. $7=self;
  459. if(! smalltalk.assert(false)){
  460. $8="alternative block";
  461. };
  462. _st($7)._assert_equals_($8,"alternative block");
  463. $9=self;
  464. if(smalltalk.assert(false)){
  465. $10="alternative block";
  466. } else {
  467. $10="alternative block2";
  468. };
  469. _st($9)._assert_equals_($10,"alternative block2");
  470. $11=self;
  471. if(smalltalk.assert(false)){
  472. $12="alternative block2";
  473. } else {
  474. $12="alternative block";
  475. };
  476. _st($11)._assert_equals_($12,"alternative block");
  477. $13=self;
  478. if(smalltalk.assert(true)){
  479. $14="alternative block";
  480. } else {
  481. $14="alternative block2";
  482. };
  483. _st($13)._assert_equals_($14,"alternative block");
  484. $15=self;
  485. if(smalltalk.assert(true)){
  486. $16="alternative block2";
  487. } else {
  488. $16="alternative block";
  489. };
  490. _st($15)._assert_equals_($16,"alternative block2");
  491. return self}, function($ctx1) {$ctx1.fill(self,"testIfTrueIfFalse",{},smalltalk.BooleanTest)})},
  492. args: [],
  493. 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'.",
  494. messageSends: ["assert:equals:", "ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  495. referencedClasses: []
  496. }),
  497. smalltalk.BooleanTest);
  498. smalltalk.addMethod(
  499. smalltalk.method({
  500. selector: "testIfTrueIfFalseWithBoxing",
  501. category: 'tests',
  502. fn: function (){
  503. var self=this;
  504. return smalltalk.withContext(function($ctx1) {
  505. 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;
  506. $1=self;
  507. $3=true._yourself();
  508. if(smalltalk.assert($3)){
  509. $2="alternative block";
  510. };
  511. _st($1)._assert_equals_($2,"alternative block");
  512. $4=self;
  513. $6=true._yourself();
  514. if(! smalltalk.assert($6)){
  515. $5="alternative block";
  516. };
  517. _st($4)._assert_equals_($5,nil);
  518. $7=self;
  519. $9=false._yourself();
  520. if(smalltalk.assert($9)){
  521. $8="alternative block";
  522. };
  523. _st($7)._assert_equals_($8,nil);
  524. $10=self;
  525. $12=false._yourself();
  526. if(! smalltalk.assert($12)){
  527. $11="alternative block";
  528. };
  529. _st($10)._assert_equals_($11,"alternative block");
  530. $13=self;
  531. $15=false._yourself();
  532. if(smalltalk.assert($15)){
  533. $14="alternative block";
  534. } else {
  535. $14="alternative block2";
  536. };
  537. _st($13)._assert_equals_($14,"alternative block2");
  538. $16=self;
  539. $18=false._yourself();
  540. if(smalltalk.assert($18)){
  541. $17="alternative block2";
  542. } else {
  543. $17="alternative block";
  544. };
  545. _st($16)._assert_equals_($17,"alternative block");
  546. $19=self;
  547. $21=true._yourself();
  548. if(smalltalk.assert($21)){
  549. $20="alternative block";
  550. } else {
  551. $20="alternative block2";
  552. };
  553. _st($19)._assert_equals_($20,"alternative block");
  554. $22=self;
  555. $24=true._yourself();
  556. if(smalltalk.assert($24)){
  557. $23="alternative block2";
  558. } else {
  559. $23="alternative block";
  560. };
  561. _st($22)._assert_equals_($23,"alternative block2");
  562. return self}, function($ctx1) {$ctx1.fill(self,"testIfTrueIfFalseWithBoxing",{},smalltalk.BooleanTest)})},
  563. args: [],
  564. 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'.",
  565. messageSends: ["assert:equals:", "ifTrue:", "yourself", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  566. referencedClasses: []
  567. }),
  568. smalltalk.BooleanTest);
  569. smalltalk.addMethod(
  570. smalltalk.method({
  571. selector: "testLogic",
  572. category: 'tests',
  573. fn: function (){
  574. var self=this;
  575. return smalltalk.withContext(function($ctx1) {
  576. var $1,$2,$3,$4,$5,$6,$7,$8;
  577. $1=self;
  578. _st($1)._assert_(true.__and(true));
  579. _st($1)._deny_(true.__and(false));
  580. _st($1)._deny_(false.__and(true));
  581. $2=_st($1)._deny_(false.__and(false));
  582. $3=self;
  583. _st($3)._assert_(true.__or(true));
  584. _st($3)._assert_(true.__or(false));
  585. _st($3)._assert_(false.__or(true));
  586. $4=_st($3)._deny_(false.__or(false));
  587. $5=self;
  588. _st($5)._assert_(true.__and((1).__gt((0))));
  589. _st($5)._deny_(_st((1).__gt((0))).__and(false));
  590. $6=_st($5)._deny_(_st((1).__gt((0))).__and((1).__gt((2))));
  591. $7=self;
  592. _st($7)._assert_(false.__or((1).__gt((0))));
  593. _st($7)._assert_(_st((1).__gt((0))).__or(false));
  594. $8=_st($7)._assert_(_st((1).__gt((0))).__or((1).__gt((2))));
  595. return self}, function($ctx1) {$ctx1.fill(self,"testLogic",{},smalltalk.BooleanTest)})},
  596. args: [],
  597. 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))",
  598. messageSends: ["assert:", "&", "deny:", "|", ">"],
  599. referencedClasses: []
  600. }),
  601. smalltalk.BooleanTest);
  602. smalltalk.addMethod(
  603. smalltalk.method({
  604. selector: "testLogicKeywords",
  605. category: 'tests',
  606. fn: function (){
  607. var self=this;
  608. return smalltalk.withContext(function($ctx1) {
  609. var $1,$2,$3,$4,$5,$6,$7,$8;
  610. $1=self;
  611. _st($1)._assert_(true._and_((function(){
  612. return smalltalk.withContext(function($ctx2) {
  613. return true;
  614. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})));
  615. _st($1)._deny_(true._and_((function(){
  616. return smalltalk.withContext(function($ctx2) {
  617. return false;
  618. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})));
  619. _st($1)._deny_(false._and_((function(){
  620. return smalltalk.withContext(function($ctx2) {
  621. return true;
  622. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})})));
  623. $2=_st($1)._deny_(false._and_((function(){
  624. return smalltalk.withContext(function($ctx2) {
  625. return false;
  626. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})})));
  627. $3=self;
  628. _st($3)._assert_(true._or_((function(){
  629. return smalltalk.withContext(function($ctx2) {
  630. return true;
  631. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})})));
  632. _st($3)._assert_(true._or_((function(){
  633. return smalltalk.withContext(function($ctx2) {
  634. return false;
  635. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})})));
  636. _st($3)._assert_(false._or_((function(){
  637. return smalltalk.withContext(function($ctx2) {
  638. return true;
  639. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,7)})})));
  640. $4=_st($3)._deny_(false._or_((function(){
  641. return smalltalk.withContext(function($ctx2) {
  642. return false;
  643. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,8)})})));
  644. $5=self;
  645. _st($5)._assert_(true._and_((function(){
  646. return smalltalk.withContext(function($ctx2) {
  647. return (1).__gt((0));
  648. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,9)})})));
  649. _st($5)._deny_(_st((1).__gt((0)))._and_((function(){
  650. return smalltalk.withContext(function($ctx2) {
  651. return false;
  652. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,10)})})));
  653. $6=_st($5)._deny_(_st((1).__gt((0)))._and_((function(){
  654. return smalltalk.withContext(function($ctx2) {
  655. return (1).__gt((2));
  656. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,11)})})));
  657. $7=self;
  658. _st($7)._assert_(false._or_((function(){
  659. return smalltalk.withContext(function($ctx2) {
  660. return (1).__gt((0));
  661. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,12)})})));
  662. _st($7)._assert_(_st((1).__gt((0)))._or_((function(){
  663. return smalltalk.withContext(function($ctx2) {
  664. return false;
  665. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,13)})})));
  666. $8=_st($7)._assert_(_st((1).__gt((0)))._or_((function(){
  667. return smalltalk.withContext(function($ctx2) {
  668. return (1).__gt((2));
  669. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,14)})})));
  670. return self}, function($ctx1) {$ctx1.fill(self,"testLogicKeywords",{},smalltalk.BooleanTest)})},
  671. args: [],
  672. 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 ])",
  673. messageSends: ["assert:", "and:", "deny:", "or:", ">"],
  674. referencedClasses: []
  675. }),
  676. smalltalk.BooleanTest);
  677. smalltalk.addMethod(
  678. smalltalk.method({
  679. selector: "testNonBooleanError",
  680. category: 'tests',
  681. fn: function (){
  682. var self=this;
  683. function $NonBooleanReceiver(){return smalltalk.NonBooleanReceiver||(typeof NonBooleanReceiver=="undefined"?nil:NonBooleanReceiver)}
  684. return smalltalk.withContext(function($ctx1) {
  685. self._should_raise_((function(){
  686. return smalltalk.withContext(function($ctx2) {
  687. if(smalltalk.assert("")){
  688. } else {
  689. };
  690. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$NonBooleanReceiver());
  691. return self}, function($ctx1) {$ctx1.fill(self,"testNonBooleanError",{},smalltalk.BooleanTest)})},
  692. args: [],
  693. source: "testNonBooleanError\x0a\x09self should: [ '' ifTrue: [] ifFalse: [] ] raise: NonBooleanReceiver",
  694. messageSends: ["should:raise:", "ifTrue:ifFalse:"],
  695. referencedClasses: ["NonBooleanReceiver"]
  696. }),
  697. smalltalk.BooleanTest);
  698. smalltalk.addClass('ClassBuilderTest', smalltalk.TestCase, ['builder', 'theClass'], 'Kernel-Tests');
  699. smalltalk.addMethod(
  700. smalltalk.method({
  701. selector: "setUp",
  702. category: 'running',
  703. fn: function (){
  704. var self=this;
  705. function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
  706. return smalltalk.withContext(function($ctx1) {
  707. self["@builder"]=_st($ClassBuilder())._new();
  708. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.ClassBuilderTest)})},
  709. args: [],
  710. source: "setUp\x0a\x09builder := ClassBuilder new",
  711. messageSends: ["new"],
  712. referencedClasses: ["ClassBuilder"]
  713. }),
  714. smalltalk.ClassBuilderTest);
  715. smalltalk.addMethod(
  716. smalltalk.method({
  717. selector: "tearDown",
  718. category: 'running',
  719. fn: function (){
  720. var self=this;
  721. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  722. return smalltalk.withContext(function($ctx1) {
  723. var $1;
  724. $1=self["@theClass"];
  725. if(($receiver = $1) == nil || $receiver == null){
  726. $1;
  727. } else {
  728. _st(_st($Smalltalk())._current())._removeClass_(self["@theClass"]);
  729. self["@theClass"]=nil;
  730. self["@theClass"];
  731. };
  732. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.ClassBuilderTest)})},
  733. args: [],
  734. source: "tearDown\x0a\x09theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]",
  735. messageSends: ["ifNotNil:", "removeClass:", "current"],
  736. referencedClasses: ["Smalltalk"]
  737. }),
  738. smalltalk.ClassBuilderTest);
  739. smalltalk.addMethod(
  740. smalltalk.method({
  741. selector: "testClassCopy",
  742. category: 'tests',
  743. fn: function (){
  744. var self=this;
  745. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  746. return smalltalk.withContext(function($ctx1) {
  747. self["@theClass"]=_st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  748. self._assert_(_st(_st(self["@theClass"])._superclass()).__eq_eq(_st($ObjectMock())._superclass()));
  749. self._assert_(_st(_st(self["@theClass"])._instanceVariableNames()).__eq_eq(_st($ObjectMock())._instanceVariableNames()));
  750. self._assert_equals_(_st(self["@theClass"])._name(),"ObjectMock2");
  751. self._assert_(_st(_st(self["@theClass"])._package()).__eq_eq(_st($ObjectMock())._package()));
  752. self._assert_equals_(_st(_st(self["@theClass"])._methodDictionary())._keys(),_st(_st($ObjectMock())._methodDictionary())._keys());
  753. return self}, function($ctx1) {$ctx1.fill(self,"testClassCopy",{},smalltalk.ClassBuilderTest)})},
  754. args: [],
  755. 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",
  756. messageSends: ["copyClass:named:", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary"],
  757. referencedClasses: ["ObjectMock"]
  758. }),
  759. smalltalk.ClassBuilderTest);
  760. smalltalk.addMethod(
  761. smalltalk.method({
  762. selector: "testClassMigration",
  763. category: 'tests',
  764. fn: function (){
  765. var self=this;
  766. var instance,oldClass;
  767. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  768. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  769. function $ObjectMock2(){return smalltalk.ObjectMock2||(typeof ObjectMock2=="undefined"?nil:ObjectMock2)}
  770. return smalltalk.withContext(function($ctx1) {
  771. oldClass=_st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  772. instance=_st(_st(_st($Smalltalk())._current())._at_("ObjectMock2"))._new();
  773. _st($ObjectMock())._subclass_instanceVariableNames_package_(_st(_st($Smalltalk())._current())._at_("ObjectMock2"),"","Kernel-Tests");
  774. self._deny_(_st(oldClass).__eq_eq($ObjectMock2()));
  775. self._assert_(_st(_st($ObjectMock2())._superclass()).__eq_eq($ObjectMock()));
  776. self._assert_(_st(_st($ObjectMock2())._instanceVariableNames())._isEmpty());
  777. self._assert_equals_(_st($ObjectMock2())._selectors(),_st(oldClass)._selectors());
  778. self._assert_equals_(_st($ObjectMock2())._comment(),_st(oldClass)._comment());
  779. self._assert_equals_(_st(_st($ObjectMock2())._package())._name(),"Kernel-Tests");
  780. self._deny_(_st(_st(instance)._class()).__eq_eq($ObjectMock2()));
  781. self._assert_(_st(_st(_st($Smalltalk())._current())._at_(_st(_st(instance)._class())._name()))._isNil());
  782. _st(_st($Smalltalk())._current())._removeClass_($ObjectMock2());
  783. return self}, function($ctx1) {$ctx1.fill(self,"testClassMigration",{instance:instance,oldClass:oldClass},smalltalk.ClassBuilderTest)})},
  784. args: [],
  785. 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",
  786. messageSends: ["copyClass:named:", "new", "at:", "current", "subclass:instanceVariableNames:package:", "deny:", "==", "assert:", "superclass", "isEmpty", "instanceVariableNames", "assert:equals:", "selectors", "comment", "name", "package", "class", "isNil", "removeClass:"],
  787. referencedClasses: ["ObjectMock", "Smalltalk", "ObjectMock2"]
  788. }),
  789. smalltalk.ClassBuilderTest);
  790. smalltalk.addMethod(
  791. smalltalk.method({
  792. selector: "testClassMigrationWithClassInstanceVariables",
  793. category: 'tests',
  794. fn: function (){
  795. var self=this;
  796. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  797. function $ObjectMock2(){return smalltalk.ObjectMock2||(typeof ObjectMock2=="undefined"?nil:ObjectMock2)}
  798. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  799. return smalltalk.withContext(function($ctx1) {
  800. _st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  801. _st(_st($ObjectMock2())._class())._instanceVariableNames_("foo bar");
  802. _st($ObjectMock())._subclass_instanceVariableNames_package_(_st(_st($Smalltalk())._current())._at_("ObjectMock2"),"","Kernel-Tests");
  803. self._assert_equals_(_st(_st($ObjectMock2())._class())._instanceVariableNames(),["foo", "bar"]);
  804. _st(_st($Smalltalk())._current())._removeClass_($ObjectMock2());
  805. return self}, function($ctx1) {$ctx1.fill(self,"testClassMigrationWithClassInstanceVariables",{},smalltalk.ClassBuilderTest)})},
  806. args: [],
  807. 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",
  808. messageSends: ["copyClass:named:", "instanceVariableNames:", "class", "subclass:instanceVariableNames:package:", "at:", "current", "assert:equals:", "instanceVariableNames", "removeClass:"],
  809. referencedClasses: ["ObjectMock", "ObjectMock2", "Smalltalk"]
  810. }),
  811. smalltalk.ClassBuilderTest);
  812. smalltalk.addMethod(
  813. smalltalk.method({
  814. selector: "testClassMigrationWithSubclasses",
  815. category: 'tests',
  816. fn: function (){
  817. var self=this;
  818. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  819. function $ObjectMock2(){return smalltalk.ObjectMock2||(typeof ObjectMock2=="undefined"?nil:ObjectMock2)}
  820. function $ObjectMock3(){return smalltalk.ObjectMock3||(typeof ObjectMock3=="undefined"?nil:ObjectMock3)}
  821. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  822. function $ObjectMock4(){return smalltalk.ObjectMock4||(typeof ObjectMock4=="undefined"?nil:ObjectMock4)}
  823. return smalltalk.withContext(function($ctx1) {
  824. _st(self["@builder"])._copyClass_named_($ObjectMock(),"ObjectMock2");
  825. _st($ObjectMock2())._subclass_instanceVariableNames_package_("ObjectMock3","","Kernel-Tests");
  826. _st($ObjectMock3())._subclass_instanceVariableNames_package_("ObjectMock4","","Kernel-Tests");
  827. _st($ObjectMock())._subclass_instanceVariableNames_package_(_st(_st($Smalltalk())._current())._at_("ObjectMock2"),"","Kernel-Tests");
  828. self._assert_(_st(_st($ObjectMock())._subclasses())._includes_($ObjectMock2()));
  829. self._assert_(_st(_st($ObjectMock2())._subclasses())._includes_($ObjectMock3()));
  830. self._assert_(_st(_st($ObjectMock3())._subclasses())._includes_($ObjectMock4()));
  831. _st(_st($ObjectMock())._allSubclasses())._do_((function(each){
  832. return smalltalk.withContext(function($ctx2) {
  833. return _st(_st($Smalltalk())._current())._removeClass_(each);
  834. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  835. return self}, function($ctx1) {$ctx1.fill(self,"testClassMigrationWithSubclasses",{},smalltalk.ClassBuilderTest)})},
  836. args: [],
  837. 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 ]",
  838. messageSends: ["copyClass:named:", "subclass:instanceVariableNames:package:", "at:", "current", "assert:", "includes:", "subclasses", "do:", "allSubclasses", "removeClass:"],
  839. referencedClasses: ["ObjectMock", "ObjectMock2", "ObjectMock3", "Smalltalk", "ObjectMock4"]
  840. }),
  841. smalltalk.ClassBuilderTest);
  842. smalltalk.addMethod(
  843. smalltalk.method({
  844. selector: "testInstanceVariableNames",
  845. category: 'tests',
  846. fn: function (){
  847. var self=this;
  848. return smalltalk.withContext(function($ctx1) {
  849. self._assert_equals_(_st(self["@builder"])._instanceVariableNamesFor_(" hello world "),["hello", "world"]);
  850. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVariableNames",{},smalltalk.ClassBuilderTest)})},
  851. args: [],
  852. source: "testInstanceVariableNames\x0a\x09self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')",
  853. messageSends: ["assert:equals:", "instanceVariableNamesFor:"],
  854. referencedClasses: []
  855. }),
  856. smalltalk.ClassBuilderTest);
  857. smalltalk.addClass('CollectionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  858. smalltalk.addMethod(
  859. smalltalk.method({
  860. selector: "assertSameContents:as:",
  861. category: 'convenience',
  862. fn: function (aCollection,anotherCollection){
  863. var self=this;
  864. return smalltalk.withContext(function($ctx1) {
  865. self._assert_(_st(_st(aCollection)._size()).__eq(_st(anotherCollection)._size()));
  866. _st(aCollection)._do_((function(each){
  867. return smalltalk.withContext(function($ctx2) {
  868. return self._assert_(_st(_st(aCollection)._occurrencesOf_(each)).__eq(_st(anotherCollection)._occurrencesOf_(each)));
  869. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  870. return self}, function($ctx1) {$ctx1.fill(self,"assertSameContents:as:",{aCollection:aCollection,anotherCollection:anotherCollection},smalltalk.CollectionTest)})},
  871. args: ["aCollection", "anotherCollection"],
  872. 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)) ]",
  873. messageSends: ["assert:", "=", "size", "do:", "occurrencesOf:"],
  874. referencedClasses: []
  875. }),
  876. smalltalk.CollectionTest);
  877. smalltalk.addMethod(
  878. smalltalk.method({
  879. selector: "collection",
  880. category: 'accessing',
  881. fn: function (){
  882. var self=this;
  883. return smalltalk.withContext(function($ctx1) {
  884. var $1;
  885. $1=_st(self._collectionClass())._withAll_(self._defaultValues());
  886. return $1;
  887. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.CollectionTest)})},
  888. args: [],
  889. source: "collection\x0a\x09^ self collectionClass withAll: self defaultValues",
  890. messageSends: ["withAll:", "collectionClass", "defaultValues"],
  891. referencedClasses: []
  892. }),
  893. smalltalk.CollectionTest);
  894. smalltalk.addMethod(
  895. smalltalk.method({
  896. selector: "collectionClass",
  897. category: 'accessing',
  898. fn: function (){
  899. var self=this;
  900. return smalltalk.withContext(function($ctx1) {
  901. var $1;
  902. $1=_st(self._class())._collectionClass();
  903. return $1;
  904. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.CollectionTest)})},
  905. args: [],
  906. source: "collectionClass\x0a\x09^ self class collectionClass",
  907. messageSends: ["collectionClass", "class"],
  908. referencedClasses: []
  909. }),
  910. smalltalk.CollectionTest);
  911. smalltalk.addMethod(
  912. smalltalk.method({
  913. selector: "collectionWithDuplicates",
  914. category: 'accessing',
  915. fn: function (){
  916. var self=this;
  917. return smalltalk.withContext(function($ctx1) {
  918. var $1;
  919. $1=_st(self._collectionClass())._withAll_(["a", "b", "c", (1), (2), (1), "a"]);
  920. return $1;
  921. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.CollectionTest)})},
  922. args: [],
  923. source: "collectionWithDuplicates\x0a\x09^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')",
  924. messageSends: ["withAll:", "collectionClass"],
  925. referencedClasses: []
  926. }),
  927. smalltalk.CollectionTest);
  928. smalltalk.addMethod(
  929. smalltalk.method({
  930. selector: "defaultValues",
  931. category: 'accessing',
  932. fn: function (){
  933. var self=this;
  934. return smalltalk.withContext(function($ctx1) {
  935. var $1;
  936. $1=[(1), (2), (3), (-4)];
  937. return $1;
  938. }, function($ctx1) {$ctx1.fill(self,"defaultValues",{},smalltalk.CollectionTest)})},
  939. args: [],
  940. source: "defaultValues\x0a\x09^ #(1 2 3 -4)",
  941. messageSends: [],
  942. referencedClasses: []
  943. }),
  944. smalltalk.CollectionTest);
  945. smalltalk.addMethod(
  946. smalltalk.method({
  947. selector: "isCollectionReadOnly",
  948. category: 'testing',
  949. fn: function (){
  950. var self=this;
  951. return smalltalk.withContext(function($ctx1) {
  952. return false;
  953. }, function($ctx1) {$ctx1.fill(self,"isCollectionReadOnly",{},smalltalk.CollectionTest)})},
  954. args: [],
  955. source: "isCollectionReadOnly\x0a\x09^ false",
  956. messageSends: [],
  957. referencedClasses: []
  958. }),
  959. smalltalk.CollectionTest);
  960. smalltalk.addMethod(
  961. smalltalk.method({
  962. selector: "testAsArray",
  963. category: 'tests',
  964. fn: function (){
  965. var self=this;
  966. return smalltalk.withContext(function($ctx1) {
  967. self._assertSameContents_as_(self._collection(),_st(self._collection())._asArray());
  968. return self}, function($ctx1) {$ctx1.fill(self,"testAsArray",{},smalltalk.CollectionTest)})},
  969. args: [],
  970. source: "testAsArray\x0a\x09self\x0a\x09\x09assertSameContents: self collection\x0a\x09\x09as: self collection asArray",
  971. messageSends: ["assertSameContents:as:", "collection", "asArray"],
  972. referencedClasses: []
  973. }),
  974. smalltalk.CollectionTest);
  975. smalltalk.addMethod(
  976. smalltalk.method({
  977. selector: "testAsOrderedCollection",
  978. category: 'tests',
  979. fn: function (){
  980. var self=this;
  981. return smalltalk.withContext(function($ctx1) {
  982. self._assertSameContents_as_(self._collection(),_st(self._collection())._asOrderedCollection());
  983. return self}, function($ctx1) {$ctx1.fill(self,"testAsOrderedCollection",{},smalltalk.CollectionTest)})},
  984. args: [],
  985. source: "testAsOrderedCollection\x0a\x09self\x0a\x09\x09assertSameContents: self collection\x0a\x09\x09as: self collection asOrderedCollection",
  986. messageSends: ["assertSameContents:as:", "collection", "asOrderedCollection"],
  987. referencedClasses: []
  988. }),
  989. smalltalk.CollectionTest);
  990. smalltalk.addMethod(
  991. smalltalk.method({
  992. selector: "testAsSet",
  993. category: 'tests',
  994. fn: function (){
  995. var self=this;
  996. var c,set;
  997. return smalltalk.withContext(function($ctx1) {
  998. c=self._collectionWithDuplicates();
  999. set=_st(c)._asSet();
  1000. self._assert_equals_(_st(set)._size(),(5));
  1001. _st(c)._do_((function(each){
  1002. return smalltalk.withContext(function($ctx2) {
  1003. return self._assert_(_st(set)._includes_(each));
  1004. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1005. return self}, function($ctx1) {$ctx1.fill(self,"testAsSet",{c:c,set:set},smalltalk.CollectionTest)})},
  1006. args: [],
  1007. 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) ]",
  1008. messageSends: ["collectionWithDuplicates", "asSet", "assert:equals:", "size", "do:", "assert:", "includes:"],
  1009. referencedClasses: []
  1010. }),
  1011. smalltalk.CollectionTest);
  1012. smalltalk.addMethod(
  1013. smalltalk.method({
  1014. selector: "testAssociation",
  1015. category: 'tests',
  1016. fn: function (){
  1017. var self=this;
  1018. return smalltalk.withContext(function($ctx1) {
  1019. self._assert_equals_("key:value:","key:value:");
  1020. self._deny_("key:value:".__eq("value:key:"));
  1021. return self}, function($ctx1) {$ctx1.fill(self,"testAssociation",{},smalltalk.CollectionTest)})},
  1022. args: [],
  1023. source: "testAssociation\x0a self assert: #key:value: equals: 'key:value:'.\x0a self deny: #key:value: = 'value:key:'",
  1024. messageSends: ["assert:equals:", "deny:", "="],
  1025. referencedClasses: []
  1026. }),
  1027. smalltalk.CollectionTest);
  1028. smalltalk.addMethod(
  1029. smalltalk.method({
  1030. selector: "testCollect",
  1031. category: 'tests',
  1032. fn: function (){
  1033. var self=this;
  1034. var newCollection;
  1035. return smalltalk.withContext(function($ctx1) {
  1036. newCollection=[(1), (2), (3), (4)];
  1037. self._assertSameContents_as_(_st(self._collection())._collect_((function(each){
  1038. return smalltalk.withContext(function($ctx2) {
  1039. return _st(each)._abs();
  1040. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),newCollection);
  1041. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{newCollection:newCollection},smalltalk.CollectionTest)})},
  1042. args: [],
  1043. 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",
  1044. messageSends: ["assertSameContents:as:", "collect:", "collection", "abs"],
  1045. referencedClasses: []
  1046. }),
  1047. smalltalk.CollectionTest);
  1048. smalltalk.addMethod(
  1049. smalltalk.method({
  1050. selector: "testDetect",
  1051. category: 'tests',
  1052. fn: function (){
  1053. var self=this;
  1054. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1055. return smalltalk.withContext(function($ctx1) {
  1056. self._assert_equals_(_st(self._collection())._detect_((function(each){
  1057. return smalltalk.withContext(function($ctx2) {
  1058. return _st(each).__lt((0));
  1059. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),(-4));
  1060. self._should_raise_((function(){
  1061. return smalltalk.withContext(function($ctx2) {
  1062. return _st(self._collection())._detect_((function(each){
  1063. return smalltalk.withContext(function($ctx3) {
  1064. return _st(each).__eq((6));
  1065. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,3)})}));
  1066. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$Error());
  1067. return self}, function($ctx1) {$ctx1.fill(self,"testDetect",{},smalltalk.CollectionTest)})},
  1068. args: [],
  1069. 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",
  1070. messageSends: ["assert:equals:", "detect:", "collection", "<", "should:raise:", "="],
  1071. referencedClasses: ["Error"]
  1072. }),
  1073. smalltalk.CollectionTest);
  1074. smalltalk.addMethod(
  1075. smalltalk.method({
  1076. selector: "testDo",
  1077. category: 'tests',
  1078. fn: function (){
  1079. var self=this;
  1080. var newCollection;
  1081. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  1082. return smalltalk.withContext(function($ctx1) {
  1083. newCollection=_st($OrderedCollection())._new();
  1084. _st(self._collection())._do_((function(each){
  1085. return smalltalk.withContext(function($ctx2) {
  1086. return _st(newCollection)._add_(each);
  1087. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1088. self._assertSameContents_as_(self._collection(),newCollection);
  1089. return self}, function($ctx1) {$ctx1.fill(self,"testDo",{newCollection:newCollection},smalltalk.CollectionTest)})},
  1090. args: [],
  1091. 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",
  1092. messageSends: ["new", "do:", "collection", "add:", "assertSameContents:as:"],
  1093. referencedClasses: ["OrderedCollection"]
  1094. }),
  1095. smalltalk.CollectionTest);
  1096. smalltalk.addMethod(
  1097. smalltalk.method({
  1098. selector: "testIsEmpty",
  1099. category: 'tests',
  1100. fn: function (){
  1101. var self=this;
  1102. return smalltalk.withContext(function($ctx1) {
  1103. self._assert_(_st(_st(self._collectionClass())._new())._isEmpty());
  1104. self._deny_(_st(self._collection())._isEmpty());
  1105. return self}, function($ctx1) {$ctx1.fill(self,"testIsEmpty",{},smalltalk.CollectionTest)})},
  1106. args: [],
  1107. source: "testIsEmpty\x0a\x09self assert: self collectionClass new isEmpty.\x0a\x09self deny: self collection isEmpty",
  1108. messageSends: ["assert:", "isEmpty", "new", "collectionClass", "deny:", "collection"],
  1109. referencedClasses: []
  1110. }),
  1111. smalltalk.CollectionTest);
  1112. smalltalk.addMethod(
  1113. smalltalk.method({
  1114. selector: "testSelect",
  1115. category: 'tests',
  1116. fn: function (){
  1117. var self=this;
  1118. var newCollection;
  1119. return smalltalk.withContext(function($ctx1) {
  1120. newCollection=[(2), (-4)];
  1121. self._assertSameContents_as_(_st(self._collection())._select_((function(each){
  1122. return smalltalk.withContext(function($ctx2) {
  1123. return _st(each)._even();
  1124. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),newCollection);
  1125. return self}, function($ctx1) {$ctx1.fill(self,"testSelect",{newCollection:newCollection},smalltalk.CollectionTest)})},
  1126. args: [],
  1127. 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",
  1128. messageSends: ["assertSameContents:as:", "select:", "collection", "even"],
  1129. referencedClasses: []
  1130. }),
  1131. smalltalk.CollectionTest);
  1132. smalltalk.addMethod(
  1133. smalltalk.method({
  1134. selector: "testSize",
  1135. category: 'tests',
  1136. fn: function (){
  1137. var self=this;
  1138. return smalltalk.withContext(function($ctx1) {
  1139. self._assert_equals_(_st(_st(self._collectionClass())._new())._size(),(0));
  1140. self._assert_equals_(_st(self._collection())._size(),(4));
  1141. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.CollectionTest)})},
  1142. args: [],
  1143. source: "testSize\x0a\x09self assert: self collectionClass new size equals: 0.\x0a\x09self assert: self collection size equals: 4",
  1144. messageSends: ["assert:equals:", "size", "new", "collectionClass", "collection"],
  1145. referencedClasses: []
  1146. }),
  1147. smalltalk.CollectionTest);
  1148. smalltalk.addMethod(
  1149. smalltalk.method({
  1150. selector: "collectionClass",
  1151. category: 'accessing',
  1152. fn: function (){
  1153. var self=this;
  1154. return smalltalk.withContext(function($ctx1) {
  1155. return nil;
  1156. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.CollectionTest.klass)})},
  1157. args: [],
  1158. source: "collectionClass\x0a\x09^ nil",
  1159. messageSends: [],
  1160. referencedClasses: []
  1161. }),
  1162. smalltalk.CollectionTest.klass);
  1163. smalltalk.addMethod(
  1164. smalltalk.method({
  1165. selector: "isAbstract",
  1166. category: 'testing',
  1167. fn: function (){
  1168. var self=this;
  1169. return smalltalk.withContext(function($ctx1) {
  1170. var $1;
  1171. $1=_st(self._collectionClass())._isNil();
  1172. return $1;
  1173. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.CollectionTest.klass)})},
  1174. args: [],
  1175. source: "isAbstract\x0a\x09^ self collectionClass isNil",
  1176. messageSends: ["isNil", "collectionClass"],
  1177. referencedClasses: []
  1178. }),
  1179. smalltalk.CollectionTest.klass);
  1180. smalltalk.addClass('IndexableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
  1181. smalltalk.addMethod(
  1182. smalltalk.method({
  1183. selector: "testAt",
  1184. category: 'tests',
  1185. fn: function (){
  1186. var self=this;
  1187. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1188. return smalltalk.withContext(function($ctx1) {
  1189. self._assert_equals_(_st(self._collection())._at_((4)),(-4));
  1190. self._should_raise_((function(){
  1191. return smalltalk.withContext(function($ctx2) {
  1192. return _st(self._collection())._at_((5));
  1193. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  1194. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.IndexableCollectionTest)})},
  1195. args: [],
  1196. source: "testAt\x0a\x09self assert: (self collection at: 4) equals: -4.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
  1197. messageSends: ["assert:equals:", "at:", "collection", "should:raise:"],
  1198. referencedClasses: ["Error"]
  1199. }),
  1200. smalltalk.IndexableCollectionTest);
  1201. smalltalk.addMethod(
  1202. smalltalk.method({
  1203. selector: "testAtIfAbsent",
  1204. category: 'tests',
  1205. fn: function (){
  1206. var self=this;
  1207. return smalltalk.withContext(function($ctx1) {
  1208. self._assert_equals_(_st(self._collection())._at_ifAbsent_(_st(_st(self._collection())._size()).__plus((1)),(function(){
  1209. return smalltalk.withContext(function($ctx2) {
  1210. return "none";
  1211. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"none");
  1212. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{},smalltalk.IndexableCollectionTest)})},
  1213. args: [],
  1214. source: "testAtIfAbsent\x0a\x09self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) equals: 'none'",
  1215. messageSends: ["assert:equals:", "at:ifAbsent:", "collection", "+", "size"],
  1216. referencedClasses: []
  1217. }),
  1218. smalltalk.IndexableCollectionTest);
  1219. smalltalk.addMethod(
  1220. smalltalk.method({
  1221. selector: "testContains",
  1222. category: 'tests',
  1223. fn: function (){
  1224. var self=this;
  1225. var collection;
  1226. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1227. return smalltalk.withContext(function($ctx1) {
  1228. collection=self._collection();
  1229. self._assert_(_st(self._collection())._contains_((function(each){
  1230. return smalltalk.withContext(function($ctx2) {
  1231. return _st(each).__eq(_st(self._collection())._first());
  1232. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})));
  1233. self._deny_(_st(self._collection())._contains_((function(each){
  1234. return smalltalk.withContext(function($ctx2) {
  1235. return _st(each).__eq(_st($Object())._new());
  1236. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})})));
  1237. return self}, function($ctx1) {$ctx1.fill(self,"testContains",{collection:collection},smalltalk.IndexableCollectionTest)})},
  1238. args: [],
  1239. source: "testContains\x0a\x09| collection |\x0a\x09collection := self collection.\x0a\x09\x0a\x09self assert: (self collection contains: [ :each | each = self collection first ]).\x0a\x09self deny: (self collection contains: [ :each | each = Object new ])",
  1240. messageSends: ["collection", "assert:", "contains:", "=", "first", "deny:", "new"],
  1241. referencedClasses: ["Object"]
  1242. }),
  1243. smalltalk.IndexableCollectionTest);
  1244. smalltalk.addMethod(
  1245. smalltalk.method({
  1246. selector: "testIndexOf",
  1247. category: 'tests',
  1248. fn: function (){
  1249. var self=this;
  1250. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1251. return smalltalk.withContext(function($ctx1) {
  1252. self._assert_equals_(_st(self._collection())._indexOf_((2)),(2));
  1253. self._should_raise_((function(){
  1254. return smalltalk.withContext(function($ctx2) {
  1255. return _st(self._collection())._indexOf_((999));
  1256. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  1257. self._assert_equals_(_st(self._collection())._indexOf_ifAbsent_((999),(function(){
  1258. return smalltalk.withContext(function($ctx2) {
  1259. return "sentinel";
  1260. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"sentinel");
  1261. return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.IndexableCollectionTest)})},
  1262. args: [],
  1263. 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'",
  1264. messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
  1265. referencedClasses: ["Error"]
  1266. }),
  1267. smalltalk.IndexableCollectionTest);
  1268. smalltalk.addMethod(
  1269. smalltalk.method({
  1270. selector: "testWithIndexDo",
  1271. category: 'tests',
  1272. fn: function (){
  1273. var self=this;
  1274. var collection;
  1275. return smalltalk.withContext(function($ctx1) {
  1276. collection=self._collection();
  1277. _st(self._collection())._withIndexDo_((function(each,index){
  1278. return smalltalk.withContext(function($ctx2) {
  1279. return self._assert_equals_(_st(collection)._at_(index),each);
  1280. }, function($ctx2) {$ctx2.fillBlock({each:each,index:index},$ctx1,1)})}));
  1281. return self}, function($ctx1) {$ctx1.fill(self,"testWithIndexDo",{collection:collection},smalltalk.IndexableCollectionTest)})},
  1282. args: [],
  1283. 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 ]",
  1284. messageSends: ["collection", "withIndexDo:", "assert:equals:", "at:"],
  1285. referencedClasses: []
  1286. }),
  1287. smalltalk.IndexableCollectionTest);
  1288. smalltalk.addClass('HashedCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
  1289. smalltalk.addMethod(
  1290. smalltalk.method({
  1291. selector: "collection",
  1292. category: 'accessing',
  1293. fn: function (){
  1294. var self=this;
  1295. return smalltalk.withContext(function($ctx1) {
  1296. var $1;
  1297. $1=smalltalk.HashedCollection._from_(["b".__minus_gt((1)),"a".__minus_gt((2)),"c".__minus_gt((3)),"d".__minus_gt((-4))]);
  1298. return $1;
  1299. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.HashedCollectionTest)})},
  1300. args: [],
  1301. source: "collection\x0a\x09^ #{ 'b' -> 1. 'a' -> 2. 'c' -> 3. 'd' -> -4 }",
  1302. messageSends: ["->"],
  1303. referencedClasses: []
  1304. }),
  1305. smalltalk.HashedCollectionTest);
  1306. smalltalk.addMethod(
  1307. smalltalk.method({
  1308. selector: "collectionWithDuplicates",
  1309. category: 'accessing',
  1310. fn: function (){
  1311. var self=this;
  1312. return smalltalk.withContext(function($ctx1) {
  1313. var $1;
  1314. $1=smalltalk.HashedCollection._from_(["b".__minus_gt((1)),"a".__minus_gt((2)),"c".__minus_gt((3)),"d".__minus_gt((-4)),"e".__minus_gt((1)),"f".__minus_gt((2)),"g".__minus_gt((10))]);
  1315. return $1;
  1316. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.HashedCollectionTest)})},
  1317. args: [],
  1318. source: "collectionWithDuplicates\x0a\x09^ #{ 'b' -> 1. 'a' -> 2. 'c' -> 3. 'd' -> -4. 'e' -> 1. 'f' -> 2. 'g' -> 10 }",
  1319. messageSends: ["->"],
  1320. referencedClasses: []
  1321. }),
  1322. smalltalk.HashedCollectionTest);
  1323. smalltalk.addMethod(
  1324. smalltalk.method({
  1325. selector: "testAsDictionary",
  1326. category: 'tests',
  1327. fn: function (){
  1328. var self=this;
  1329. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1330. return smalltalk.withContext(function($ctx1) {
  1331. self._assert_(_st(_st(_st(self._collectionClass())._new())._asDictionary())._isMemberOf_($Dictionary()));
  1332. return self}, function($ctx1) {$ctx1.fill(self,"testAsDictionary",{},smalltalk.HashedCollectionTest)})},
  1333. args: [],
  1334. source: "testAsDictionary\x0aself assert: ( self collectionClass new asDictionary isMemberOf: Dictionary ).",
  1335. messageSends: ["assert:", "isMemberOf:", "asDictionary", "new", "collectionClass"],
  1336. referencedClasses: ["Dictionary"]
  1337. }),
  1338. smalltalk.HashedCollectionTest);
  1339. smalltalk.addMethod(
  1340. smalltalk.method({
  1341. selector: "testAt",
  1342. category: 'tests',
  1343. fn: function (){
  1344. var self=this;
  1345. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1346. return smalltalk.withContext(function($ctx1) {
  1347. self._assert_equals_(_st(self._collection())._at_("a"),(2));
  1348. self._should_raise_((function(){
  1349. return smalltalk.withContext(function($ctx2) {
  1350. return _st(self._collection())._at_((5));
  1351. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  1352. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.HashedCollectionTest)})},
  1353. args: [],
  1354. source: "testAt\x0a\x09self assert: (self collection at: 'a') equals: 2.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
  1355. messageSends: ["assert:equals:", "at:", "collection", "should:raise:"],
  1356. referencedClasses: ["Error"]
  1357. }),
  1358. smalltalk.HashedCollectionTest);
  1359. smalltalk.addMethod(
  1360. smalltalk.method({
  1361. selector: "testContains",
  1362. category: 'tests',
  1363. fn: function (){
  1364. var self=this;
  1365. var collection;
  1366. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1367. return smalltalk.withContext(function($ctx1) {
  1368. collection=self._collection();
  1369. self._assert_(_st(self._collection())._contains_((function(each){
  1370. return smalltalk.withContext(function($ctx2) {
  1371. return _st(each).__eq(_st(_st(self._collection())._values())._first());
  1372. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})));
  1373. self._deny_(_st(self._collection())._contains_((function(each){
  1374. return smalltalk.withContext(function($ctx2) {
  1375. return _st(each).__eq(_st($Object())._new());
  1376. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})})));
  1377. return self}, function($ctx1) {$ctx1.fill(self,"testContains",{collection:collection},smalltalk.HashedCollectionTest)})},
  1378. args: [],
  1379. source: "testContains\x0a\x09| collection |\x0a\x09collection := self collection.\x0a\x09\x0a\x09self assert: (self collection contains: [ :each | each = self collection values first ]).\x0a\x09self deny: (self collection contains: [ :each | each = Object new ])",
  1380. messageSends: ["collection", "assert:", "contains:", "=", "first", "values", "deny:", "new"],
  1381. referencedClasses: ["Object"]
  1382. }),
  1383. smalltalk.HashedCollectionTest);
  1384. smalltalk.addMethod(
  1385. smalltalk.method({
  1386. selector: "testFrom",
  1387. category: 'tests',
  1388. fn: function (){
  1389. var self=this;
  1390. var associations;
  1391. return smalltalk.withContext(function($ctx1) {
  1392. associations=["a".__minus_gt((1)),"b".__minus_gt((2))];
  1393. self._assertSameContents_as_(_st(_st(self._class())._collectionClass())._from_(associations),smalltalk.HashedCollection._from_(["a".__minus_gt((1)),"b".__minus_gt((2))]));
  1394. return self}, function($ctx1) {$ctx1.fill(self,"testFrom",{associations:associations},smalltalk.HashedCollectionTest)})},
  1395. args: [],
  1396. source: "testFrom\x0a\x22Accept a collection of associations.\x22\x0a| associations |\x0aassociations := { 'a' -> 1. 'b' -> 2 }.\x0aself assertSameContents: ( self class collectionClass from: associations ) as: #{ 'a' -> 1. 'b' -> 2 }.",
  1397. messageSends: ["->", "assertSameContents:as:", "from:", "collectionClass", "class"],
  1398. referencedClasses: []
  1399. }),
  1400. smalltalk.HashedCollectionTest);
  1401. smalltalk.addMethod(
  1402. smalltalk.method({
  1403. selector: "testIndexOf",
  1404. category: 'tests',
  1405. fn: function (){
  1406. var self=this;
  1407. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  1408. return smalltalk.withContext(function($ctx1) {
  1409. self._assert_equals_(_st(self._collection())._indexOf_((2)),"a");
  1410. self._should_raise_((function(){
  1411. return smalltalk.withContext(function($ctx2) {
  1412. return _st(self._collection())._indexOf_((999));
  1413. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  1414. self._assert_equals_(_st(self._collection())._indexOf_ifAbsent_((999),(function(){
  1415. return smalltalk.withContext(function($ctx2) {
  1416. return "sentinel";
  1417. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"sentinel");
  1418. return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.HashedCollectionTest)})},
  1419. args: [],
  1420. 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'",
  1421. messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
  1422. referencedClasses: ["Error"]
  1423. }),
  1424. smalltalk.HashedCollectionTest);
  1425. smalltalk.addMethod(
  1426. smalltalk.method({
  1427. selector: "testNewFromPairs",
  1428. category: 'tests',
  1429. fn: function (){
  1430. var self=this;
  1431. var flattenedAssociations;
  1432. return smalltalk.withContext(function($ctx1) {
  1433. flattenedAssociations=["a",(1),"b",(2)];
  1434. self._assertSameContents_as_(_st(_st(self._class())._collectionClass())._newFromPairs_(flattenedAssociations),smalltalk.HashedCollection._from_(["a".__minus_gt((1)),"b".__minus_gt((2))]));
  1435. return self}, function($ctx1) {$ctx1.fill(self,"testNewFromPairs",{flattenedAssociations:flattenedAssociations},smalltalk.HashedCollectionTest)})},
  1436. args: [],
  1437. source: "testNewFromPairs\x0a\x22Accept an array in which all odd indexes are keys and evens are values.\x22\x0a| flattenedAssociations |\x0aflattenedAssociations := { 'a'. 1. 'b'. 2 }.\x0aself assertSameContents: ( self class collectionClass newFromPairs: flattenedAssociations ) as: #{ 'a' -> 1. 'b' -> 2 }.",
  1438. messageSends: ["assertSameContents:as:", "newFromPairs:", "collectionClass", "class", "->"],
  1439. referencedClasses: []
  1440. }),
  1441. smalltalk.HashedCollectionTest);
  1442. smalltalk.addMethod(
  1443. smalltalk.method({
  1444. selector: "collectionClass",
  1445. category: 'accessing',
  1446. fn: function (){
  1447. var self=this;
  1448. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1449. return smalltalk.withContext(function($ctx1) {
  1450. var $1;
  1451. $1=$HashedCollection();
  1452. return $1;
  1453. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.HashedCollectionTest.klass)})},
  1454. args: [],
  1455. source: "collectionClass\x0a\x09^ HashedCollection",
  1456. messageSends: [],
  1457. referencedClasses: ["HashedCollection"]
  1458. }),
  1459. smalltalk.HashedCollectionTest.klass);
  1460. smalltalk.addClass('DictionaryTest', smalltalk.HashedCollectionTest, [], 'Kernel-Tests');
  1461. smalltalk.addMethod(
  1462. smalltalk.method({
  1463. selector: "collection",
  1464. category: 'accessing',
  1465. fn: function (){
  1466. var self=this;
  1467. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1468. return smalltalk.withContext(function($ctx1) {
  1469. var $2,$3,$1;
  1470. $2=_st($Dictionary())._new();
  1471. _st($2)._at_put_((1),(1));
  1472. _st($2)._at_put_("a",(2));
  1473. _st($2)._at_put_(true,(3));
  1474. _st($2)._at_put_((4),(-4));
  1475. $3=_st($2)._yourself();
  1476. $1=$3;
  1477. return $1;
  1478. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.DictionaryTest)})},
  1479. args: [],
  1480. 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",
  1481. messageSends: ["at:put:", "new", "yourself"],
  1482. referencedClasses: ["Dictionary"]
  1483. }),
  1484. smalltalk.DictionaryTest);
  1485. smalltalk.addMethod(
  1486. smalltalk.method({
  1487. selector: "collectionWithDuplicates",
  1488. category: 'accessing',
  1489. fn: function (){
  1490. var self=this;
  1491. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1492. return smalltalk.withContext(function($ctx1) {
  1493. var $2,$3,$1;
  1494. $2=_st($Dictionary())._new();
  1495. _st($2)._at_put_((1),(1));
  1496. _st($2)._at_put_("a",(2));
  1497. _st($2)._at_put_(true,(3));
  1498. _st($2)._at_put_((4),(-4));
  1499. _st($2)._at_put_("b",(1));
  1500. _st($2)._at_put_((3),(3));
  1501. _st($2)._at_put_(false,(12));
  1502. $3=_st($2)._yourself();
  1503. $1=$3;
  1504. return $1;
  1505. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.DictionaryTest)})},
  1506. args: [],
  1507. 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",
  1508. messageSends: ["at:put:", "new", "yourself"],
  1509. referencedClasses: ["Dictionary"]
  1510. }),
  1511. smalltalk.DictionaryTest);
  1512. smalltalk.addMethod(
  1513. smalltalk.method({
  1514. selector: "testAccessing",
  1515. category: 'tests',
  1516. fn: function (){
  1517. var self=this;
  1518. var d;
  1519. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1520. return smalltalk.withContext(function($ctx1) {
  1521. d=_st($Dictionary())._new();
  1522. _st(d)._at_put_("hello","world");
  1523. self._assert_equals_(_st(d)._at_("hello"),"world");
  1524. self._assert_equals_(_st(d)._at_ifAbsent_("hello",(function(){
  1525. return smalltalk.withContext(function($ctx2) {
  1526. return nil;
  1527. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"world");
  1528. self._deny_(_st(_st(d)._at_ifAbsent_("foo",(function(){
  1529. return smalltalk.withContext(function($ctx2) {
  1530. return nil;
  1531. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}))).__eq("world"));
  1532. self._assert_(_st(d)._includesKey_("hello"));
  1533. self._deny_(_st(d)._includesKey_("foo"));
  1534. _st(d)._at_put_((1),(2));
  1535. self._assert_equals_(_st(d)._at_((1)),(2));
  1536. _st(d)._at_put_((1).__at((3)),(3));
  1537. self._assert_equals_(_st(d)._at_((1).__at((3))),(3));
  1538. self._assert_(_st(d)._includesKey_((1).__at((3))));
  1539. self._deny_(_st(d)._includesKey_((3).__at((1))));
  1540. return self}, function($ctx1) {$ctx1.fill(self,"testAccessing",{d:d},smalltalk.DictionaryTest)})},
  1541. args: [],
  1542. 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)",
  1543. messageSends: ["new", "at:put:", "assert:equals:", "at:", "at:ifAbsent:", "deny:", "=", "assert:", "includesKey:", "@"],
  1544. referencedClasses: ["Dictionary"]
  1545. }),
  1546. smalltalk.DictionaryTest);
  1547. smalltalk.addMethod(
  1548. smalltalk.method({
  1549. selector: "testAsHashedCollection",
  1550. category: 'tests',
  1551. fn: function (){
  1552. var self=this;
  1553. function $HashedCollection(){return smalltalk.HashedCollection||(typeof HashedCollection=="undefined"?nil:HashedCollection)}
  1554. return smalltalk.withContext(function($ctx1) {
  1555. self._assert_(_st(_st(_st(self._collectionClass())._new())._asHashedCollection())._isMemberOf_($HashedCollection()));
  1556. return self}, function($ctx1) {$ctx1.fill(self,"testAsHashedCollection",{},smalltalk.DictionaryTest)})},
  1557. args: [],
  1558. source: "testAsHashedCollection\x0aself assert: ( self collectionClass new asHashedCollection isMemberOf: HashedCollection ).",
  1559. messageSends: ["assert:", "isMemberOf:", "asHashedCollection", "new", "collectionClass"],
  1560. referencedClasses: ["HashedCollection"]
  1561. }),
  1562. smalltalk.DictionaryTest);
  1563. smalltalk.addMethod(
  1564. smalltalk.method({
  1565. selector: "testDynamicDictionaries",
  1566. category: 'tests',
  1567. fn: function (){
  1568. var self=this;
  1569. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1570. return smalltalk.withContext(function($ctx1) {
  1571. self._assert_equals_(_st(smalltalk.HashedCollection._from_(["hello".__minus_gt((1))]))._asDictionary(),_st($Dictionary())._with_("hello".__minus_gt((1))));
  1572. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaries",{},smalltalk.DictionaryTest)})},
  1573. args: [],
  1574. source: "testDynamicDictionaries\x0a\x09self assert: #{'hello' -> 1} asDictionary equals: (Dictionary with: 'hello' -> 1)",
  1575. messageSends: ["assert:equals:", "asDictionary", "->", "with:"],
  1576. referencedClasses: ["Dictionary"]
  1577. }),
  1578. smalltalk.DictionaryTest);
  1579. smalltalk.addMethod(
  1580. smalltalk.method({
  1581. selector: "testEquality",
  1582. category: 'tests',
  1583. fn: function (){
  1584. var self=this;
  1585. var d1,d2;
  1586. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1587. return smalltalk.withContext(function($ctx1) {
  1588. var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10;
  1589. self._assert_(_st(_st($Dictionary())._new()).__eq(_st($Dictionary())._new()));
  1590. $1=_st($Dictionary())._new();
  1591. _st($1)._at_put_((1),(2));
  1592. $2=_st($1)._yourself();
  1593. d1=$2;
  1594. $3=_st($Dictionary())._new();
  1595. _st($3)._at_put_((1),(2));
  1596. $4=_st($3)._yourself();
  1597. d2=$4;
  1598. self._assert_(_st(d1).__eq(d2));
  1599. $5=_st($Dictionary())._new();
  1600. _st($5)._at_put_((1),(3));
  1601. $6=_st($5)._yourself();
  1602. d2=$6;
  1603. self._deny_(_st(d1).__eq(d2));
  1604. $7=_st($Dictionary())._new();
  1605. _st($7)._at_put_((2),(2));
  1606. $8=_st($7)._yourself();
  1607. d2=$8;
  1608. self._deny_(_st(d1).__eq(d2));
  1609. $9=_st($Dictionary())._new();
  1610. _st($9)._at_put_((1),(2));
  1611. _st($9)._at_put_((3),(4));
  1612. $10=_st($9)._yourself();
  1613. d2=$10;
  1614. self._deny_(_st(d1).__eq(d2));
  1615. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{d1:d1,d2:d2},smalltalk.DictionaryTest)})},
  1616. args: [],
  1617. 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.",
  1618. messageSends: ["assert:", "=", "new", "at:put:", "yourself", "deny:"],
  1619. referencedClasses: ["Dictionary"]
  1620. }),
  1621. smalltalk.DictionaryTest);
  1622. smalltalk.addMethod(
  1623. smalltalk.method({
  1624. selector: "testIfAbsent",
  1625. category: 'tests',
  1626. fn: function (){
  1627. var self=this;
  1628. var d,visited;
  1629. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1630. return smalltalk.withContext(function($ctx1) {
  1631. visited=false;
  1632. d=_st($Dictionary())._new();
  1633. _st(d)._at_ifAbsent_("hello",(function(){
  1634. return smalltalk.withContext(function($ctx2) {
  1635. visited=true;
  1636. return visited;
  1637. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1638. self._assert_(visited);
  1639. return self}, function($ctx1) {$ctx1.fill(self,"testIfAbsent",{d:d,visited:visited},smalltalk.DictionaryTest)})},
  1640. args: [],
  1641. 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.",
  1642. messageSends: ["new", "at:ifAbsent:", "assert:"],
  1643. referencedClasses: ["Dictionary"]
  1644. }),
  1645. smalltalk.DictionaryTest);
  1646. smalltalk.addMethod(
  1647. smalltalk.method({
  1648. selector: "testIfPresent",
  1649. category: 'tests',
  1650. fn: function (){
  1651. var self=this;
  1652. var d,visited,absent;
  1653. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1654. return smalltalk.withContext(function($ctx1) {
  1655. visited=false;
  1656. d=_st($Dictionary())._new();
  1657. _st(d)._at_put_("hello","world");
  1658. _st(d)._at_ifPresent_("hello",(function(value){
  1659. return smalltalk.withContext(function($ctx2) {
  1660. visited=value;
  1661. return visited;
  1662. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,1)})}));
  1663. self._assert_equals_(visited,"world");
  1664. absent=_st(d)._at_ifPresent_("bye",(function(value){
  1665. return smalltalk.withContext(function($ctx2) {
  1666. visited=value;
  1667. return visited;
  1668. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,2)})}));
  1669. self._assert_(_st(absent)._isNil());
  1670. return self}, function($ctx1) {$ctx1.fill(self,"testIfPresent",{d:d,visited:visited,absent:absent},smalltalk.DictionaryTest)})},
  1671. args: [],
  1672. 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.",
  1673. messageSends: ["new", "at:put:", "at:ifPresent:", "assert:equals:", "assert:", "isNil"],
  1674. referencedClasses: ["Dictionary"]
  1675. }),
  1676. smalltalk.DictionaryTest);
  1677. smalltalk.addMethod(
  1678. smalltalk.method({
  1679. selector: "testIfPresentIfAbsent",
  1680. category: 'tests',
  1681. fn: function (){
  1682. var self=this;
  1683. var d,visited;
  1684. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1685. return smalltalk.withContext(function($ctx1) {
  1686. visited=false;
  1687. d=_st($Dictionary())._new();
  1688. _st(d)._at_put_("hello","world");
  1689. _st(d)._at_ifPresent_ifAbsent_("hello",(function(value){
  1690. return smalltalk.withContext(function($ctx2) {
  1691. visited=value;
  1692. return visited;
  1693. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,1)})}),(function(){
  1694. return smalltalk.withContext(function($ctx2) {
  1695. visited=true;
  1696. return visited;
  1697. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1698. self._assert_equals_(visited,"world");
  1699. _st(d)._at_ifPresent_ifAbsent_("buy",(function(value){
  1700. return smalltalk.withContext(function($ctx2) {
  1701. visited=value;
  1702. return visited;
  1703. }, function($ctx2) {$ctx2.fillBlock({value:value},$ctx1,3)})}),(function(){
  1704. return smalltalk.withContext(function($ctx2) {
  1705. visited=true;
  1706. return visited;
  1707. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
  1708. self._assert_(visited);
  1709. return self}, function($ctx1) {$ctx1.fill(self,"testIfPresentIfAbsent",{d:d,visited:visited},smalltalk.DictionaryTest)})},
  1710. args: [],
  1711. 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.",
  1712. messageSends: ["new", "at:put:", "at:ifPresent:ifAbsent:", "assert:equals:", "assert:"],
  1713. referencedClasses: ["Dictionary"]
  1714. }),
  1715. smalltalk.DictionaryTest);
  1716. smalltalk.addMethod(
  1717. smalltalk.method({
  1718. selector: "testKeys",
  1719. category: 'tests',
  1720. fn: function (){
  1721. var self=this;
  1722. var d;
  1723. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1724. return smalltalk.withContext(function($ctx1) {
  1725. d=_st($Dictionary())._new();
  1726. _st(d)._at_put_((1),(2));
  1727. _st(d)._at_put_((2),(3));
  1728. _st(d)._at_put_((3),(4));
  1729. self._assert_equals_(_st(d)._keys(),[(1), (2), (3)]);
  1730. return self}, function($ctx1) {$ctx1.fill(self,"testKeys",{d:d},smalltalk.DictionaryTest)})},
  1731. args: [],
  1732. 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)",
  1733. messageSends: ["new", "at:put:", "assert:equals:", "keys"],
  1734. referencedClasses: ["Dictionary"]
  1735. }),
  1736. smalltalk.DictionaryTest);
  1737. smalltalk.addMethod(
  1738. smalltalk.method({
  1739. selector: "testPointKey",
  1740. category: 'tests',
  1741. fn: function (){
  1742. var self=this;
  1743. var d;
  1744. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1745. return smalltalk.withContext(function($ctx1) {
  1746. d=_st($Dictionary())._new();
  1747. _st(d)._at_put_((1).__at((1)),"foo");
  1748. self._assert_equals_(_st(d)._at_((1).__at((1))),"foo");
  1749. _st(d)._at_put_((1).__at((1)),"bar");
  1750. self._assert_equals_(_st(d)._at_((1).__at((1))),"bar");
  1751. _st(d)._removeKey_((1).__at((1)));
  1752. self._assert_equals_(_st(d)._at_ifAbsent_((1).__at((1)),(function(){
  1753. return smalltalk.withContext(function($ctx2) {
  1754. return "baz";
  1755. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"baz");
  1756. self._deny_(_st(d)._includesKey_((1).__at((1))));
  1757. return self}, function($ctx1) {$ctx1.fill(self,"testPointKey",{d:d},smalltalk.DictionaryTest)})},
  1758. args: [],
  1759. 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)",
  1760. messageSends: ["new", "at:put:", "@", "assert:equals:", "at:", "removeKey:", "at:ifAbsent:", "deny:", "includesKey:"],
  1761. referencedClasses: ["Dictionary"]
  1762. }),
  1763. smalltalk.DictionaryTest);
  1764. smalltalk.addMethod(
  1765. smalltalk.method({
  1766. selector: "testPrintString",
  1767. category: 'tests',
  1768. fn: function (){
  1769. var self=this;
  1770. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1771. return smalltalk.withContext(function($ctx1) {
  1772. var $1,$2;
  1773. $1=_st($Dictionary())._new();
  1774. _st($1)._at_put_("firstname","James");
  1775. _st($1)._at_put_("lastname","Bond");
  1776. $2=_st($1)._printString();
  1777. self._assert_equals_($2,"a Dictionary ('firstname' -> 'James' , 'lastname' -> 'Bond')");
  1778. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{},smalltalk.DictionaryTest)})},
  1779. args: [],
  1780. 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'')'",
  1781. messageSends: ["assert:equals:", "at:put:", "new", "printString"],
  1782. referencedClasses: ["Dictionary"]
  1783. }),
  1784. smalltalk.DictionaryTest);
  1785. smalltalk.addMethod(
  1786. smalltalk.method({
  1787. selector: "testRemoveKey",
  1788. category: 'tests',
  1789. fn: function (){
  1790. var self=this;
  1791. var d,key;
  1792. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1793. return smalltalk.withContext(function($ctx1) {
  1794. d=_st($Dictionary())._new();
  1795. _st(d)._at_put_((1),(2));
  1796. _st(d)._at_put_((2),(3));
  1797. _st(d)._at_put_((3),(4));
  1798. key=(2);
  1799. self._assert_equals_(_st(d)._keys(),[(1), (2), (3)]);
  1800. _st(d)._removeKey_(key);
  1801. self._assert_equals_(_st(d)._keys(),[(1), (3)]);
  1802. self._assert_equals_(_st(d)._values(),[(2), (4)]);
  1803. self._deny_(_st(d)._includesKey_((2)));
  1804. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveKey",{d:d,key:key},smalltalk.DictionaryTest)})},
  1805. args: [],
  1806. 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)",
  1807. messageSends: ["new", "at:put:", "assert:equals:", "keys", "removeKey:", "values", "deny:", "includesKey:"],
  1808. referencedClasses: ["Dictionary"]
  1809. }),
  1810. smalltalk.DictionaryTest);
  1811. smalltalk.addMethod(
  1812. smalltalk.method({
  1813. selector: "testRemoveKeyIfAbsent",
  1814. category: 'tests',
  1815. fn: function (){
  1816. var self=this;
  1817. var d,key;
  1818. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1819. return smalltalk.withContext(function($ctx1) {
  1820. d=_st($Dictionary())._new();
  1821. _st(d)._at_put_((1),(2));
  1822. _st(d)._at_put_((2),(3));
  1823. _st(d)._at_put_((3),(4));
  1824. key=(2);
  1825. self._assert_equals_(_st(d)._removeKey_(key),(3));
  1826. key=(3);
  1827. self._assert_equals_(_st(d)._removeKey_ifAbsent_(key,(function(){
  1828. return smalltalk.withContext(function($ctx2) {
  1829. return (42);
  1830. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),(4));
  1831. key="why";
  1832. self._assert_equals_(_st(d)._removeKey_ifAbsent_(key,(function(){
  1833. return smalltalk.withContext(function($ctx2) {
  1834. return (42);
  1835. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),(42));
  1836. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveKeyIfAbsent",{d:d,key:key},smalltalk.DictionaryTest)})},
  1837. args: [],
  1838. 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.",
  1839. messageSends: ["new", "at:put:", "assert:equals:", "removeKey:", "removeKey:ifAbsent:"],
  1840. referencedClasses: ["Dictionary"]
  1841. }),
  1842. smalltalk.DictionaryTest);
  1843. smalltalk.addMethod(
  1844. smalltalk.method({
  1845. selector: "testSize",
  1846. category: 'tests',
  1847. fn: function (){
  1848. var self=this;
  1849. var d;
  1850. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1851. return smalltalk.withContext(function($ctx1) {
  1852. d=_st($Dictionary())._new();
  1853. self._assert_equals_(_st(d)._size(),(0));
  1854. _st(d)._at_put_((1),(2));
  1855. self._assert_equals_(_st(d)._size(),(1));
  1856. _st(d)._at_put_((2),(3));
  1857. self._assert_equals_(_st(d)._size(),(2));
  1858. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{d:d},smalltalk.DictionaryTest)})},
  1859. args: [],
  1860. 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.",
  1861. messageSends: ["new", "assert:equals:", "size", "at:put:"],
  1862. referencedClasses: ["Dictionary"]
  1863. }),
  1864. smalltalk.DictionaryTest);
  1865. smalltalk.addMethod(
  1866. smalltalk.method({
  1867. selector: "testValues",
  1868. category: 'tests',
  1869. fn: function (){
  1870. var self=this;
  1871. var d;
  1872. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1873. return smalltalk.withContext(function($ctx1) {
  1874. d=_st($Dictionary())._new();
  1875. _st(d)._at_put_((1),(2));
  1876. _st(d)._at_put_((2),(3));
  1877. _st(d)._at_put_((3),(4));
  1878. self._assert_equals_(_st(d)._values(),[(2), (3), (4)]);
  1879. return self}, function($ctx1) {$ctx1.fill(self,"testValues",{d:d},smalltalk.DictionaryTest)})},
  1880. args: [],
  1881. 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)",
  1882. messageSends: ["new", "at:put:", "assert:equals:", "values"],
  1883. referencedClasses: ["Dictionary"]
  1884. }),
  1885. smalltalk.DictionaryTest);
  1886. smalltalk.addMethod(
  1887. smalltalk.method({
  1888. selector: "collectionClass",
  1889. category: 'accessing',
  1890. fn: function (){
  1891. var self=this;
  1892. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1893. return smalltalk.withContext(function($ctx1) {
  1894. var $1;
  1895. $1=$Dictionary();
  1896. return $1;
  1897. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.DictionaryTest.klass)})},
  1898. args: [],
  1899. source: "collectionClass\x0a\x09^ Dictionary",
  1900. messageSends: [],
  1901. referencedClasses: ["Dictionary"]
  1902. }),
  1903. smalltalk.DictionaryTest.klass);
  1904. smalltalk.addClass('SequenceableCollectionTest', smalltalk.IndexableCollectionTest, [], 'Kernel-Tests');
  1905. smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1906. smalltalk.addMethod(
  1907. smalltalk.method({
  1908. selector: "testAdd",
  1909. category: 'tests',
  1910. fn: function (){
  1911. var self=this;
  1912. var array;
  1913. return smalltalk.withContext(function($ctx1) {
  1914. array=[(1), (2), (3), (4), (5)];
  1915. _st(array)._add_((6));
  1916. self._assert_equals_(array,[(1), (2), (3), (4), (5), (6)]);
  1917. return self}, function($ctx1) {$ctx1.fill(self,"testAdd",{array:array},smalltalk.ArrayTest)})},
  1918. args: [],
  1919. source: "testAdd \x0a\x09| array | \x0a\x09array := #(1 2 3 4 5). \x0a\x09array add:6 . \x0a\x09self assert: array equals: #(1 2 3 4 5 6).",
  1920. messageSends: ["add:", "assert:equals:"],
  1921. referencedClasses: []
  1922. }),
  1923. smalltalk.ArrayTest);
  1924. smalltalk.addMethod(
  1925. smalltalk.method({
  1926. selector: "testAddFirst",
  1927. category: 'tests',
  1928. fn: function (){
  1929. var self=this;
  1930. return smalltalk.withContext(function($ctx1) {
  1931. var $1,$2;
  1932. $1=[(2), (3), (4), (5)];
  1933. _st($1)._addFirst_((1));
  1934. $2=_st($1)._yourself();
  1935. self._assert_equals_($2,[(1), (2), (3), (4), (5)]);
  1936. return self}, function($ctx1) {$ctx1.fill(self,"testAddFirst",{},smalltalk.ArrayTest)})},
  1937. args: [],
  1938. source: "testAddFirst\x0a\x09self assert: (#(2 3 4 5) addFirst: 1; yourself) equals: #(1 2 3 4 5)",
  1939. messageSends: ["assert:equals:", "addFirst:", "yourself"],
  1940. referencedClasses: []
  1941. }),
  1942. smalltalk.ArrayTest);
  1943. smalltalk.addMethod(
  1944. smalltalk.method({
  1945. selector: "testAtIfAbsent",
  1946. category: 'tests',
  1947. fn: function (){
  1948. var self=this;
  1949. var array;
  1950. return smalltalk.withContext(function($ctx1) {
  1951. array=["hello", "world"];
  1952. self._assert_equals_(_st(array)._at_((1)),"hello");
  1953. self._assert_equals_(_st(array)._at_((2)),"world");
  1954. self._assert_equals_(_st(array)._at_ifAbsent_((2),(function(){
  1955. return smalltalk.withContext(function($ctx2) {
  1956. return "not found";
  1957. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"world");
  1958. self._assert_equals_(_st(array)._at_ifAbsent_((0),(function(){
  1959. return smalltalk.withContext(function($ctx2) {
  1960. return "not found";
  1961. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"not found");
  1962. self._assert_equals_(_st(array)._at_ifAbsent_((-10),(function(){
  1963. return smalltalk.withContext(function($ctx2) {
  1964. return "not found";
  1965. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})})),"not found");
  1966. self._assert_equals_(_st(array)._at_ifAbsent_((3),(function(){
  1967. return smalltalk.withContext(function($ctx2) {
  1968. return "not found";
  1969. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})})),"not found");
  1970. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{array:array},smalltalk.ArrayTest)})},
  1971. args: [],
  1972. 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'.",
  1973. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  1974. referencedClasses: []
  1975. }),
  1976. smalltalk.ArrayTest);
  1977. smalltalk.addMethod(
  1978. smalltalk.method({
  1979. selector: "testFirst",
  1980. category: 'tests',
  1981. fn: function (){
  1982. var self=this;
  1983. var array;
  1984. return smalltalk.withContext(function($ctx1) {
  1985. array=[(1), (2), (3), (4), (5)];
  1986. self._assert_(_st(_st(array)._first()).__eq(_st(array)._at_((1))));
  1987. return self}, function($ctx1) {$ctx1.fill(self,"testFirst",{array:array},smalltalk.ArrayTest)})},
  1988. args: [],
  1989. source: "testFirst\x0a\x09|array|\x0a\x09array := #(1 2 3 4 5).\x0a\x09self assert: (array first) = (array at:1)",
  1990. messageSends: ["assert:", "=", "first", "at:"],
  1991. referencedClasses: []
  1992. }),
  1993. smalltalk.ArrayTest);
  1994. smalltalk.addMethod(
  1995. smalltalk.method({
  1996. selector: "testFirstN",
  1997. category: 'tests',
  1998. fn: function (){
  1999. var self=this;
  2000. return smalltalk.withContext(function($ctx1) {
  2001. self._assert_equals_(_st([(1),(2),(3),(4),(5)])._first_((3)),[(1),(2),(3)]);
  2002. return self}, function($ctx1) {$ctx1.fill(self,"testFirstN",{},smalltalk.ArrayTest)})},
  2003. args: [],
  2004. source: "testFirstN\x0a\x09self assert: ({1. 2. 3. 4. 5} first: 3) equals: {1. 2. 3}",
  2005. messageSends: ["assert:equals:", "first:"],
  2006. referencedClasses: []
  2007. }),
  2008. smalltalk.ArrayTest);
  2009. smalltalk.addMethod(
  2010. smalltalk.method({
  2011. selector: "testFourth",
  2012. category: 'tests',
  2013. fn: function (){
  2014. var self=this;
  2015. var array;
  2016. return smalltalk.withContext(function($ctx1) {
  2017. array=[(1), (2), (3), (4), (5)];
  2018. self._assert_(_st(_st(array)._fourth()).__eq(_st(array)._at_((4))));
  2019. return self}, function($ctx1) {$ctx1.fill(self,"testFourth",{array:array},smalltalk.ArrayTest)})},
  2020. args: [],
  2021. source: "testFourth\x0a\x09|array|\x0a\x09array := #(1 2 3 4 5).\x0a\x09self assert: (array fourth) = (array at:4)",
  2022. messageSends: ["assert:", "=", "fourth", "at:"],
  2023. referencedClasses: []
  2024. }),
  2025. smalltalk.ArrayTest);
  2026. smalltalk.addMethod(
  2027. smalltalk.method({
  2028. selector: "testIfEmpty",
  2029. category: 'tests',
  2030. fn: function (){
  2031. var self=this;
  2032. return smalltalk.withContext(function($ctx1) {
  2033. self._assert_equals_(""._ifEmpty_((function(){
  2034. return smalltalk.withContext(function($ctx2) {
  2035. return "zork";
  2036. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"zork");
  2037. return self}, function($ctx1) {$ctx1.fill(self,"testIfEmpty",{},smalltalk.ArrayTest)})},
  2038. args: [],
  2039. source: "testIfEmpty\x0a\x09self assert: ( '' ifEmpty: ['zork'] ) equals: 'zork'",
  2040. messageSends: ["assert:equals:", "ifEmpty:"],
  2041. referencedClasses: []
  2042. }),
  2043. smalltalk.ArrayTest);
  2044. smalltalk.addMethod(
  2045. smalltalk.method({
  2046. selector: "testLast",
  2047. category: 'tests',
  2048. fn: function (){
  2049. var self=this;
  2050. var array;
  2051. return smalltalk.withContext(function($ctx1) {
  2052. array=[(1), (2), (3), (4), (5)];
  2053. self._assert_(_st(_st(array)._last()).__eq(_st(array)._at_((5))));
  2054. return self}, function($ctx1) {$ctx1.fill(self,"testLast",{array:array},smalltalk.ArrayTest)})},
  2055. args: [],
  2056. source: "testLast\x0a\x09|array|\x0a\x09array := #(1 2 3 4 5).\x0a\x09self assert: (array last) = (array at:5)",
  2057. messageSends: ["assert:", "=", "last", "at:"],
  2058. referencedClasses: []
  2059. }),
  2060. smalltalk.ArrayTest);
  2061. smalltalk.addMethod(
  2062. smalltalk.method({
  2063. selector: "testPrintString",
  2064. category: 'tests',
  2065. fn: function (){
  2066. var self=this;
  2067. var array;
  2068. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  2069. return smalltalk.withContext(function($ctx1) {
  2070. var $1,$2,$3,$4;
  2071. array=_st($Array())._new();
  2072. self._assert_equals_(_st(array)._printString(),"an Array ()");
  2073. $1=array;
  2074. _st($1)._add_((1));
  2075. $2=_st($1)._add_((3));
  2076. self._assert_equals_(_st(array)._printString(),"an Array (1 3)");
  2077. _st(array)._add_("foo");
  2078. self._assert_equals_(_st(array)._printString(),"an Array (1 3 'foo')");
  2079. $3=array;
  2080. _st($3)._remove_((1));
  2081. $4=_st($3)._remove_((3));
  2082. self._assert_equals_(_st(array)._printString(),"an Array ('foo')");
  2083. _st(array)._addLast_((3));
  2084. self._assert_equals_(_st(array)._printString(),"an Array ('foo' 3)");
  2085. _st(array)._addLast_((3));
  2086. self._assert_equals_(_st(array)._printString(),"an Array ('foo' 3 3)");
  2087. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{array:array},smalltalk.ArrayTest)})},
  2088. args: [],
  2089. 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)'.",
  2090. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:", "addLast:"],
  2091. referencedClasses: ["Array"]
  2092. }),
  2093. smalltalk.ArrayTest);
  2094. smalltalk.addMethod(
  2095. smalltalk.method({
  2096. selector: "testRemove",
  2097. category: 'tests',
  2098. fn: function (){
  2099. var self=this;
  2100. var array;
  2101. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2102. return smalltalk.withContext(function($ctx1) {
  2103. array=[(1), (2), (3), (4), (5)];
  2104. _st(array)._remove_((3));
  2105. self._assert_equals_(array,[(1), (2), (4), (5)]);
  2106. self._should_raise_((function(){
  2107. return smalltalk.withContext(function($ctx2) {
  2108. return _st(array)._remove_((3));
  2109. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2110. return self}, function($ctx1) {$ctx1.fill(self,"testRemove",{array:array},smalltalk.ArrayTest)})},
  2111. args: [],
  2112. source: "testRemove \x0a\x09|array|\x0a\x09array := #(1 2 3 4 5). \x0a\x09array remove:3.\x0a\x09self assert: array equals: #(1 2 4 5).\x0a\x09self should: [array remove:3] raise: Error.",
  2113. messageSends: ["remove:", "assert:equals:", "should:raise:"],
  2114. referencedClasses: ["Error"]
  2115. }),
  2116. smalltalk.ArrayTest);
  2117. smalltalk.addMethod(
  2118. smalltalk.method({
  2119. selector: "testRemoveFromTo",
  2120. category: 'tests',
  2121. fn: function (){
  2122. var self=this;
  2123. return smalltalk.withContext(function($ctx1) {
  2124. self._assert_equals_([(1), (2), (3), (4)]._removeFrom_to_((1),(3)),[(4)]);
  2125. self._assert_equals_([(1), (2), (3), (4)]._removeFrom_to_((2),(3)),[(1), (4)]);
  2126. self._assert_equals_([(1), (2), (3), (4)]._removeFrom_to_((2),(4)),[(1)]);
  2127. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveFromTo",{},smalltalk.ArrayTest)})},
  2128. args: [],
  2129. source: "testRemoveFromTo\x0a\x09\x0a\x09self assert: (#(1 2 3 4) removeFrom: 1 to: 3) equals: #(4).\x0a\x09self assert: (#(1 2 3 4) removeFrom: 2 to: 3) equals: #(1 4).\x0a\x09self assert: (#(1 2 3 4) removeFrom: 2 to: 4) equals: #(1)",
  2130. messageSends: ["assert:equals:", "removeFrom:to:"],
  2131. referencedClasses: []
  2132. }),
  2133. smalltalk.ArrayTest);
  2134. smalltalk.addMethod(
  2135. smalltalk.method({
  2136. selector: "testRemoveIndex",
  2137. category: 'tests',
  2138. fn: function (){
  2139. var self=this;
  2140. return smalltalk.withContext(function($ctx1) {
  2141. self._assert_equals_([(1), (2), (3), (4)]._removeIndex_((2)),[(1), (3), (4)]);
  2142. self._assert_equals_([(1), (2), (3), (4)]._removeIndex_((1)),[(2), (3), (4)]);
  2143. self._assert_equals_(["hello"]._removeIndex_((1)),[]);
  2144. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveIndex",{},smalltalk.ArrayTest)})},
  2145. args: [],
  2146. source: "testRemoveIndex\x0a\x09\x0a\x09self assert: (#(1 2 3 4) removeIndex: 2) equals: #(1 3 4).\x0a\x09self assert: (#(1 2 3 4) removeIndex: 1) equals: #(2 3 4).\x0a\x09self assert: (#('hello') removeIndex: 1) equals: #()",
  2147. messageSends: ["assert:equals:", "removeIndex:"],
  2148. referencedClasses: []
  2149. }),
  2150. smalltalk.ArrayTest);
  2151. smalltalk.addMethod(
  2152. smalltalk.method({
  2153. selector: "testRemoveLast",
  2154. category: 'tests',
  2155. fn: function (){
  2156. var self=this;
  2157. var array;
  2158. return smalltalk.withContext(function($ctx1) {
  2159. array=[(1), (2)];
  2160. _st(array)._removeLast();
  2161. self._assert_(_st(_st(array)._last()).__eq((1)));
  2162. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveLast",{array:array},smalltalk.ArrayTest)})},
  2163. args: [],
  2164. source: "testRemoveLast \x0a\x09|array|\x0a\x09array := #(1 2). \x0a\x09array removeLast.\x0a\x09self assert: array last = 1.",
  2165. messageSends: ["removeLast", "assert:", "=", "last"],
  2166. referencedClasses: []
  2167. }),
  2168. smalltalk.ArrayTest);
  2169. smalltalk.addMethod(
  2170. smalltalk.method({
  2171. selector: "testReversed",
  2172. category: 'tests',
  2173. fn: function (){
  2174. var self=this;
  2175. var array;
  2176. return smalltalk.withContext(function($ctx1) {
  2177. array=[(5), (4), (3), (2), (1)];
  2178. self._assert_equals_(_st(array)._reversed(),[(1), (2), (3), (4), (5)]);
  2179. return self}, function($ctx1) {$ctx1.fill(self,"testReversed",{array:array},smalltalk.ArrayTest)})},
  2180. args: [],
  2181. source: "testReversed\x0a\x09|array|\x0a\x09array := #(5 4 3 2 1). \x0a\x09self assert: (array reversed) equals: #(1 2 3 4 5)",
  2182. messageSends: ["assert:equals:", "reversed"],
  2183. referencedClasses: []
  2184. }),
  2185. smalltalk.ArrayTest);
  2186. smalltalk.addMethod(
  2187. smalltalk.method({
  2188. selector: "testSize",
  2189. category: 'tests',
  2190. fn: function (){
  2191. var self=this;
  2192. var array;
  2193. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  2194. return smalltalk.withContext(function($ctx1) {
  2195. array=["hello", "world"];
  2196. self._assert_(_st(_st(array)._size()).__eq((2)));
  2197. self._assert_(_st(_st(_st($Array())._new())._size()).__eq((0)));
  2198. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{array:array},smalltalk.ArrayTest)})},
  2199. args: [],
  2200. source: "testSize\x0a\x09\x09| array | \x0a\x09\x09array := #('hello' 'world'). \x0a\x09\x09self assert: array size = 2. \x0a\x09\x09self assert: Array new size = 0.",
  2201. messageSends: ["assert:", "=", "size", "new"],
  2202. referencedClasses: ["Array"]
  2203. }),
  2204. smalltalk.ArrayTest);
  2205. smalltalk.addMethod(
  2206. smalltalk.method({
  2207. selector: "testSort",
  2208. category: 'tests',
  2209. fn: function (){
  2210. var self=this;
  2211. var array;
  2212. return smalltalk.withContext(function($ctx1) {
  2213. array=[(3), (1), (4), (5), (2)];
  2214. _st(array)._sort();
  2215. self._assert_equals_(array,[(1), (2), (3), (4), (5)]);
  2216. return self}, function($ctx1) {$ctx1.fill(self,"testSort",{array:array},smalltalk.ArrayTest)})},
  2217. args: [],
  2218. source: "testSort\x0a\x09|array|\x0a\x09array := #(3 1 4 5 2). \x0a\x09array sort.\x0a\x09self assert: array equals: #(1 2 3 4 5)",
  2219. messageSends: ["sort", "assert:equals:"],
  2220. referencedClasses: []
  2221. }),
  2222. smalltalk.ArrayTest);
  2223. smalltalk.addMethod(
  2224. smalltalk.method({
  2225. selector: "testThird",
  2226. category: 'tests',
  2227. fn: function (){
  2228. var self=this;
  2229. var array;
  2230. return smalltalk.withContext(function($ctx1) {
  2231. array=[(1), (2), (3), (4), (5)];
  2232. self._assert_(_st(_st(array)._third()).__eq(_st(array)._at_((3))));
  2233. return self}, function($ctx1) {$ctx1.fill(self,"testThird",{array:array},smalltalk.ArrayTest)})},
  2234. args: [],
  2235. source: "testThird\x0a\x09|array|\x0a\x09array := #(1 2 3 4 5).\x0a\x09self assert: (array third) = (array at:3)",
  2236. messageSends: ["assert:", "=", "third", "at:"],
  2237. referencedClasses: []
  2238. }),
  2239. smalltalk.ArrayTest);
  2240. smalltalk.addMethod(
  2241. smalltalk.method({
  2242. selector: "collectionClass",
  2243. category: 'accessing',
  2244. fn: function (){
  2245. var self=this;
  2246. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  2247. return smalltalk.withContext(function($ctx1) {
  2248. var $1;
  2249. $1=$Array();
  2250. return $1;
  2251. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayTest.klass)})},
  2252. args: [],
  2253. source: "collectionClass\x0a\x09^ Array",
  2254. messageSends: [],
  2255. referencedClasses: ["Array"]
  2256. }),
  2257. smalltalk.ArrayTest.klass);
  2258. smalltalk.addClass('StringTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  2259. smalltalk.addMethod(
  2260. smalltalk.method({
  2261. selector: "collection",
  2262. category: 'accessing',
  2263. fn: function (){
  2264. var self=this;
  2265. return smalltalk.withContext(function($ctx1) {
  2266. return "hello";
  2267. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.StringTest)})},
  2268. args: [],
  2269. source: "collection\x0a\x09^'hello'",
  2270. messageSends: [],
  2271. referencedClasses: []
  2272. }),
  2273. smalltalk.StringTest);
  2274. smalltalk.addMethod(
  2275. smalltalk.method({
  2276. selector: "collectionWithDuplicates",
  2277. category: 'accessing',
  2278. fn: function (){
  2279. var self=this;
  2280. return smalltalk.withContext(function($ctx1) {
  2281. return "abbaerte";
  2282. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.StringTest)})},
  2283. args: [],
  2284. source: "collectionWithDuplicates\x0a\x09^ 'abbaerte'",
  2285. messageSends: [],
  2286. referencedClasses: []
  2287. }),
  2288. smalltalk.StringTest);
  2289. smalltalk.addMethod(
  2290. smalltalk.method({
  2291. selector: "testAddRemove",
  2292. category: 'tests',
  2293. fn: function (){
  2294. var self=this;
  2295. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2296. return smalltalk.withContext(function($ctx1) {
  2297. self._should_raise_((function(){
  2298. return smalltalk.withContext(function($ctx2) {
  2299. return "hello"._add_("a");
  2300. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2301. self._should_raise_((function(){
  2302. return smalltalk.withContext(function($ctx2) {
  2303. return "hello"._remove_("h");
  2304. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$Error());
  2305. return self}, function($ctx1) {$ctx1.fill(self,"testAddRemove",{},smalltalk.StringTest)})},
  2306. args: [],
  2307. source: "testAddRemove\x0a\x09self should: ['hello' add: 'a'] raise: Error.\x0a\x09self should: ['hello' remove: 'h'] raise: Error",
  2308. messageSends: ["should:raise:", "add:", "remove:"],
  2309. referencedClasses: ["Error"]
  2310. }),
  2311. smalltalk.StringTest);
  2312. smalltalk.addMethod(
  2313. smalltalk.method({
  2314. selector: "testAsArray",
  2315. category: 'tests',
  2316. fn: function (){
  2317. var self=this;
  2318. return smalltalk.withContext(function($ctx1) {
  2319. self._assert_equals_("hello"._asArray(),["h", "e", "l", "l", "o"]);
  2320. return self}, function($ctx1) {$ctx1.fill(self,"testAsArray",{},smalltalk.StringTest)})},
  2321. args: [],
  2322. source: "testAsArray\x0a\x09self assert: 'hello' asArray equals: #('h' 'e' 'l' 'l' 'o').",
  2323. messageSends: ["assert:equals:", "asArray"],
  2324. referencedClasses: []
  2325. }),
  2326. smalltalk.StringTest);
  2327. smalltalk.addMethod(
  2328. smalltalk.method({
  2329. selector: "testAsLowerCase",
  2330. category: 'tests',
  2331. fn: function (){
  2332. var self=this;
  2333. return smalltalk.withContext(function($ctx1) {
  2334. self._assert_equals_("JACKIE"._asLowercase(),"jackie");
  2335. return self}, function($ctx1) {$ctx1.fill(self,"testAsLowerCase",{},smalltalk.StringTest)})},
  2336. args: [],
  2337. source: "testAsLowerCase\x0a\x09self assert: 'JACKIE' asLowercase equals: 'jackie'.",
  2338. messageSends: ["assert:equals:", "asLowercase"],
  2339. referencedClasses: []
  2340. }),
  2341. smalltalk.StringTest);
  2342. smalltalk.addMethod(
  2343. smalltalk.method({
  2344. selector: "testAsNumber",
  2345. category: 'tests',
  2346. fn: function (){
  2347. var self=this;
  2348. return smalltalk.withContext(function($ctx1) {
  2349. self._assert_equals_("3"._asNumber(),(3));
  2350. self._assert_equals_("-3"._asNumber(),(-3));
  2351. self._assert_equals_("-1.5"._asNumber(),(-1.5));
  2352. return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.StringTest)})},
  2353. args: [],
  2354. source: "testAsNumber\x0a\x09self assert: '3' asNumber equals: 3.\x0a\x09self assert: '-3' asNumber equals: -3.\x0a\x09self assert: '-1.5' asNumber equals: -1.5.",
  2355. messageSends: ["assert:equals:", "asNumber"],
  2356. referencedClasses: []
  2357. }),
  2358. smalltalk.StringTest);
  2359. smalltalk.addMethod(
  2360. smalltalk.method({
  2361. selector: "testAsUpperCase",
  2362. category: 'tests',
  2363. fn: function (){
  2364. var self=this;
  2365. return smalltalk.withContext(function($ctx1) {
  2366. self._assert_equals_("jackie"._asUppercase(),"JACKIE");
  2367. return self}, function($ctx1) {$ctx1.fill(self,"testAsUpperCase",{},smalltalk.StringTest)})},
  2368. args: [],
  2369. source: "testAsUpperCase\x0a\x09self assert: 'jackie' asUppercase equals: 'JACKIE'.",
  2370. messageSends: ["assert:equals:", "asUppercase"],
  2371. referencedClasses: []
  2372. }),
  2373. smalltalk.StringTest);
  2374. smalltalk.addMethod(
  2375. smalltalk.method({
  2376. selector: "testAsciiValue",
  2377. category: 'tests',
  2378. fn: function (){
  2379. var self=this;
  2380. var characterA,characterU;
  2381. return smalltalk.withContext(function($ctx1) {
  2382. characterA="A";
  2383. characterU="U";
  2384. self._assert_equals_(_st(characterA)._asciiValue(),(65));
  2385. self._assert_equals_(_st(characterU)._asciiValue(),(85));
  2386. return self}, function($ctx1) {$ctx1.fill(self,"testAsciiValue",{characterA:characterA,characterU:characterU},smalltalk.StringTest)})},
  2387. args: [],
  2388. source: "testAsciiValue\x0a |characterA characterU|\x0a characterA := 'A'.\x0a characterU := 'U'.\x0a self assert: (characterA asciiValue) equals:65.\x0a self assert: (characterU asciiValue) equals:85",
  2389. messageSends: ["assert:equals:", "asciiValue"],
  2390. referencedClasses: []
  2391. }),
  2392. smalltalk.StringTest);
  2393. smalltalk.addMethod(
  2394. smalltalk.method({
  2395. selector: "testAt",
  2396. category: 'tests',
  2397. fn: function (){
  2398. var self=this;
  2399. return smalltalk.withContext(function($ctx1) {
  2400. self._assert_equals_("hello"._at_((1)),"h");
  2401. self._assert_equals_("hello"._at_((5)),"o");
  2402. self._assert_equals_("hello"._at_ifAbsent_((6),(function(){
  2403. return smalltalk.withContext(function($ctx2) {
  2404. return nil;
  2405. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),nil);
  2406. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.StringTest)})},
  2407. args: [],
  2408. 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",
  2409. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  2410. referencedClasses: []
  2411. }),
  2412. smalltalk.StringTest);
  2413. smalltalk.addMethod(
  2414. smalltalk.method({
  2415. selector: "testAtPut",
  2416. category: 'tests',
  2417. fn: function (){
  2418. var self=this;
  2419. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2420. return smalltalk.withContext(function($ctx1) {
  2421. self._should_raise_((function(){
  2422. return smalltalk.withContext(function($ctx2) {
  2423. return "hello"._at_put_((1),"a");
  2424. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2425. return self}, function($ctx1) {$ctx1.fill(self,"testAtPut",{},smalltalk.StringTest)})},
  2426. args: [],
  2427. source: "testAtPut\x0a\x09\x22String instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  2428. messageSends: ["should:raise:", "at:put:"],
  2429. referencedClasses: ["Error"]
  2430. }),
  2431. smalltalk.StringTest);
  2432. smalltalk.addMethod(
  2433. smalltalk.method({
  2434. selector: "testCapitalized",
  2435. category: 'tests',
  2436. fn: function (){
  2437. var self=this;
  2438. return smalltalk.withContext(function($ctx1) {
  2439. self._assert_equals_("test"._capitalized(),"Test");
  2440. self._assert_equals_("Test"._capitalized(),"Test");
  2441. self._assert_equals_(""._capitalized(),"");
  2442. self._assert_equals_("Test"._isCapitalized(),true);
  2443. self._assert_equals_("test"._isCapitalized(),false);
  2444. return self}, function($ctx1) {$ctx1.fill(self,"testCapitalized",{},smalltalk.StringTest)})},
  2445. args: [],
  2446. source: "testCapitalized\x0a\x09self assert: 'test' capitalized equals: 'Test'.\x0a\x09self assert: 'Test' capitalized equals: 'Test'.\x0a\x09self assert: '' capitalized equals: ''.\x0a\x09self assert: 'Test' isCapitalized equals: true.\x0a\x09self assert: 'test' isCapitalized equals: false.",
  2447. messageSends: ["assert:equals:", "capitalized", "isCapitalized"],
  2448. referencedClasses: []
  2449. }),
  2450. smalltalk.StringTest);
  2451. smalltalk.addMethod(
  2452. smalltalk.method({
  2453. selector: "testCharCodeAt",
  2454. category: 'tests',
  2455. fn: function (){
  2456. var self=this;
  2457. var s;
  2458. return smalltalk.withContext(function($ctx1) {
  2459. s="jackie";
  2460. self._assert_equals_("jackie"._charCodeAt_((1)),(106));
  2461. self._assert_equals_("jackie"._charCodeAt_((2)),(97));
  2462. self._assert_equals_("jackie"._charCodeAt_((3)),(99));
  2463. self._assert_equals_("jackie"._charCodeAt_((4)),(107));
  2464. self._assert_equals_("jackie"._charCodeAt_((5)),(105));
  2465. self._assert_equals_("jackie"._charCodeAt_((6)),(101));
  2466. return self}, function($ctx1) {$ctx1.fill(self,"testCharCodeAt",{s:s},smalltalk.StringTest)})},
  2467. args: [],
  2468. source: "testCharCodeAt\x0a\x09|s|\x0a\x09s := 'jackie'.\x0a\x09self assert: ('jackie' charCodeAt:1) equals: 106.\x0a\x09self assert: ('jackie' charCodeAt:2) equals: 97.\x0a\x09self assert: ('jackie' charCodeAt:3) equals: 99.\x0a\x09self assert: ('jackie' charCodeAt:4) equals: 107.\x0a\x09self assert: ('jackie' charCodeAt:5) equals: 105.\x0a\x09self assert: ('jackie' charCodeAt:6) equals: 101.",
  2469. messageSends: ["assert:equals:", "charCodeAt:"],
  2470. referencedClasses: []
  2471. }),
  2472. smalltalk.StringTest);
  2473. smalltalk.addMethod(
  2474. smalltalk.method({
  2475. selector: "testCollect",
  2476. category: 'tests',
  2477. fn: function (){
  2478. var self=this;
  2479. var newCollection;
  2480. return smalltalk.withContext(function($ctx1) {
  2481. newCollection="hheelllloo";
  2482. self._assertSameContents_as_(_st(self._collection())._collect_((function(each){
  2483. return smalltalk.withContext(function($ctx2) {
  2484. return _st(each).__comma(each);
  2485. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),newCollection);
  2486. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{newCollection:newCollection},smalltalk.StringTest)})},
  2487. args: [],
  2488. 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",
  2489. messageSends: ["assertSameContents:as:", "collect:", "collection", ","],
  2490. referencedClasses: []
  2491. }),
  2492. smalltalk.StringTest);
  2493. smalltalk.addMethod(
  2494. smalltalk.method({
  2495. selector: "testCopyFromTo",
  2496. category: 'tests',
  2497. fn: function (){
  2498. var self=this;
  2499. return smalltalk.withContext(function($ctx1) {
  2500. self._assert_equals_("jackie"._copyFrom_to_((1),(3)),"jac");
  2501. self._assert_equals_("jackie"._copyFrom_to_((4),(6)),"kie");
  2502. return self}, function($ctx1) {$ctx1.fill(self,"testCopyFromTo",{},smalltalk.StringTest)})},
  2503. args: [],
  2504. source: "testCopyFromTo\x0a\x09self assert: ('jackie' copyFrom: 1 to: 3) equals: 'jac'.\x0a\x09self assert: ('jackie' copyFrom: 4 to: 6) equals: 'kie'.",
  2505. messageSends: ["assert:equals:", "copyFrom:to:"],
  2506. referencedClasses: []
  2507. }),
  2508. smalltalk.StringTest);
  2509. smalltalk.addMethod(
  2510. smalltalk.method({
  2511. selector: "testCopyWithoutAll",
  2512. category: 'tests',
  2513. fn: function (){
  2514. var self=this;
  2515. return smalltalk.withContext(function($ctx1) {
  2516. self._assert_equals_("*hello* *world*"._copyWithoutAll_("*"),"hello world");
  2517. return self}, function($ctx1) {$ctx1.fill(self,"testCopyWithoutAll",{},smalltalk.StringTest)})},
  2518. args: [],
  2519. source: "testCopyWithoutAll\x0a\x09self\x0a\x09\x09assert: ('*hello* *world*' copyWithoutAll: '*')\x0a\x09\x09equals: 'hello world'",
  2520. messageSends: ["assert:equals:", "copyWithoutAll:"],
  2521. referencedClasses: []
  2522. }),
  2523. smalltalk.StringTest);
  2524. smalltalk.addMethod(
  2525. smalltalk.method({
  2526. selector: "testDetect",
  2527. category: 'tests',
  2528. fn: function (){
  2529. var self=this;
  2530. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2531. return smalltalk.withContext(function($ctx1) {
  2532. self._assert_equals_(_st(self._collection())._detect_((function(each){
  2533. return smalltalk.withContext(function($ctx2) {
  2534. return _st(each).__eq("h");
  2535. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),"h");
  2536. self._should_raise_((function(){
  2537. return smalltalk.withContext(function($ctx2) {
  2538. return _st(self._collection())._detect_((function(each){
  2539. return smalltalk.withContext(function($ctx3) {
  2540. return _st(each).__eq((6));
  2541. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,3)})}));
  2542. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$Error());
  2543. return self}, function($ctx1) {$ctx1.fill(self,"testDetect",{},smalltalk.StringTest)})},
  2544. args: [],
  2545. 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",
  2546. messageSends: ["assert:equals:", "detect:", "collection", "=", "should:raise:"],
  2547. referencedClasses: ["Error"]
  2548. }),
  2549. smalltalk.StringTest);
  2550. smalltalk.addMethod(
  2551. smalltalk.method({
  2552. selector: "testEquality",
  2553. category: 'tests',
  2554. fn: function (){
  2555. var self=this;
  2556. return smalltalk.withContext(function($ctx1) {
  2557. self._assert_equals_("hello","hello");
  2558. self._deny_("hello".__eq("world"));
  2559. self._deny_("hello".__eq([]._at_ifAbsent_((1),(function(){
  2560. return smalltalk.withContext(function($ctx2) {
  2561. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))));
  2562. self._assert_equals_("hello","hello"._yourself());
  2563. self._assert_equals_("hello"._yourself(),"hello");
  2564. self._deny_("".__eq((0)));
  2565. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.StringTest)})},
  2566. args: [],
  2567. 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",
  2568. messageSends: ["assert:equals:", "deny:", "=", "at:ifAbsent:", "yourself"],
  2569. referencedClasses: []
  2570. }),
  2571. smalltalk.StringTest);
  2572. smalltalk.addMethod(
  2573. smalltalk.method({
  2574. selector: "testIdentity",
  2575. category: 'tests',
  2576. fn: function (){
  2577. var self=this;
  2578. return smalltalk.withContext(function($ctx1) {
  2579. self._assert_("hello".__eq_eq("hello"));
  2580. self._deny_("hello".__eq_eq("world"));
  2581. self._assert_("hello".__eq_eq("hello"._yourself()));
  2582. self._assert_(_st("hello"._yourself()).__eq_eq("hello"));
  2583. self._deny_("".__eq_eq((0)));
  2584. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.StringTest)})},
  2585. args: [],
  2586. 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",
  2587. messageSends: ["assert:", "==", "deny:", "yourself"],
  2588. referencedClasses: []
  2589. }),
  2590. smalltalk.StringTest);
  2591. smalltalk.addMethod(
  2592. smalltalk.method({
  2593. selector: "testIdentityHash",
  2594. category: 'tests',
  2595. fn: function (){
  2596. var self=this;
  2597. return smalltalk.withContext(function($ctx1) {
  2598. self._assert_equals_("foo"._identityHash(),"foo"._identityHash());
  2599. self._deny_(_st("foo"._identityHash()).__eq("bar"._identityHash()));
  2600. return self}, function($ctx1) {$ctx1.fill(self,"testIdentityHash",{},smalltalk.StringTest)})},
  2601. args: [],
  2602. source: "testIdentityHash\x0a\x09self assert: 'foo' identityHash equals: 'foo' identityHash.\x0a\x09self deny: ('foo' identityHash = 'bar' identityHash)",
  2603. messageSends: ["assert:equals:", "identityHash", "deny:", "="],
  2604. referencedClasses: []
  2605. }),
  2606. smalltalk.StringTest);
  2607. smalltalk.addMethod(
  2608. smalltalk.method({
  2609. selector: "testIncludesSubString",
  2610. category: 'tests',
  2611. fn: function (){
  2612. var self=this;
  2613. return smalltalk.withContext(function($ctx1) {
  2614. self._assert_("amber"._includesSubString_("ber"));
  2615. self._deny_("amber"._includesSubString_("zork"));
  2616. return self}, function($ctx1) {$ctx1.fill(self,"testIncludesSubString",{},smalltalk.StringTest)})},
  2617. args: [],
  2618. source: "testIncludesSubString\x0a\x09self assert: ('amber' includesSubString: 'ber').\x0a\x09self deny: ('amber' includesSubString: 'zork').",
  2619. messageSends: ["assert:", "includesSubString:", "deny:"],
  2620. referencedClasses: []
  2621. }),
  2622. smalltalk.StringTest);
  2623. smalltalk.addMethod(
  2624. smalltalk.method({
  2625. selector: "testIndexOf",
  2626. category: 'tests',
  2627. fn: function (){
  2628. var self=this;
  2629. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2630. return smalltalk.withContext(function($ctx1) {
  2631. self._assert_equals_(_st(self._collection())._indexOf_("e"),(2));
  2632. self._should_raise_((function(){
  2633. return smalltalk.withContext(function($ctx2) {
  2634. return _st(self._collection())._indexOf_((999));
  2635. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2636. self._assert_equals_(_st(self._collection())._indexOf_ifAbsent_((999),(function(){
  2637. return smalltalk.withContext(function($ctx2) {
  2638. return "sentinel";
  2639. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"sentinel");
  2640. return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.StringTest)})},
  2641. args: [],
  2642. 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'",
  2643. messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
  2644. referencedClasses: ["Error"]
  2645. }),
  2646. smalltalk.StringTest);
  2647. smalltalk.addMethod(
  2648. smalltalk.method({
  2649. selector: "testIsVowel",
  2650. category: 'tests',
  2651. fn: function (){
  2652. var self=this;
  2653. var vowel,consonant;
  2654. return smalltalk.withContext(function($ctx1) {
  2655. vowel="u";
  2656. consonant="z";
  2657. self._assert_equals_(_st(vowel)._isVowel(),true);
  2658. self._assert_equals_(_st(consonant)._isVowel(),false);
  2659. return self}, function($ctx1) {$ctx1.fill(self,"testIsVowel",{vowel:vowel,consonant:consonant},smalltalk.StringTest)})},
  2660. args: [],
  2661. source: "testIsVowel\x0a |vowel consonant|\x0a vowel := 'u'.\x0a consonant := 'z'.\x0a self assert: vowel isVowel equals: true.\x0a self assert: consonant isVowel equals: false",
  2662. messageSends: ["assert:equals:", "isVowel"],
  2663. referencedClasses: []
  2664. }),
  2665. smalltalk.StringTest);
  2666. smalltalk.addMethod(
  2667. smalltalk.method({
  2668. selector: "testJoin",
  2669. category: 'tests',
  2670. fn: function (){
  2671. var self=this;
  2672. return smalltalk.withContext(function($ctx1) {
  2673. self._assert_equals_(","._join_(["hello", "world"]),"hello,world");
  2674. return self}, function($ctx1) {$ctx1.fill(self,"testJoin",{},smalltalk.StringTest)})},
  2675. args: [],
  2676. source: "testJoin\x0a\x09self assert: (',' join: #('hello' 'world')) equals: 'hello,world'",
  2677. messageSends: ["assert:equals:", "join:"],
  2678. referencedClasses: []
  2679. }),
  2680. smalltalk.StringTest);
  2681. smalltalk.addMethod(
  2682. smalltalk.method({
  2683. selector: "testReversed",
  2684. category: 'tests',
  2685. fn: function (){
  2686. var self=this;
  2687. return smalltalk.withContext(function($ctx1) {
  2688. self._assert_equals_("jackiechan"._reversed(),"nahceikcaj");
  2689. return self}, function($ctx1) {$ctx1.fill(self,"testReversed",{},smalltalk.StringTest)})},
  2690. args: [],
  2691. source: "testReversed\x0a\x09self assert: 'jackiechan' reversed equals: 'nahceikcaj'.",
  2692. messageSends: ["assert:equals:", "reversed"],
  2693. referencedClasses: []
  2694. }),
  2695. smalltalk.StringTest);
  2696. smalltalk.addMethod(
  2697. smalltalk.method({
  2698. selector: "testSelect",
  2699. category: 'tests',
  2700. fn: function (){
  2701. var self=this;
  2702. var newCollection;
  2703. return smalltalk.withContext(function($ctx1) {
  2704. newCollection="o";
  2705. self._assertSameContents_as_(_st(self._collection())._select_((function(each){
  2706. return smalltalk.withContext(function($ctx2) {
  2707. return _st(each).__eq("o");
  2708. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),newCollection);
  2709. return self}, function($ctx1) {$ctx1.fill(self,"testSelect",{newCollection:newCollection},smalltalk.StringTest)})},
  2710. args: [],
  2711. 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",
  2712. messageSends: ["assertSameContents:as:", "select:", "collection", "="],
  2713. referencedClasses: []
  2714. }),
  2715. smalltalk.StringTest);
  2716. smalltalk.addMethod(
  2717. smalltalk.method({
  2718. selector: "testSize",
  2719. category: 'tests',
  2720. fn: function (){
  2721. var self=this;
  2722. return smalltalk.withContext(function($ctx1) {
  2723. self._assert_equals_("smalltalk"._size(),(9));
  2724. self._assert_equals_(""._size(),(0));
  2725. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.StringTest)})},
  2726. args: [],
  2727. source: "testSize\x0a\x09self assert: 'smalltalk' size equals: 9.\x0a\x09self assert: '' size equals: 0",
  2728. messageSends: ["assert:equals:", "size"],
  2729. referencedClasses: []
  2730. }),
  2731. smalltalk.StringTest);
  2732. smalltalk.addMethod(
  2733. smalltalk.method({
  2734. selector: "testStreamContents",
  2735. category: 'tests',
  2736. fn: function (){
  2737. var self=this;
  2738. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2739. return smalltalk.withContext(function($ctx1) {
  2740. var $1,$2;
  2741. self._assert_equals_(_st($String())._streamContents_((function(aStream){
  2742. return smalltalk.withContext(function($ctx2) {
  2743. $1=aStream;
  2744. _st($1)._nextPutAll_("hello");
  2745. _st($1)._space();
  2746. $2=_st($1)._nextPutAll_("world");
  2747. return $2;
  2748. }, function($ctx2) {$ctx2.fillBlock({aStream:aStream},$ctx1,1)})})),"hello world");
  2749. return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StringTest)})},
  2750. args: [],
  2751. 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'",
  2752. messageSends: ["assert:equals:", "streamContents:", "nextPutAll:", "space"],
  2753. referencedClasses: ["String"]
  2754. }),
  2755. smalltalk.StringTest);
  2756. smalltalk.addMethod(
  2757. smalltalk.method({
  2758. selector: "testSubStrings",
  2759. category: 'tests',
  2760. fn: function (){
  2761. var self=this;
  2762. return smalltalk.withContext(function($ctx1) {
  2763. self._assert_equals_("jackiechan"._subStrings_("ie"),["jack", "chan"]);
  2764. return self}, function($ctx1) {$ctx1.fill(self,"testSubStrings",{},smalltalk.StringTest)})},
  2765. args: [],
  2766. source: "testSubStrings\x0a\x09self assert: ('jackiechan' subStrings: 'ie') equals: #( 'jack' 'chan' ).",
  2767. messageSends: ["assert:equals:", "subStrings:"],
  2768. referencedClasses: []
  2769. }),
  2770. smalltalk.StringTest);
  2771. smalltalk.addMethod(
  2772. smalltalk.method({
  2773. selector: "testTrim",
  2774. category: 'tests',
  2775. fn: function (){
  2776. var self=this;
  2777. return smalltalk.withContext(function($ctx1) {
  2778. self._assert_equals_(" jackie"._trimLeft(),"jackie");
  2779. self._assert_equals_("jackie "._trimRight(),"jackie");
  2780. return self}, function($ctx1) {$ctx1.fill(self,"testTrim",{},smalltalk.StringTest)})},
  2781. args: [],
  2782. source: "testTrim\x0a\x09self assert: ' jackie' trimLeft equals: 'jackie'.\x0a\x09self assert: 'jackie ' trimRight equals: 'jackie'.",
  2783. messageSends: ["assert:equals:", "trimLeft", "trimRight"],
  2784. referencedClasses: []
  2785. }),
  2786. smalltalk.StringTest);
  2787. smalltalk.addMethod(
  2788. smalltalk.method({
  2789. selector: "collectionClass",
  2790. category: 'accessing',
  2791. fn: function (){
  2792. var self=this;
  2793. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2794. return smalltalk.withContext(function($ctx1) {
  2795. var $1;
  2796. $1=$String();
  2797. return $1;
  2798. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringTest.klass)})},
  2799. args: [],
  2800. source: "collectionClass\x0a\x09^ String",
  2801. messageSends: [],
  2802. referencedClasses: ["String"]
  2803. }),
  2804. smalltalk.StringTest.klass);
  2805. smalltalk.addClass('ConsoleTranscriptTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2806. smalltalk.addMethod(
  2807. smalltalk.method({
  2808. selector: "testShow",
  2809. category: 'tests',
  2810. fn: function (){
  2811. var self=this;
  2812. var originalTranscript;
  2813. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  2814. function $ConsoleTranscript(){return smalltalk.ConsoleTranscript||(typeof ConsoleTranscript=="undefined"?nil:ConsoleTranscript)}
  2815. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2816. return smalltalk.withContext(function($ctx1) {
  2817. originalTranscript=_st($Transcript())._current();
  2818. _st($Transcript())._register_(_st($ConsoleTranscript())._new());
  2819. self._shouldnt_raise_((function(){
  2820. return smalltalk.withContext(function($ctx2) {
  2821. return _st($Transcript())._show_("Hello console!");
  2822. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2823. self._shouldnt_raise_((function(){
  2824. return smalltalk.withContext(function($ctx2) {
  2825. return _st($Transcript())._show_(console);
  2826. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$Error());
  2827. _st($Transcript())._register_(originalTranscript);
  2828. return self}, function($ctx1) {$ctx1.fill(self,"testShow",{originalTranscript:originalTranscript},smalltalk.ConsoleTranscriptTest)})},
  2829. args: [],
  2830. source: "testShow\x0a| originalTranscript |\x0aoriginalTranscript := Transcript current.\x0aTranscript register: ConsoleTranscript new.\x0a\x0aself shouldnt: [ Transcript show: 'Hello console!' ] raise: Error.\x0aself shouldnt: [ Transcript show: console ] raise: Error.\x0a\x0aTranscript register: originalTranscript.",
  2831. messageSends: ["current", "register:", "new", "shouldnt:raise:", "show:"],
  2832. referencedClasses: ["Transcript", "ConsoleTranscript", "Error"]
  2833. }),
  2834. smalltalk.ConsoleTranscriptTest);
  2835. smalltalk.addClass('JSObjectProxyTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2836. smalltalk.addMethod(
  2837. smalltalk.method({
  2838. selector: "jsObject",
  2839. category: 'accessing',
  2840. fn: function (){
  2841. var self=this;
  2842. return smalltalk.withContext(function($ctx1) {
  2843. return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null, 'f': void 0};
  2844. return self}, function($ctx1) {$ctx1.fill(self,"jsObject",{},smalltalk.JSObjectProxyTest)})},
  2845. args: [],
  2846. source: "jsObject\x0a\x09<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null, 'f': void 0}>",
  2847. messageSends: [],
  2848. referencedClasses: []
  2849. }),
  2850. smalltalk.JSObjectProxyTest);
  2851. smalltalk.addMethod(
  2852. smalltalk.method({
  2853. selector: "testAtIfAbsent",
  2854. category: 'tests',
  2855. fn: function (){
  2856. var self=this;
  2857. var testObject;
  2858. return smalltalk.withContext(function($ctx1) {
  2859. testObject=self._jsObject();
  2860. self._assert_equals_(_st(testObject)._at_ifAbsent_("abc",(function(){
  2861. return smalltalk.withContext(function($ctx2) {
  2862. return "Property does not exist";
  2863. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"Property does not exist");
  2864. self._assert_equals_(_st(testObject)._at_ifAbsent_("e",(function(){
  2865. return smalltalk.withContext(function($ctx2) {
  2866. return "Property does not exist";
  2867. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),nil);
  2868. self._assert_equals_(_st(testObject)._at_ifAbsent_("a",(function(){
  2869. return smalltalk.withContext(function($ctx2) {
  2870. return "Property does not exist";
  2871. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})})),(1));
  2872. self._assert_equals_(_st(testObject)._at_ifAbsent_("f",(function(){
  2873. return smalltalk.withContext(function($ctx2) {
  2874. return "Property does not exist";
  2875. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})})),nil);
  2876. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2877. args: [],
  2878. 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.",
  2879. messageSends: ["jsObject", "assert:equals:", "at:ifAbsent:"],
  2880. referencedClasses: []
  2881. }),
  2882. smalltalk.JSObjectProxyTest);
  2883. smalltalk.addMethod(
  2884. smalltalk.method({
  2885. selector: "testAtIfPresent",
  2886. category: 'tests',
  2887. fn: function (){
  2888. var self=this;
  2889. var testObject;
  2890. return smalltalk.withContext(function($ctx1) {
  2891. testObject=self._jsObject();
  2892. self._assert_equals_(_st(testObject)._at_ifPresent_("abc",(function(x){
  2893. return smalltalk.withContext(function($ctx2) {
  2894. return "hello ".__comma(_st(x)._asString());
  2895. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})})),nil);
  2896. self._assert_equals_(_st(testObject)._at_ifPresent_("e",(function(x){
  2897. return smalltalk.withContext(function($ctx2) {
  2898. return "hello ".__comma(_st(x)._asString());
  2899. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,2)})})),"hello nil");
  2900. self._assert_equals_(_st(testObject)._at_ifPresent_("a",(function(x){
  2901. return smalltalk.withContext(function($ctx2) {
  2902. return "hello ".__comma(_st(x)._asString());
  2903. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,3)})})),"hello 1");
  2904. self._assert_equals_(_st(testObject)._at_ifPresent_("f",(function(x){
  2905. return smalltalk.withContext(function($ctx2) {
  2906. return "hello ".__comma(_st(x)._asString());
  2907. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,4)})})),"hello nil");
  2908. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfPresent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2909. args: [],
  2910. 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'.",
  2911. messageSends: ["jsObject", "assert:equals:", "at:ifPresent:", ",", "asString"],
  2912. referencedClasses: []
  2913. }),
  2914. smalltalk.JSObjectProxyTest);
  2915. smalltalk.addMethod(
  2916. smalltalk.method({
  2917. selector: "testAtIfPresentIfAbsent",
  2918. category: 'tests',
  2919. fn: function (){
  2920. var self=this;
  2921. var testObject;
  2922. return smalltalk.withContext(function($ctx1) {
  2923. testObject=self._jsObject();
  2924. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("abc",(function(x){
  2925. return smalltalk.withContext(function($ctx2) {
  2926. return "hello ".__comma(_st(x)._asString());
  2927. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})}),(function(){
  2928. return smalltalk.withContext(function($ctx2) {
  2929. return "not present";
  2930. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"not present");
  2931. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("e",(function(x){
  2932. return smalltalk.withContext(function($ctx2) {
  2933. return "hello ".__comma(_st(x)._asString());
  2934. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,3)})}),(function(){
  2935. return smalltalk.withContext(function($ctx2) {
  2936. return "not present";
  2937. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})})),"hello nil");
  2938. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("a",(function(x){
  2939. return smalltalk.withContext(function($ctx2) {
  2940. return "hello ".__comma(_st(x)._asString());
  2941. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,5)})}),(function(){
  2942. return smalltalk.withContext(function($ctx2) {
  2943. return "not present";
  2944. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})})),"hello 1");
  2945. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("f",(function(x){
  2946. return smalltalk.withContext(function($ctx2) {
  2947. return "hello ".__comma(_st(x)._asString());
  2948. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,7)})}),(function(){
  2949. return smalltalk.withContext(function($ctx2) {
  2950. return "not present";
  2951. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,8)})})),"hello nil");
  2952. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfPresentIfAbsent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2953. args: [],
  2954. 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'.",
  2955. messageSends: ["jsObject", "assert:equals:", "at:ifPresent:ifAbsent:", ",", "asString"],
  2956. referencedClasses: []
  2957. }),
  2958. smalltalk.JSObjectProxyTest);
  2959. smalltalk.addMethod(
  2960. smalltalk.method({
  2961. selector: "testDNU",
  2962. category: 'tests',
  2963. fn: function (){
  2964. var self=this;
  2965. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  2966. return smalltalk.withContext(function($ctx1) {
  2967. self._should_raise_((function(){
  2968. return smalltalk.withContext(function($ctx2) {
  2969. return _st(self._jsObject())._foo();
  2970. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  2971. return self}, function($ctx1) {$ctx1.fill(self,"testDNU",{},smalltalk.JSObjectProxyTest)})},
  2972. args: [],
  2973. source: "testDNU\x0a\x09self should: [self jsObject foo] raise: MessageNotUnderstood",
  2974. messageSends: ["should:raise:", "foo", "jsObject"],
  2975. referencedClasses: ["MessageNotUnderstood"]
  2976. }),
  2977. smalltalk.JSObjectProxyTest);
  2978. smalltalk.addMethod(
  2979. smalltalk.method({
  2980. selector: "testMessageSend",
  2981. category: 'tests',
  2982. fn: function (){
  2983. var self=this;
  2984. return smalltalk.withContext(function($ctx1) {
  2985. self._assert_equals_(_st(self._jsObject())._a(),(1));
  2986. self._assert_equals_(_st(self._jsObject())._b(),(2));
  2987. self._assert_equals_(_st(self._jsObject())._c_((3)),(3));
  2988. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.JSObjectProxyTest)})},
  2989. args: [],
  2990. 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",
  2991. messageSends: ["assert:equals:", "a", "jsObject", "b", "c:"],
  2992. referencedClasses: []
  2993. }),
  2994. smalltalk.JSObjectProxyTest);
  2995. smalltalk.addMethod(
  2996. smalltalk.method({
  2997. selector: "testMethodWithArguments",
  2998. category: 'tests',
  2999. fn: function (){
  3000. var self=this;
  3001. return smalltalk.withContext(function($ctx1) {
  3002. self._assert_equals_(_st(self._jsObject())._c_((1)),(1));
  3003. return self}, function($ctx1) {$ctx1.fill(self,"testMethodWithArguments",{},smalltalk.JSObjectProxyTest)})},
  3004. args: [],
  3005. source: "testMethodWithArguments\x0a\x09self assert: (self jsObject c: 1) equals: 1",
  3006. messageSends: ["assert:equals:", "c:", "jsObject"],
  3007. referencedClasses: []
  3008. }),
  3009. smalltalk.JSObjectProxyTest);
  3010. smalltalk.addMethod(
  3011. smalltalk.method({
  3012. selector: "testPrinting",
  3013. category: 'tests',
  3014. fn: function (){
  3015. var self=this;
  3016. return smalltalk.withContext(function($ctx1) {
  3017. self._assert_equals_(_st(self._jsObject())._printString(),"[object Object]");
  3018. return self}, function($ctx1) {$ctx1.fill(self,"testPrinting",{},smalltalk.JSObjectProxyTest)})},
  3019. args: [],
  3020. source: "testPrinting\x0a\x09self assert: self jsObject printString equals: '[object Object]'",
  3021. messageSends: ["assert:equals:", "printString", "jsObject"],
  3022. referencedClasses: []
  3023. }),
  3024. smalltalk.JSObjectProxyTest);
  3025. smalltalk.addMethod(
  3026. smalltalk.method({
  3027. selector: "testPropertyThatReturnsEmptyString",
  3028. category: 'tests',
  3029. fn: function (){
  3030. var self=this;
  3031. var object;
  3032. return smalltalk.withContext(function($ctx1) {
  3033. object=self._jsObject();
  3034. self._assert_equals_(_st(object)._d(),"");
  3035. _st(object)._d_("hello");
  3036. self._assert_equals_(_st(object)._d(),"hello");
  3037. return self}, function($ctx1) {$ctx1.fill(self,"testPropertyThatReturnsEmptyString",{object:object},smalltalk.JSObjectProxyTest)})},
  3038. args: [],
  3039. 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'",
  3040. messageSends: ["jsObject", "assert:equals:", "d", "d:"],
  3041. referencedClasses: []
  3042. }),
  3043. smalltalk.JSObjectProxyTest);
  3044. smalltalk.addMethod(
  3045. smalltalk.method({
  3046. selector: "testPropertyThatReturnsUndefined",
  3047. category: 'tests',
  3048. fn: function (){
  3049. var self=this;
  3050. var object;
  3051. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3052. return smalltalk.withContext(function($ctx1) {
  3053. object=self._jsObject();
  3054. self._shouldnt_raise_((function(){
  3055. return smalltalk.withContext(function($ctx2) {
  3056. return _st(object)._e();
  3057. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3058. self._assert_(_st(_st(object)._e())._isNil());
  3059. return self}, function($ctx1) {$ctx1.fill(self,"testPropertyThatReturnsUndefined",{object:object},smalltalk.JSObjectProxyTest)})},
  3060. args: [],
  3061. source: "testPropertyThatReturnsUndefined\x0a\x09| object |\x0a\x0a\x09object := self jsObject.\x0a\x09self shouldnt: [ object e ] raise: MessageNotUnderstood.\x0a\x09self assert: object e isNil",
  3062. messageSends: ["jsObject", "shouldnt:raise:", "e", "assert:", "isNil"],
  3063. referencedClasses: ["MessageNotUnderstood"]
  3064. }),
  3065. smalltalk.JSObjectProxyTest);
  3066. smalltalk.addMethod(
  3067. smalltalk.method({
  3068. selector: "testValue",
  3069. category: 'tests',
  3070. fn: function (){
  3071. var self=this;
  3072. var testObject;
  3073. return smalltalk.withContext(function($ctx1) {
  3074. testObject=self._jsObject();
  3075. self._assert_equals_(_st(_st(testObject)._value())._printString(),"[object Object]");
  3076. _st(testObject)._at_put_("value","aValue");
  3077. self._assert_equals_(_st(testObject)._value(),"aValue");
  3078. return self}, function($ctx1) {$ctx1.fill(self,"testValue",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  3079. args: [],
  3080. 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'",
  3081. messageSends: ["jsObject", "assert:equals:", "printString", "value", "at:put:"],
  3082. referencedClasses: []
  3083. }),
  3084. smalltalk.JSObjectProxyTest);
  3085. smalltalk.addMethod(
  3086. smalltalk.method({
  3087. selector: "testYourself",
  3088. category: 'tests',
  3089. fn: function (){
  3090. var self=this;
  3091. var object;
  3092. return smalltalk.withContext(function($ctx1) {
  3093. var $1,$2;
  3094. $1=self._jsObject();
  3095. _st($1)._d_("test");
  3096. $2=_st($1)._yourself();
  3097. object=$2;
  3098. self._assert_equals_(_st(object)._d(),"test");
  3099. return self}, function($ctx1) {$ctx1.fill(self,"testYourself",{object:object},smalltalk.JSObjectProxyTest)})},
  3100. args: [],
  3101. source: "testYourself\x0a\x09| object |\x0a\x09object := self jsObject\x0a\x09\x09d: 'test';\x0a\x09\x09yourself.\x0a\x0a\x09self assert: object d equals: 'test'",
  3102. messageSends: ["d:", "jsObject", "yourself", "assert:equals:", "d"],
  3103. referencedClasses: []
  3104. }),
  3105. smalltalk.JSObjectProxyTest);
  3106. smalltalk.addClass('JavaScriptExceptionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3107. smalltalk.addMethod(
  3108. smalltalk.method({
  3109. selector: "testCatchingException",
  3110. category: 'tests',
  3111. fn: function (){
  3112. var self=this;
  3113. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3114. return smalltalk.withContext(function($ctx1) {
  3115. _st((function(){
  3116. return smalltalk.withContext(function($ctx2) {
  3117. return self._throwException();
  3118. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(error){
  3119. return smalltalk.withContext(function($ctx2) {
  3120. return self._assert_(_st(_st(error)._exception()).__eq("test"));
  3121. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)})}));
  3122. return self}, function($ctx1) {$ctx1.fill(self,"testCatchingException",{},smalltalk.JavaScriptExceptionTest)})},
  3123. args: [],
  3124. source: "testCatchingException\x0a\x09[ self throwException ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :error |\x0a\x09\x09\x09self assert: error exception = 'test' ]",
  3125. messageSends: ["on:do:", "throwException", "assert:", "=", "exception"],
  3126. referencedClasses: ["Error"]
  3127. }),
  3128. smalltalk.JavaScriptExceptionTest);
  3129. smalltalk.addMethod(
  3130. smalltalk.method({
  3131. selector: "testRaisingException",
  3132. category: 'tests',
  3133. fn: function (){
  3134. var self=this;
  3135. function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
  3136. return smalltalk.withContext(function($ctx1) {
  3137. self._should_raise_((function(){
  3138. return smalltalk.withContext(function($ctx2) {
  3139. return self._throwException();
  3140. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$JavaScriptException());
  3141. return self}, function($ctx1) {$ctx1.fill(self,"testRaisingException",{},smalltalk.JavaScriptExceptionTest)})},
  3142. args: [],
  3143. source: "testRaisingException\x0a\x09self should: [ self throwException ] raise: JavaScriptException",
  3144. messageSends: ["should:raise:", "throwException"],
  3145. referencedClasses: ["JavaScriptException"]
  3146. }),
  3147. smalltalk.JavaScriptExceptionTest);
  3148. smalltalk.addMethod(
  3149. smalltalk.method({
  3150. selector: "throwException",
  3151. category: 'helpers',
  3152. fn: function (){
  3153. var self=this;
  3154. return smalltalk.withContext(function($ctx1) {
  3155. throw 'test';
  3156. return self}, function($ctx1) {$ctx1.fill(self,"throwException",{},smalltalk.JavaScriptExceptionTest)})},
  3157. args: [],
  3158. source: "throwException\x0a\x09<throw 'test'>",
  3159. messageSends: [],
  3160. referencedClasses: []
  3161. }),
  3162. smalltalk.JavaScriptExceptionTest);
  3163. smalltalk.addClass('MessageSendTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3164. smalltalk.addMethod(
  3165. smalltalk.method({
  3166. selector: "testValue",
  3167. category: 'tests',
  3168. fn: function (){
  3169. var self=this;
  3170. var messageSend;
  3171. function $MessageSend(){return smalltalk.MessageSend||(typeof MessageSend=="undefined"?nil:MessageSend)}
  3172. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3173. return smalltalk.withContext(function($ctx1) {
  3174. var $1,$2;
  3175. $1=_st($MessageSend())._new();
  3176. _st($1)._receiver_(_st($Object())._new());
  3177. _st($1)._selector_("asString");
  3178. $2=_st($1)._yourself();
  3179. messageSend=$2;
  3180. self._assert_equals_(_st(messageSend)._value(),"an Object");
  3181. return self}, function($ctx1) {$ctx1.fill(self,"testValue",{messageSend:messageSend},smalltalk.MessageSendTest)})},
  3182. args: [],
  3183. source: "testValue\x0a\x09| messageSend |\x0a\x09\x0a\x09messageSend := MessageSend new\x0a\x09\x09receiver: Object new;\x0a\x09\x09selector: #asString;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09self assert: messageSend value equals: 'an Object'",
  3184. messageSends: ["receiver:", "new", "selector:", "yourself", "assert:equals:", "value"],
  3185. referencedClasses: ["MessageSend", "Object"]
  3186. }),
  3187. smalltalk.MessageSendTest);
  3188. smalltalk.addMethod(
  3189. smalltalk.method({
  3190. selector: "testValueWithArguments",
  3191. category: 'tests',
  3192. fn: function (){
  3193. var self=this;
  3194. var messageSend;
  3195. function $MessageSend(){return smalltalk.MessageSend||(typeof MessageSend=="undefined"?nil:MessageSend)}
  3196. return smalltalk.withContext(function($ctx1) {
  3197. var $1,$2;
  3198. $1=_st($MessageSend())._new();
  3199. _st($1)._receiver_((2));
  3200. _st($1)._selector_("+");
  3201. $2=_st($1)._yourself();
  3202. messageSend=$2;
  3203. self._assert_equals_(_st(messageSend)._value_((3)),(5));
  3204. self._assert_equals_(_st(messageSend)._valueWithPossibleArguments_([(4)]),(6));
  3205. return self}, function($ctx1) {$ctx1.fill(self,"testValueWithArguments",{messageSend:messageSend},smalltalk.MessageSendTest)})},
  3206. args: [],
  3207. source: "testValueWithArguments\x0a\x09| messageSend |\x0a\x09\x0a\x09messageSend := MessageSend new\x0a\x09\x09receiver: 2;\x0a\x09\x09selector: '+';\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09self assert: (messageSend value: 3) equals: 5.\x0a\x09\x0a\x09self assert: (messageSend valueWithPossibleArguments: #(4)) equals: 6",
  3208. messageSends: ["receiver:", "new", "selector:", "yourself", "assert:equals:", "value:", "valueWithPossibleArguments:"],
  3209. referencedClasses: ["MessageSend"]
  3210. }),
  3211. smalltalk.MessageSendTest);
  3212. smalltalk.addClass('MethodInheritanceTest', smalltalk.TestCase, ['receiverTop', 'receiverMiddle', 'receiverBottom', 'method', 'performBlock'], 'Kernel-Tests');
  3213. smalltalk.addMethod(
  3214. smalltalk.method({
  3215. selector: "codeGeneratorClass",
  3216. category: 'accessing',
  3217. fn: function (){
  3218. var self=this;
  3219. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  3220. return smalltalk.withContext(function($ctx1) {
  3221. var $1;
  3222. $1=$CodeGenerator();
  3223. return $1;
  3224. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.MethodInheritanceTest)})},
  3225. args: [],
  3226. source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
  3227. messageSends: [],
  3228. referencedClasses: ["CodeGenerator"]
  3229. }),
  3230. smalltalk.MethodInheritanceTest);
  3231. smalltalk.addMethod(
  3232. smalltalk.method({
  3233. selector: "compiler",
  3234. category: 'factory',
  3235. fn: function (){
  3236. var self=this;
  3237. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  3238. return smalltalk.withContext(function($ctx1) {
  3239. var $2,$3,$1;
  3240. $2=_st($Compiler())._new();
  3241. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  3242. $3=_st($2)._yourself();
  3243. $1=$3;
  3244. return $1;
  3245. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.MethodInheritanceTest)})},
  3246. args: [],
  3247. source: "compiler\x0a\x09^ Compiler new\x0a\x09\x09codeGeneratorClass: self codeGeneratorClass;\x0a\x09\x09yourself",
  3248. messageSends: ["codeGeneratorClass:", "new", "codeGeneratorClass", "yourself"],
  3249. referencedClasses: ["Compiler"]
  3250. }),
  3251. smalltalk.MethodInheritanceTest);
  3252. smalltalk.addMethod(
  3253. smalltalk.method({
  3254. selector: "deinstallBottom",
  3255. category: 'testing',
  3256. fn: function (){
  3257. var self=this;
  3258. return smalltalk.withContext(function($ctx1) {
  3259. _st(self._targetClassBottom())._removeCompiledMethod_(self["@method"]);
  3260. return self}, function($ctx1) {$ctx1.fill(self,"deinstallBottom",{},smalltalk.MethodInheritanceTest)})},
  3261. args: [],
  3262. source: "deinstallBottom\x0a\x09self targetClassBottom removeCompiledMethod: method",
  3263. messageSends: ["removeCompiledMethod:", "targetClassBottom"],
  3264. referencedClasses: []
  3265. }),
  3266. smalltalk.MethodInheritanceTest);
  3267. smalltalk.addMethod(
  3268. smalltalk.method({
  3269. selector: "deinstallMiddle",
  3270. category: 'testing',
  3271. fn: function (){
  3272. var self=this;
  3273. return smalltalk.withContext(function($ctx1) {
  3274. _st(self._targetClassMiddle())._removeCompiledMethod_(self["@method"]);
  3275. return self}, function($ctx1) {$ctx1.fill(self,"deinstallMiddle",{},smalltalk.MethodInheritanceTest)})},
  3276. args: [],
  3277. source: "deinstallMiddle\x0a\x09self targetClassMiddle removeCompiledMethod: method",
  3278. messageSends: ["removeCompiledMethod:", "targetClassMiddle"],
  3279. referencedClasses: []
  3280. }),
  3281. smalltalk.MethodInheritanceTest);
  3282. smalltalk.addMethod(
  3283. smalltalk.method({
  3284. selector: "deinstallTop",
  3285. category: 'testing',
  3286. fn: function (){
  3287. var self=this;
  3288. return smalltalk.withContext(function($ctx1) {
  3289. _st(self._targetClassTop())._removeCompiledMethod_(self["@method"]);
  3290. return self}, function($ctx1) {$ctx1.fill(self,"deinstallTop",{},smalltalk.MethodInheritanceTest)})},
  3291. args: [],
  3292. source: "deinstallTop\x0a\x09self targetClassTop removeCompiledMethod: method",
  3293. messageSends: ["removeCompiledMethod:", "targetClassTop"],
  3294. referencedClasses: []
  3295. }),
  3296. smalltalk.MethodInheritanceTest);
  3297. smalltalk.addMethod(
  3298. smalltalk.method({
  3299. selector: "installBottom:",
  3300. category: 'testing',
  3301. fn: function (aString){
  3302. var self=this;
  3303. return smalltalk.withContext(function($ctx1) {
  3304. self["@method"]=_st(self._compiler())._install_forClass_category_(aString,self._targetClassBottom(),"tests");
  3305. return self}, function($ctx1) {$ctx1.fill(self,"installBottom:",{aString:aString},smalltalk.MethodInheritanceTest)})},
  3306. args: ["aString"],
  3307. source: "installBottom: aString\x0a\x09method := self compiler install: aString forClass: self targetClassBottom category: 'tests'",
  3308. messageSends: ["install:forClass:category:", "compiler", "targetClassBottom"],
  3309. referencedClasses: []
  3310. }),
  3311. smalltalk.MethodInheritanceTest);
  3312. smalltalk.addMethod(
  3313. smalltalk.method({
  3314. selector: "installMiddle:",
  3315. category: 'testing',
  3316. fn: function (aString){
  3317. var self=this;
  3318. return smalltalk.withContext(function($ctx1) {
  3319. self["@method"]=_st(self._compiler())._install_forClass_category_(aString,self._targetClassMiddle(),"tests");
  3320. return self}, function($ctx1) {$ctx1.fill(self,"installMiddle:",{aString:aString},smalltalk.MethodInheritanceTest)})},
  3321. args: ["aString"],
  3322. source: "installMiddle: aString\x0a\x09method := self compiler install: aString forClass: self targetClassMiddle category: 'tests'",
  3323. messageSends: ["install:forClass:category:", "compiler", "targetClassMiddle"],
  3324. referencedClasses: []
  3325. }),
  3326. smalltalk.MethodInheritanceTest);
  3327. smalltalk.addMethod(
  3328. smalltalk.method({
  3329. selector: "installTop:",
  3330. category: 'testing',
  3331. fn: function (aString){
  3332. var self=this;
  3333. return smalltalk.withContext(function($ctx1) {
  3334. self["@method"]=_st(self._compiler())._install_forClass_category_(aString,self._targetClassTop(),"tests");
  3335. return self}, function($ctx1) {$ctx1.fill(self,"installTop:",{aString:aString},smalltalk.MethodInheritanceTest)})},
  3336. args: ["aString"],
  3337. source: "installTop: aString\x0a\x09method := self compiler install: aString forClass: self targetClassTop category: 'tests'",
  3338. messageSends: ["install:forClass:category:", "compiler", "targetClassTop"],
  3339. referencedClasses: []
  3340. }),
  3341. smalltalk.MethodInheritanceTest);
  3342. smalltalk.addMethod(
  3343. smalltalk.method({
  3344. selector: "setUp",
  3345. category: 'initialization',
  3346. fn: function (){
  3347. var self=this;
  3348. return smalltalk.withContext(function($ctx1) {
  3349. self["@receiverTop"]=_st(self._targetClassTop())._new();
  3350. self["@receiverMiddle"]=_st(self._targetClassMiddle())._new();
  3351. self["@receiverBottom"]=_st(self._targetClassBottom())._new();
  3352. self["@method"]=nil;
  3353. self["@performBlock"]=(function(){
  3354. return smalltalk.withContext(function($ctx2) {
  3355. return self._error_("performBlock not initialized");
  3356. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})});
  3357. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.MethodInheritanceTest)})},
  3358. args: [],
  3359. source: "setUp\x0a\x09receiverTop := self targetClassTop new.\x0a\x09receiverMiddle := self targetClassMiddle new.\x0a\x09receiverBottom := self targetClassBottom new.\x0a\x09method := nil.\x0a\x09performBlock := [ self error: 'performBlock not initialized' ]",
  3360. messageSends: ["new", "targetClassTop", "targetClassMiddle", "targetClassBottom", "error:"],
  3361. referencedClasses: []
  3362. }),
  3363. smalltalk.MethodInheritanceTest);
  3364. smalltalk.addMethod(
  3365. smalltalk.method({
  3366. selector: "shouldMNU",
  3367. category: 'testing',
  3368. fn: function (){
  3369. var self=this;
  3370. return smalltalk.withContext(function($ctx1) {
  3371. self._shouldMNUTop();
  3372. self._shouldMNUMiddle();
  3373. self._shouldMNUBottom();
  3374. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNU",{},smalltalk.MethodInheritanceTest)})},
  3375. args: [],
  3376. source: "shouldMNU\x0a\x09self shouldMNUTop.\x0a\x09self shouldMNUMiddle.\x0a\x09self shouldMNUBottom",
  3377. messageSends: ["shouldMNUTop", "shouldMNUMiddle", "shouldMNUBottom"],
  3378. referencedClasses: []
  3379. }),
  3380. smalltalk.MethodInheritanceTest);
  3381. smalltalk.addMethod(
  3382. smalltalk.method({
  3383. selector: "shouldMNUBottom",
  3384. category: 'testing',
  3385. fn: function (){
  3386. var self=this;
  3387. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3388. return smalltalk.withContext(function($ctx1) {
  3389. self._should_raise_((function(){
  3390. return smalltalk.withContext(function($ctx2) {
  3391. return _st(self["@performBlock"])._value_(self["@receiverBottom"]);
  3392. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3393. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNUBottom",{},smalltalk.MethodInheritanceTest)})},
  3394. args: [],
  3395. source: "shouldMNUBottom\x0a\x09self should: [ performBlock value: receiverBottom ] raise: MessageNotUnderstood",
  3396. messageSends: ["should:raise:", "value:"],
  3397. referencedClasses: ["MessageNotUnderstood"]
  3398. }),
  3399. smalltalk.MethodInheritanceTest);
  3400. smalltalk.addMethod(
  3401. smalltalk.method({
  3402. selector: "shouldMNUMiddle",
  3403. category: 'testing',
  3404. fn: function (){
  3405. var self=this;
  3406. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3407. return smalltalk.withContext(function($ctx1) {
  3408. self._should_raise_((function(){
  3409. return smalltalk.withContext(function($ctx2) {
  3410. return _st(self["@performBlock"])._value_(self["@receiverMiddle"]);
  3411. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3412. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNUMiddle",{},smalltalk.MethodInheritanceTest)})},
  3413. args: [],
  3414. source: "shouldMNUMiddle\x0a\x09self should: [ performBlock value: receiverMiddle ] raise: MessageNotUnderstood",
  3415. messageSends: ["should:raise:", "value:"],
  3416. referencedClasses: ["MessageNotUnderstood"]
  3417. }),
  3418. smalltalk.MethodInheritanceTest);
  3419. smalltalk.addMethod(
  3420. smalltalk.method({
  3421. selector: "shouldMNUTop",
  3422. category: 'testing',
  3423. fn: function (){
  3424. var self=this;
  3425. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3426. return smalltalk.withContext(function($ctx1) {
  3427. self._should_raise_((function(){
  3428. return smalltalk.withContext(function($ctx2) {
  3429. return _st(self["@performBlock"])._value_(self["@receiverTop"]);
  3430. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3431. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNUTop",{},smalltalk.MethodInheritanceTest)})},
  3432. args: [],
  3433. source: "shouldMNUTop\x0a\x09self should: [ performBlock value: receiverTop ] raise: MessageNotUnderstood",
  3434. messageSends: ["should:raise:", "value:"],
  3435. referencedClasses: ["MessageNotUnderstood"]
  3436. }),
  3437. smalltalk.MethodInheritanceTest);
  3438. smalltalk.addMethod(
  3439. smalltalk.method({
  3440. selector: "shouldReturn:",
  3441. category: 'testing',
  3442. fn: function (anObject){
  3443. var self=this;
  3444. var result;
  3445. return smalltalk.withContext(function($ctx1) {
  3446. result=_st(self["@performBlock"])._value_(self["@receiverTop"]);
  3447. self._assert_equals_(["top",anObject],["top",result]);
  3448. result=_st(self["@performBlock"])._value_(self["@receiverMiddle"]);
  3449. self._assert_equals_(["middle",anObject],["middle",result]);
  3450. result=_st(self["@performBlock"])._value_(self["@receiverBottom"]);
  3451. self._assert_equals_(["bottom",anObject],["bottom",result]);
  3452. return self}, function($ctx1) {$ctx1.fill(self,"shouldReturn:",{anObject:anObject,result:result},smalltalk.MethodInheritanceTest)})},
  3453. args: ["anObject"],
  3454. source: "shouldReturn: anObject\x0a\x09| result |\x0a\x0a\x09result := performBlock value: receiverTop.\x0a\x09self assert: { 'top'. anObject } equals: { 'top'. result }.\x0a\x09result := performBlock value: receiverMiddle.\x0a\x09self assert: { 'middle'. anObject } equals: { 'middle'. result }.\x0a\x09result := performBlock value: receiverBottom.\x0a\x09self assert: { 'bottom'. anObject } equals: { 'bottom'. result }",
  3455. messageSends: ["value:", "assert:equals:"],
  3456. referencedClasses: []
  3457. }),
  3458. smalltalk.MethodInheritanceTest);
  3459. smalltalk.addMethod(
  3460. smalltalk.method({
  3461. selector: "shouldReturn:and:and:",
  3462. category: 'testing',
  3463. fn: function (anObject,anObject2,anObject3){
  3464. var self=this;
  3465. var result;
  3466. return smalltalk.withContext(function($ctx1) {
  3467. result=_st(self["@performBlock"])._value_(self["@receiverTop"]);
  3468. self._assert_equals_(["top",anObject],["top",result]);
  3469. result=_st(self["@performBlock"])._value_(self["@receiverMiddle"]);
  3470. self._assert_equals_(["middle",anObject2],["middle",result]);
  3471. result=_st(self["@performBlock"])._value_(self["@receiverBottom"]);
  3472. self._assert_equals_(["bottom",anObject3],["bottom",result]);
  3473. return self}, function($ctx1) {$ctx1.fill(self,"shouldReturn:and:and:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3,result:result},smalltalk.MethodInheritanceTest)})},
  3474. args: ["anObject", "anObject2", "anObject3"],
  3475. source: "shouldReturn: anObject and: anObject2 and: anObject3\x0a\x09| result |\x0a\x0a\x09result := performBlock value: receiverTop.\x0a\x09self assert: { 'top'. anObject } equals: { 'top'. result }.\x0a\x09result := performBlock value: receiverMiddle.\x0a\x09self assert: { 'middle'. anObject2 } equals: { 'middle'. result }.\x0a\x09result := performBlock value: receiverBottom.\x0a\x09self assert: { 'bottom'. anObject3 } equals: { 'bottom'. result }",
  3476. messageSends: ["value:", "assert:equals:"],
  3477. referencedClasses: []
  3478. }),
  3479. smalltalk.MethodInheritanceTest);
  3480. smalltalk.addMethod(
  3481. smalltalk.method({
  3482. selector: "targetClassBottom",
  3483. category: 'accessing',
  3484. fn: function (){
  3485. var self=this;
  3486. function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
  3487. return smalltalk.withContext(function($ctx1) {
  3488. var $1;
  3489. $1=$JavaScriptException();
  3490. return $1;
  3491. }, function($ctx1) {$ctx1.fill(self,"targetClassBottom",{},smalltalk.MethodInheritanceTest)})},
  3492. args: [],
  3493. source: "targetClassBottom\x0a\x09^ JavaScriptException",
  3494. messageSends: [],
  3495. referencedClasses: ["JavaScriptException"]
  3496. }),
  3497. smalltalk.MethodInheritanceTest);
  3498. smalltalk.addMethod(
  3499. smalltalk.method({
  3500. selector: "targetClassMiddle",
  3501. category: 'accessing',
  3502. fn: function (){
  3503. var self=this;
  3504. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3505. return smalltalk.withContext(function($ctx1) {
  3506. var $1;
  3507. $1=$Error();
  3508. return $1;
  3509. }, function($ctx1) {$ctx1.fill(self,"targetClassMiddle",{},smalltalk.MethodInheritanceTest)})},
  3510. args: [],
  3511. source: "targetClassMiddle\x0a\x09^ Error",
  3512. messageSends: [],
  3513. referencedClasses: ["Error"]
  3514. }),
  3515. smalltalk.MethodInheritanceTest);
  3516. smalltalk.addMethod(
  3517. smalltalk.method({
  3518. selector: "targetClassTop",
  3519. category: 'accessing',
  3520. fn: function (){
  3521. var self=this;
  3522. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3523. return smalltalk.withContext(function($ctx1) {
  3524. var $1;
  3525. $1=$Object();
  3526. return $1;
  3527. }, function($ctx1) {$ctx1.fill(self,"targetClassTop",{},smalltalk.MethodInheritanceTest)})},
  3528. args: [],
  3529. source: "targetClassTop\x0a\x09^ Object",
  3530. messageSends: [],
  3531. referencedClasses: ["Object"]
  3532. }),
  3533. smalltalk.MethodInheritanceTest);
  3534. smalltalk.addMethod(
  3535. smalltalk.method({
  3536. selector: "tearDown",
  3537. category: 'initialization',
  3538. fn: function (){
  3539. var self=this;
  3540. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3541. return smalltalk.withContext(function($ctx1) {
  3542. _st((function(){
  3543. return smalltalk.withContext(function($ctx2) {
  3544. return self._deinstallTop();
  3545. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(){
  3546. return smalltalk.withContext(function($ctx2) {
  3547. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  3548. _st((function(){
  3549. return smalltalk.withContext(function($ctx2) {
  3550. return self._deinstallMiddle();
  3551. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}))._on_do_($Error(),(function(){
  3552. return smalltalk.withContext(function($ctx2) {
  3553. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
  3554. _st((function(){
  3555. return smalltalk.withContext(function($ctx2) {
  3556. return self._deinstallBottom();
  3557. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}))._on_do_($Error(),(function(){
  3558. return smalltalk.withContext(function($ctx2) {
  3559. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}));
  3560. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.MethodInheritanceTest)})},
  3561. args: [],
  3562. source: "tearDown\x0a\x09[ self deinstallTop ] on: Error do: [].\x0a\x09[ self deinstallMiddle ] on: Error do: [].\x0a\x09[ self deinstallBottom ] on: Error do: []",
  3563. messageSends: ["on:do:", "deinstallTop", "deinstallMiddle", "deinstallBottom"],
  3564. referencedClasses: ["Error"]
  3565. }),
  3566. smalltalk.MethodInheritanceTest);
  3567. smalltalk.addMethod(
  3568. smalltalk.method({
  3569. selector: "testMNU11",
  3570. category: 'tests',
  3571. fn: function (){
  3572. var self=this;
  3573. return smalltalk.withContext(function($ctx1) {
  3574. self["@performBlock"]=(function(x){
  3575. return smalltalk.withContext(function($ctx2) {
  3576. return _st(x)._foo();
  3577. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})});
  3578. self._shouldMNU();
  3579. self._installTop_("foo ^ false");
  3580. self._installTop_("foo ^ true");
  3581. self._deinstallTop();
  3582. self._shouldMNU();
  3583. return self}, function($ctx1) {$ctx1.fill(self,"testMNU11",{},smalltalk.MethodInheritanceTest)})},
  3584. args: [],
  3585. source: "testMNU11\x0a\x09performBlock := [ :x | x foo ].\x0a\x09self shouldMNU.\x0a\x09self installTop: 'foo ^ false'.\x0a\x09self installTop: 'foo ^ true'.\x0a\x09self deinstallTop.\x0a\x09self shouldMNU",
  3586. messageSends: ["foo", "shouldMNU", "installTop:", "deinstallTop"],
  3587. referencedClasses: []
  3588. }),
  3589. smalltalk.MethodInheritanceTest);
  3590. smalltalk.addMethod(
  3591. smalltalk.method({
  3592. selector: "testMNU22",
  3593. category: 'tests',
  3594. fn: function (){
  3595. var self=this;
  3596. return smalltalk.withContext(function($ctx1) {
  3597. self["@performBlock"]=(function(x){
  3598. return smalltalk.withContext(function($ctx2) {
  3599. return _st(x)._foo();
  3600. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})});
  3601. self._shouldMNU();
  3602. self._installMiddle_("foo ^ false");
  3603. self._installMiddle_("foo ^ true");
  3604. self._deinstallMiddle();
  3605. self._shouldMNU();
  3606. return self}, function($ctx1) {$ctx1.fill(self,"testMNU22",{},smalltalk.MethodInheritanceTest)})},
  3607. args: [],
  3608. source: "testMNU22\x0a\x09performBlock := [ :x | x foo ].\x0a\x09self shouldMNU.\x0a\x09self installMiddle: 'foo ^ false'.\x0a\x09self installMiddle: 'foo ^ true'.\x0a\x09self deinstallMiddle.\x0a\x09self shouldMNU",
  3609. messageSends: ["foo", "shouldMNU", "installMiddle:", "deinstallMiddle"],
  3610. referencedClasses: []
  3611. }),
  3612. smalltalk.MethodInheritanceTest);
  3613. smalltalk.addMethod(
  3614. smalltalk.method({
  3615. selector: "testReturns1",
  3616. category: 'tests',
  3617. fn: function (){
  3618. var self=this;
  3619. return smalltalk.withContext(function($ctx1) {
  3620. self["@performBlock"]=(function(x){
  3621. return smalltalk.withContext(function($ctx2) {
  3622. return _st(x)._foo();
  3623. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})});
  3624. self._installTop_("foo ^ false");
  3625. self._shouldReturn_(false);
  3626. self._installTop_("foo ^ true");
  3627. self._shouldReturn_(true);
  3628. return self}, function($ctx1) {$ctx1.fill(self,"testReturns1",{},smalltalk.MethodInheritanceTest)})},
  3629. args: [],
  3630. source: "testReturns1\x0a\x09performBlock := [ :x | x foo ].\x0a\x09self installTop: 'foo ^ false'.\x0a\x09self shouldReturn: false.\x0a\x09self installTop: 'foo ^ true'.\x0a\x09self shouldReturn: true",
  3631. messageSends: ["foo", "installTop:", "shouldReturn:"],
  3632. referencedClasses: []
  3633. }),
  3634. smalltalk.MethodInheritanceTest);
  3635. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3636. smalltalk.addMethod(
  3637. smalltalk.method({
  3638. selector: "testAbs",
  3639. category: 'tests',
  3640. fn: function (){
  3641. var self=this;
  3642. return smalltalk.withContext(function($ctx1) {
  3643. self._assert_equals_((4)._abs(),(4));
  3644. self._assert_equals_((-4)._abs(),(4));
  3645. return self}, function($ctx1) {$ctx1.fill(self,"testAbs",{},smalltalk.NumberTest)})},
  3646. args: [],
  3647. source: "testAbs\x0a\x09self assert: 4 abs equals: 4.\x0a\x09self assert: -4 abs equals: 4",
  3648. messageSends: ["assert:equals:", "abs"],
  3649. referencedClasses: []
  3650. }),
  3651. smalltalk.NumberTest);
  3652. smalltalk.addMethod(
  3653. smalltalk.method({
  3654. selector: "testArithmetic",
  3655. category: 'tests',
  3656. fn: function (){
  3657. var self=this;
  3658. return smalltalk.withContext(function($ctx1) {
  3659. self._assert_equals_((1.5).__plus((1)),(2.5));
  3660. self._assert_equals_((2).__minus((1)),(1));
  3661. self._assert_equals_((-2).__minus((1)),(-3));
  3662. self._assert_equals_((12).__slash((2)),(6));
  3663. self._assert_equals_((3).__star((4)),(12));
  3664. self._assert_equals_((7).__slash_slash((2)),(3));
  3665. self._assert_equals_((7).__backslash_backslash((2)),(1));
  3666. self._assert_equals_(_st((1).__plus((2))).__star((3)),(9));
  3667. self._assert_equals_((1).__plus((2).__star((3))),(7));
  3668. return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.NumberTest)})},
  3669. args: [],
  3670. 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\x09self assert: 7 // 2 equals: 3.\x0a\x09self assert: 7 \x5c\x5c 2 equals: 1.\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",
  3671. messageSends: ["assert:equals:", "+", "-", "/", "*", "//", "\x5c\x5c"],
  3672. referencedClasses: []
  3673. }),
  3674. smalltalk.NumberTest);
  3675. smalltalk.addMethod(
  3676. smalltalk.method({
  3677. selector: "testAsNumber",
  3678. category: 'tests',
  3679. fn: function (){
  3680. var self=this;
  3681. return smalltalk.withContext(function($ctx1) {
  3682. self._assert_equals_((3)._asNumber(),(3));
  3683. return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.NumberTest)})},
  3684. args: [],
  3685. source: "testAsNumber\x0a\x09self assert: 3 asNumber equals: 3.",
  3686. messageSends: ["assert:equals:", "asNumber"],
  3687. referencedClasses: []
  3688. }),
  3689. smalltalk.NumberTest);
  3690. smalltalk.addMethod(
  3691. smalltalk.method({
  3692. selector: "testCeiling",
  3693. category: 'tests',
  3694. fn: function (){
  3695. var self=this;
  3696. return smalltalk.withContext(function($ctx1) {
  3697. self._assert_equals_((1.2)._ceiling(),(2));
  3698. self._assert_equals_((-1.2)._ceiling(),(-1));
  3699. self._assert_equals_((1)._ceiling(),(1));
  3700. return self}, function($ctx1) {$ctx1.fill(self,"testCeiling",{},smalltalk.NumberTest)})},
  3701. args: [],
  3702. source: "testCeiling\x0a\x09self assert: 1.2 ceiling equals: 2.\x0a\x09self assert: -1.2 ceiling equals: -1.\x0a\x09self assert: 1.0 ceiling equals: 1.",
  3703. messageSends: ["assert:equals:", "ceiling"],
  3704. referencedClasses: []
  3705. }),
  3706. smalltalk.NumberTest);
  3707. smalltalk.addMethod(
  3708. smalltalk.method({
  3709. selector: "testComparison",
  3710. category: 'tests',
  3711. fn: function (){
  3712. var self=this;
  3713. return smalltalk.withContext(function($ctx1) {
  3714. self._assert_((3).__gt((2)));
  3715. self._assert_((2).__lt((3)));
  3716. self._deny_((3).__lt((2)));
  3717. self._deny_((2).__gt((3)));
  3718. self._assert_((3).__gt_eq((3)));
  3719. self._assert_((3.1).__gt_eq((3)));
  3720. self._assert_((3).__lt_eq((3)));
  3721. self._assert_((3).__lt_eq((3.1)));
  3722. return self}, function($ctx1) {$ctx1.fill(self,"testComparison",{},smalltalk.NumberTest)})},
  3723. args: [],
  3724. 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",
  3725. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  3726. referencedClasses: []
  3727. }),
  3728. smalltalk.NumberTest);
  3729. smalltalk.addMethod(
  3730. smalltalk.method({
  3731. selector: "testCopying",
  3732. category: 'tests',
  3733. fn: function (){
  3734. var self=this;
  3735. return smalltalk.withContext(function($ctx1) {
  3736. self._assert_(_st((1)._copy()).__eq_eq((1)));
  3737. self._assert_(_st((1)._deepCopy()).__eq_eq((1)));
  3738. return self}, function($ctx1) {$ctx1.fill(self,"testCopying",{},smalltalk.NumberTest)})},
  3739. args: [],
  3740. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  3741. messageSends: ["assert:", "==", "copy", "deepCopy"],
  3742. referencedClasses: []
  3743. }),
  3744. smalltalk.NumberTest);
  3745. smalltalk.addMethod(
  3746. smalltalk.method({
  3747. selector: "testEquality",
  3748. category: 'tests',
  3749. fn: function (){
  3750. var self=this;
  3751. return smalltalk.withContext(function($ctx1) {
  3752. self._assert_((1).__eq((1)));
  3753. self._assert_((0).__eq((0)));
  3754. self._deny_((1).__eq((0)));
  3755. self._assert_(_st((1)._yourself()).__eq((1)));
  3756. self._assert_((1).__eq((1)._yourself()));
  3757. self._assert_(_st((1)._yourself()).__eq((1)._yourself()));
  3758. self._deny_((0).__eq(false));
  3759. self._deny_(false.__eq((0)));
  3760. self._deny_("".__eq((0)));
  3761. self._deny_((0).__eq(""));
  3762. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.NumberTest)})},
  3763. args: [],
  3764. 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 = ''",
  3765. messageSends: ["assert:", "=", "deny:", "yourself"],
  3766. referencedClasses: []
  3767. }),
  3768. smalltalk.NumberTest);
  3769. smalltalk.addMethod(
  3770. smalltalk.method({
  3771. selector: "testFloor",
  3772. category: 'tests',
  3773. fn: function (){
  3774. var self=this;
  3775. return smalltalk.withContext(function($ctx1) {
  3776. self._assert_equals_((1.2)._floor(),(1));
  3777. self._assert_equals_((-1.2)._floor(),(-2));
  3778. self._assert_equals_((1)._floor(),(1));
  3779. return self}, function($ctx1) {$ctx1.fill(self,"testFloor",{},smalltalk.NumberTest)})},
  3780. args: [],
  3781. source: "testFloor\x0a\x09self assert: 1.2 floor equals: 1.\x0a\x09self assert: -1.2 floor equals: -2.\x0a\x09self assert: 1.0 floor equals: 1.",
  3782. messageSends: ["assert:equals:", "floor"],
  3783. referencedClasses: []
  3784. }),
  3785. smalltalk.NumberTest);
  3786. smalltalk.addMethod(
  3787. smalltalk.method({
  3788. selector: "testHexNumbers",
  3789. category: 'tests',
  3790. fn: function (){
  3791. var self=this;
  3792. return smalltalk.withContext(function($ctx1) {
  3793. self._assert_equals_((9),(9));
  3794. self._assert_equals_((10)._truncated(),(10));
  3795. self._assert_equals_((11)._truncated(),(11));
  3796. self._assert_equals_((12)._truncated(),(12));
  3797. self._assert_equals_((13)._truncated(),(13));
  3798. self._assert_equals_((14)._truncated(),(14));
  3799. self._assert_equals_((15)._truncated(),(15));
  3800. return self}, function($ctx1) {$ctx1.fill(self,"testHexNumbers",{},smalltalk.NumberTest)})},
  3801. args: [],
  3802. 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",
  3803. messageSends: ["assert:equals:", "truncated"],
  3804. referencedClasses: []
  3805. }),
  3806. smalltalk.NumberTest);
  3807. smalltalk.addMethod(
  3808. smalltalk.method({
  3809. selector: "testIdentity",
  3810. category: 'tests',
  3811. fn: function (){
  3812. var self=this;
  3813. return smalltalk.withContext(function($ctx1) {
  3814. self._assert_((1).__eq_eq((1)));
  3815. self._assert_((0).__eq_eq((0)));
  3816. self._deny_((1).__eq_eq((0)));
  3817. self._assert_(_st((1)._yourself()).__eq_eq((1)));
  3818. self._assert_((1).__eq_eq((1)._yourself()));
  3819. self._assert_(_st((1)._yourself()).__eq_eq((1)._yourself()));
  3820. self._deny_((1).__eq_eq((2)));
  3821. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.NumberTest)})},
  3822. args: [],
  3823. 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",
  3824. messageSends: ["assert:", "==", "deny:", "yourself"],
  3825. referencedClasses: []
  3826. }),
  3827. smalltalk.NumberTest);
  3828. smalltalk.addMethod(
  3829. smalltalk.method({
  3830. selector: "testInvalidHexNumbers",
  3831. category: 'tests',
  3832. fn: function (){
  3833. var self=this;
  3834. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3835. return smalltalk.withContext(function($ctx1) {
  3836. self._should_raise_((function(){
  3837. return smalltalk.withContext(function($ctx2) {
  3838. return (16)._rG();
  3839. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3840. self._should_raise_((function(){
  3841. return smalltalk.withContext(function($ctx2) {
  3842. return (16)._rg();
  3843. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$MessageNotUnderstood());
  3844. self._should_raise_((function(){
  3845. return smalltalk.withContext(function($ctx2) {
  3846. return (16)._rH();
  3847. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}),$MessageNotUnderstood());
  3848. self._should_raise_((function(){
  3849. return smalltalk.withContext(function($ctx2) {
  3850. return (16)._rh();
  3851. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}),$MessageNotUnderstood());
  3852. self._should_raise_((function(){
  3853. return smalltalk.withContext(function($ctx2) {
  3854. return (16)._rI();
  3855. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}),$MessageNotUnderstood());
  3856. self._should_raise_((function(){
  3857. return smalltalk.withContext(function($ctx2) {
  3858. return (16)._ri();
  3859. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}),$MessageNotUnderstood());
  3860. self._should_raise_((function(){
  3861. return smalltalk.withContext(function($ctx2) {
  3862. return (16)._rJ();
  3863. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,7)})}),$MessageNotUnderstood());
  3864. self._should_raise_((function(){
  3865. return smalltalk.withContext(function($ctx2) {
  3866. return (16)._rj();
  3867. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,8)})}),$MessageNotUnderstood());
  3868. self._should_raise_((function(){
  3869. return smalltalk.withContext(function($ctx2) {
  3870. return (16)._rK();
  3871. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,9)})}),$MessageNotUnderstood());
  3872. self._should_raise_((function(){
  3873. return smalltalk.withContext(function($ctx2) {
  3874. return (16)._rk();
  3875. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,10)})}),$MessageNotUnderstood());
  3876. self._should_raise_((function(){
  3877. return smalltalk.withContext(function($ctx2) {
  3878. return (16)._rL();
  3879. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,11)})}),$MessageNotUnderstood());
  3880. self._should_raise_((function(){
  3881. return smalltalk.withContext(function($ctx2) {
  3882. return (16)._rl();
  3883. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,12)})}),$MessageNotUnderstood());
  3884. self._should_raise_((function(){
  3885. return smalltalk.withContext(function($ctx2) {
  3886. return (16)._rM();
  3887. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,13)})}),$MessageNotUnderstood());
  3888. self._should_raise_((function(){
  3889. return smalltalk.withContext(function($ctx2) {
  3890. return (16)._rm();
  3891. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,14)})}),$MessageNotUnderstood());
  3892. self._should_raise_((function(){
  3893. return smalltalk.withContext(function($ctx2) {
  3894. return (16)._rN();
  3895. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,15)})}),$MessageNotUnderstood());
  3896. self._should_raise_((function(){
  3897. return smalltalk.withContext(function($ctx2) {
  3898. return (16)._rn();
  3899. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,16)})}),$MessageNotUnderstood());
  3900. self._should_raise_((function(){
  3901. return smalltalk.withContext(function($ctx2) {
  3902. return (16)._rO();
  3903. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,17)})}),$MessageNotUnderstood());
  3904. self._should_raise_((function(){
  3905. return smalltalk.withContext(function($ctx2) {
  3906. return (16)._ro();
  3907. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,18)})}),$MessageNotUnderstood());
  3908. self._should_raise_((function(){
  3909. return smalltalk.withContext(function($ctx2) {
  3910. return (16)._rP();
  3911. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,19)})}),$MessageNotUnderstood());
  3912. self._should_raise_((function(){
  3913. return smalltalk.withContext(function($ctx2) {
  3914. return (16)._rp();
  3915. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,20)})}),$MessageNotUnderstood());
  3916. self._should_raise_((function(){
  3917. return smalltalk.withContext(function($ctx2) {
  3918. return (16)._rQ();
  3919. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,21)})}),$MessageNotUnderstood());
  3920. self._should_raise_((function(){
  3921. return smalltalk.withContext(function($ctx2) {
  3922. return (16)._rq();
  3923. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,22)})}),$MessageNotUnderstood());
  3924. self._should_raise_((function(){
  3925. return smalltalk.withContext(function($ctx2) {
  3926. return (16)._rR();
  3927. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,23)})}),$MessageNotUnderstood());
  3928. self._should_raise_((function(){
  3929. return smalltalk.withContext(function($ctx2) {
  3930. return (16)._rr();
  3931. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,24)})}),$MessageNotUnderstood());
  3932. self._should_raise_((function(){
  3933. return smalltalk.withContext(function($ctx2) {
  3934. return (16)._rS();
  3935. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,25)})}),$MessageNotUnderstood());
  3936. self._should_raise_((function(){
  3937. return smalltalk.withContext(function($ctx2) {
  3938. return (16)._rs();
  3939. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,26)})}),$MessageNotUnderstood());
  3940. self._should_raise_((function(){
  3941. return smalltalk.withContext(function($ctx2) {
  3942. return (16)._rT();
  3943. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,27)})}),$MessageNotUnderstood());
  3944. self._should_raise_((function(){
  3945. return smalltalk.withContext(function($ctx2) {
  3946. return (16)._rt();
  3947. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,28)})}),$MessageNotUnderstood());
  3948. self._should_raise_((function(){
  3949. return smalltalk.withContext(function($ctx2) {
  3950. return (16)._rU();
  3951. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,29)})}),$MessageNotUnderstood());
  3952. self._should_raise_((function(){
  3953. return smalltalk.withContext(function($ctx2) {
  3954. return (16)._ru();
  3955. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,30)})}),$MessageNotUnderstood());
  3956. self._should_raise_((function(){
  3957. return smalltalk.withContext(function($ctx2) {
  3958. return (16)._rV();
  3959. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,31)})}),$MessageNotUnderstood());
  3960. self._should_raise_((function(){
  3961. return smalltalk.withContext(function($ctx2) {
  3962. return (16)._rv();
  3963. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,32)})}),$MessageNotUnderstood());
  3964. self._should_raise_((function(){
  3965. return smalltalk.withContext(function($ctx2) {
  3966. return (16)._rW();
  3967. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,33)})}),$MessageNotUnderstood());
  3968. self._should_raise_((function(){
  3969. return smalltalk.withContext(function($ctx2) {
  3970. return (16)._rw();
  3971. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,34)})}),$MessageNotUnderstood());
  3972. self._should_raise_((function(){
  3973. return smalltalk.withContext(function($ctx2) {
  3974. return (16)._rX();
  3975. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,35)})}),$MessageNotUnderstood());
  3976. self._should_raise_((function(){
  3977. return smalltalk.withContext(function($ctx2) {
  3978. return (16)._rx();
  3979. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,36)})}),$MessageNotUnderstood());
  3980. self._should_raise_((function(){
  3981. return smalltalk.withContext(function($ctx2) {
  3982. return (16)._rY();
  3983. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,37)})}),$MessageNotUnderstood());
  3984. self._should_raise_((function(){
  3985. return smalltalk.withContext(function($ctx2) {
  3986. return (16)._ry();
  3987. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,38)})}),$MessageNotUnderstood());
  3988. self._should_raise_((function(){
  3989. return smalltalk.withContext(function($ctx2) {
  3990. return (16)._rZ();
  3991. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,39)})}),$MessageNotUnderstood());
  3992. self._should_raise_((function(){
  3993. return smalltalk.withContext(function($ctx2) {
  3994. return (16)._rz();
  3995. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,40)})}),$MessageNotUnderstood());
  3996. self._should_raise_((function(){
  3997. return smalltalk.withContext(function($ctx2) {
  3998. return (11259375)._Z();
  3999. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,41)})}),$MessageNotUnderstood());
  4000. return self}, function($ctx1) {$ctx1.fill(self,"testInvalidHexNumbers",{},smalltalk.NumberTest)})},
  4001. args: [],
  4002. 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.",
  4003. 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"],
  4004. referencedClasses: ["MessageNotUnderstood"]
  4005. }),
  4006. smalltalk.NumberTest);
  4007. smalltalk.addMethod(
  4008. smalltalk.method({
  4009. selector: "testLog",
  4010. category: 'tests',
  4011. fn: function (){
  4012. var self=this;
  4013. function $Number(){return smalltalk.Number||(typeof Number=="undefined"?nil:Number)}
  4014. return smalltalk.withContext(function($ctx1) {
  4015. self._assert_equals_((10000)._log(),(4));
  4016. self._assert_equals_((512)._log_((2)),(9));
  4017. self._assert_equals_(_st(_st($Number())._e())._ln(),(1));
  4018. return self}, function($ctx1) {$ctx1.fill(self,"testLog",{},smalltalk.NumberTest)})},
  4019. args: [],
  4020. source: "testLog\x0a\x09self assert: 10000 log equals: 4.\x0a\x09self assert: (512 log: 2) equals: 9.\x0a\x09self assert: Number e ln equals: 1.",
  4021. messageSends: ["assert:equals:", "log", "log:", "ln", "e"],
  4022. referencedClasses: ["Number"]
  4023. }),
  4024. smalltalk.NumberTest);
  4025. smalltalk.addMethod(
  4026. smalltalk.method({
  4027. selector: "testMinMax",
  4028. category: 'tests',
  4029. fn: function (){
  4030. var self=this;
  4031. return smalltalk.withContext(function($ctx1) {
  4032. self._assert_equals_((2)._max_((5)),(5));
  4033. self._assert_equals_((2)._min_((5)),(2));
  4034. return self}, function($ctx1) {$ctx1.fill(self,"testMinMax",{},smalltalk.NumberTest)})},
  4035. args: [],
  4036. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  4037. messageSends: ["assert:equals:", "max:", "min:"],
  4038. referencedClasses: []
  4039. }),
  4040. smalltalk.NumberTest);
  4041. smalltalk.addMethod(
  4042. smalltalk.method({
  4043. selector: "testNegated",
  4044. category: 'tests',
  4045. fn: function (){
  4046. var self=this;
  4047. return smalltalk.withContext(function($ctx1) {
  4048. self._assert_equals_((3)._negated(),(-3));
  4049. self._assert_equals_((-3)._negated(),(3));
  4050. return self}, function($ctx1) {$ctx1.fill(self,"testNegated",{},smalltalk.NumberTest)})},
  4051. args: [],
  4052. source: "testNegated\x0a\x09self assert: 3 negated equals: -3.\x0a\x09self assert: -3 negated equals: 3",
  4053. messageSends: ["assert:equals:", "negated"],
  4054. referencedClasses: []
  4055. }),
  4056. smalltalk.NumberTest);
  4057. smalltalk.addMethod(
  4058. smalltalk.method({
  4059. selector: "testPrintShowingDecimalPlaces",
  4060. category: 'tests',
  4061. fn: function (){
  4062. var self=this;
  4063. return smalltalk.withContext(function($ctx1) {
  4064. self._assert_equals_((23)._printShowingDecimalPlaces_((2)),"23.00");
  4065. self._assert_equals_((23.5698)._printShowingDecimalPlaces_((2)),"23.57");
  4066. self._assert_equals_(_st((234.567)._negated())._printShowingDecimalPlaces_((5)),"-234.56700");
  4067. self._assert_equals_((23.4567)._printShowingDecimalPlaces_((0)),"23");
  4068. self._assert_equals_((23.5567)._printShowingDecimalPlaces_((0)),"24");
  4069. self._assert_equals_(_st((23.4567)._negated())._printShowingDecimalPlaces_((0)),"-23");
  4070. self._assert_equals_(_st((23.5567)._negated())._printShowingDecimalPlaces_((0)),"-24");
  4071. self._assert_equals_((100000000)._printShowingDecimalPlaces_((1)),"100000000.0");
  4072. self._assert_equals_((0.98)._printShowingDecimalPlaces_((5)),"0.98000");
  4073. self._assert_equals_(_st((0.98)._negated())._printShowingDecimalPlaces_((2)),"-0.98");
  4074. self._assert_equals_((2.567)._printShowingDecimalPlaces_((2)),"2.57");
  4075. self._assert_equals_((-2.567)._printShowingDecimalPlaces_((2)),"-2.57");
  4076. self._assert_equals_((0)._printShowingDecimalPlaces_((2)),"0.00");
  4077. return self}, function($ctx1) {$ctx1.fill(self,"testPrintShowingDecimalPlaces",{},smalltalk.NumberTest)})},
  4078. args: [],
  4079. 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'.",
  4080. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  4081. referencedClasses: []
  4082. }),
  4083. smalltalk.NumberTest);
  4084. smalltalk.addMethod(
  4085. smalltalk.method({
  4086. selector: "testRaisedTo",
  4087. category: 'tests',
  4088. fn: function (){
  4089. var self=this;
  4090. return smalltalk.withContext(function($ctx1) {
  4091. self._assert_equals_((2)._raisedTo_((4)),(16));
  4092. self._assert_equals_((2)._raisedTo_((0)),(1));
  4093. self._assert_equals_((2)._raisedTo_((-3)),(0.125));
  4094. self._assert_equals_((4)._raisedTo_((0.5)),(2));
  4095. self._assert_equals_((2).__star_star((4)),(16));
  4096. return self}, function($ctx1) {$ctx1.fill(self,"testRaisedTo",{},smalltalk.NumberTest)})},
  4097. args: [],
  4098. source: "testRaisedTo\x0a\x09self assert: (2 raisedTo: 4) equals: 16.\x0a\x09self assert: (2 raisedTo: 0) equals: 1.\x0a\x09self assert: (2 raisedTo: -3) equals: 0.125.\x0a\x09self assert: (4 raisedTo: 0.5) equals: 2.\x0a\x09\x0a\x09self assert: 2 ** 4 equals: 16.",
  4099. messageSends: ["assert:equals:", "raisedTo:", "**"],
  4100. referencedClasses: []
  4101. }),
  4102. smalltalk.NumberTest);
  4103. smalltalk.addMethod(
  4104. smalltalk.method({
  4105. selector: "testRounded",
  4106. category: 'tests',
  4107. fn: function (){
  4108. var self=this;
  4109. return smalltalk.withContext(function($ctx1) {
  4110. self._assert_equals_((3)._rounded(),(3));
  4111. self._assert_equals_((3.212)._rounded(),(3));
  4112. self._assert_equals_((3.51)._rounded(),(4));
  4113. return self}, function($ctx1) {$ctx1.fill(self,"testRounded",{},smalltalk.NumberTest)})},
  4114. args: [],
  4115. 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",
  4116. messageSends: ["assert:equals:", "rounded"],
  4117. referencedClasses: []
  4118. }),
  4119. smalltalk.NumberTest);
  4120. smalltalk.addMethod(
  4121. smalltalk.method({
  4122. selector: "testSign",
  4123. category: 'tests',
  4124. fn: function (){
  4125. var self=this;
  4126. return smalltalk.withContext(function($ctx1) {
  4127. self._assert_equals_((5)._sign(),(1));
  4128. self._assert_equals_((0)._sign(),(0));
  4129. self._assert_equals_((-1.4)._sign(),(-1));
  4130. return self}, function($ctx1) {$ctx1.fill(self,"testSign",{},smalltalk.NumberTest)})},
  4131. args: [],
  4132. source: "testSign\x0a\x09self assert: 5 sign equals: 1.\x0a\x09self assert: 0 sign equals: 0.\x0a\x09self assert: -1.4 sign equals: -1.",
  4133. messageSends: ["assert:equals:", "sign"],
  4134. referencedClasses: []
  4135. }),
  4136. smalltalk.NumberTest);
  4137. smalltalk.addMethod(
  4138. smalltalk.method({
  4139. selector: "testSqrt",
  4140. category: 'tests',
  4141. fn: function (){
  4142. var self=this;
  4143. return smalltalk.withContext(function($ctx1) {
  4144. self._assert_equals_((4)._sqrt(),(2));
  4145. self._assert_equals_((16)._sqrt(),(4));
  4146. return self}, function($ctx1) {$ctx1.fill(self,"testSqrt",{},smalltalk.NumberTest)})},
  4147. args: [],
  4148. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt equals: 2.\x0a\x09self assert: 16 sqrt equals: 4",
  4149. messageSends: ["assert:equals:", "sqrt"],
  4150. referencedClasses: []
  4151. }),
  4152. smalltalk.NumberTest);
  4153. smalltalk.addMethod(
  4154. smalltalk.method({
  4155. selector: "testSquared",
  4156. category: 'tests',
  4157. fn: function (){
  4158. var self=this;
  4159. return smalltalk.withContext(function($ctx1) {
  4160. self._assert_equals_((4)._squared(),(16));
  4161. return self}, function($ctx1) {$ctx1.fill(self,"testSquared",{},smalltalk.NumberTest)})},
  4162. args: [],
  4163. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared equals: 16",
  4164. messageSends: ["assert:equals:", "squared"],
  4165. referencedClasses: []
  4166. }),
  4167. smalltalk.NumberTest);
  4168. smalltalk.addMethod(
  4169. smalltalk.method({
  4170. selector: "testTimesRepeat",
  4171. category: 'tests',
  4172. fn: function (){
  4173. var self=this;
  4174. var i;
  4175. return smalltalk.withContext(function($ctx1) {
  4176. i=(0);
  4177. (0)._timesRepeat_((function(){
  4178. return smalltalk.withContext(function($ctx2) {
  4179. i=_st(i).__plus((1));
  4180. return i;
  4181. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  4182. self._assert_equals_(i,(0));
  4183. (5)._timesRepeat_((function(){
  4184. return smalltalk.withContext(function($ctx2) {
  4185. i=_st(i).__plus((1));
  4186. return i;
  4187. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  4188. self._assert_equals_(i,(5));
  4189. return self}, function($ctx1) {$ctx1.fill(self,"testTimesRepeat",{i:i},smalltalk.NumberTest)})},
  4190. args: [],
  4191. 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",
  4192. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  4193. referencedClasses: []
  4194. }),
  4195. smalltalk.NumberTest);
  4196. smalltalk.addMethod(
  4197. smalltalk.method({
  4198. selector: "testTo",
  4199. category: 'tests',
  4200. fn: function (){
  4201. var self=this;
  4202. return smalltalk.withContext(function($ctx1) {
  4203. self._assert_equals_((1)._to_((5)),[(1), (2), (3), (4), (5)]);
  4204. return self}, function($ctx1) {$ctx1.fill(self,"testTo",{},smalltalk.NumberTest)})},
  4205. args: [],
  4206. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  4207. messageSends: ["assert:equals:", "to:"],
  4208. referencedClasses: []
  4209. }),
  4210. smalltalk.NumberTest);
  4211. smalltalk.addMethod(
  4212. smalltalk.method({
  4213. selector: "testToBy",
  4214. category: 'tests',
  4215. fn: function (){
  4216. var self=this;
  4217. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  4218. return smalltalk.withContext(function($ctx1) {
  4219. self._assert_equals_((0)._to_by_((6),(2)),[(0), (2), (4), (6)]);
  4220. self._should_raise_((function(){
  4221. return smalltalk.withContext(function($ctx2) {
  4222. return (1)._to_by_((4),(0));
  4223. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  4224. return self}, function($ctx1) {$ctx1.fill(self,"testToBy",{},smalltalk.NumberTest)})},
  4225. args: [],
  4226. 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",
  4227. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  4228. referencedClasses: ["Error"]
  4229. }),
  4230. smalltalk.NumberTest);
  4231. smalltalk.addMethod(
  4232. smalltalk.method({
  4233. selector: "testTrigonometry",
  4234. category: 'tests',
  4235. fn: function (){
  4236. var self=this;
  4237. return smalltalk.withContext(function($ctx1) {
  4238. self._assert_equals_((0)._cos(),(1));
  4239. self._assert_equals_((0)._sin(),(0));
  4240. self._assert_equals_((0)._tan(),(0));
  4241. self._assert_equals_((1)._arcCos(),(0));
  4242. self._assert_equals_((0)._arcSin(),(0));
  4243. self._assert_equals_((0)._arcTan(),(0));
  4244. return self}, function($ctx1) {$ctx1.fill(self,"testTrigonometry",{},smalltalk.NumberTest)})},
  4245. args: [],
  4246. source: "testTrigonometry\x0a\x09self assert: 0 cos equals: 1.\x0a\x09self assert: 0 sin equals: 0.\x0a\x09self assert: 0 tan equals: 0.\x0a\x09self assert: 1 arcCos equals: 0.\x0a\x09self assert: 0 arcSin equals: 0.\x0a\x09self assert: 0 arcTan equals: 0.",
  4247. messageSends: ["assert:equals:", "cos", "sin", "tan", "arcCos", "arcSin", "arcTan"],
  4248. referencedClasses: []
  4249. }),
  4250. smalltalk.NumberTest);
  4251. smalltalk.addMethod(
  4252. smalltalk.method({
  4253. selector: "testTruncated",
  4254. category: 'tests',
  4255. fn: function (){
  4256. var self=this;
  4257. return smalltalk.withContext(function($ctx1) {
  4258. self._assert_equals_((3)._truncated(),(3));
  4259. self._assert_equals_((3.212)._truncated(),(3));
  4260. self._assert_equals_((3.51)._truncated(),(3));
  4261. return self}, function($ctx1) {$ctx1.fill(self,"testTruncated",{},smalltalk.NumberTest)})},
  4262. args: [],
  4263. 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",
  4264. messageSends: ["assert:equals:", "truncated"],
  4265. referencedClasses: []
  4266. }),
  4267. smalltalk.NumberTest);
  4268. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  4269. smalltalk.ObjectMock.comment="ObjectMock is there only to perform tests on classes.";
  4270. smalltalk.addMethod(
  4271. smalltalk.method({
  4272. selector: "foo",
  4273. category: 'not yet classified',
  4274. fn: function (){
  4275. var self=this;
  4276. return smalltalk.withContext(function($ctx1) {
  4277. var $1;
  4278. $1=self["@foo"];
  4279. return $1;
  4280. }, function($ctx1) {$ctx1.fill(self,"foo",{},smalltalk.ObjectMock)})},
  4281. args: [],
  4282. source: "foo\x0a\x09^foo",
  4283. messageSends: [],
  4284. referencedClasses: []
  4285. }),
  4286. smalltalk.ObjectMock);
  4287. smalltalk.addMethod(
  4288. smalltalk.method({
  4289. selector: "foo:",
  4290. category: 'not yet classified',
  4291. fn: function (anObject){
  4292. var self=this;
  4293. return smalltalk.withContext(function($ctx1) {
  4294. self["@foo"]=anObject;
  4295. return self}, function($ctx1) {$ctx1.fill(self,"foo:",{anObject:anObject},smalltalk.ObjectMock)})},
  4296. args: ["anObject"],
  4297. source: "foo: anObject\x0a\x09foo := anObject",
  4298. messageSends: [],
  4299. referencedClasses: []
  4300. }),
  4301. smalltalk.ObjectMock);
  4302. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4303. smalltalk.addMethod(
  4304. smalltalk.method({
  4305. selector: "notDefined",
  4306. category: 'tests',
  4307. fn: function (){
  4308. var self=this;
  4309. return smalltalk.withContext(function($ctx1) {
  4310. return void 0;;
  4311. return self}, function($ctx1) {$ctx1.fill(self,"notDefined",{},smalltalk.ObjectTest)})},
  4312. args: [],
  4313. source: "notDefined\x0a\x09<return void 0;>",
  4314. messageSends: [],
  4315. referencedClasses: []
  4316. }),
  4317. smalltalk.ObjectTest);
  4318. smalltalk.addMethod(
  4319. smalltalk.method({
  4320. selector: "testBasicAccess",
  4321. category: 'tests',
  4322. fn: function (){
  4323. var self=this;
  4324. var o;
  4325. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4326. return smalltalk.withContext(function($ctx1) {
  4327. o=_st($Object())._new();
  4328. _st(o)._basicAt_put_("a",(1));
  4329. self._assert_equals_(_st(o)._basicAt_("a"),(1));
  4330. self._assert_equals_(_st(o)._basicAt_("b"),nil);
  4331. return self}, function($ctx1) {$ctx1.fill(self,"testBasicAccess",{o:o},smalltalk.ObjectTest)})},
  4332. args: [],
  4333. 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",
  4334. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  4335. referencedClasses: ["Object"]
  4336. }),
  4337. smalltalk.ObjectTest);
  4338. smalltalk.addMethod(
  4339. smalltalk.method({
  4340. selector: "testBasicPerform",
  4341. category: 'tests',
  4342. fn: function (){
  4343. var self=this;
  4344. var o;
  4345. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4346. return smalltalk.withContext(function($ctx1) {
  4347. o=_st($Object())._new();
  4348. _st(o)._basicAt_put_("func",(function(){
  4349. return smalltalk.withContext(function($ctx2) {
  4350. return "hello";
  4351. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  4352. _st(o)._basicAt_put_("func2",(function(a){
  4353. return smalltalk.withContext(function($ctx2) {
  4354. return _st(a).__plus((1));
  4355. }, function($ctx2) {$ctx2.fillBlock({a:a},$ctx1,2)})}));
  4356. self._assert_equals_(_st(o)._basicPerform_("func"),"hello");
  4357. self._assert_equals_(_st(o)._basicPerform_withArguments_("func2",[(3)]),(4));
  4358. return self}, function($ctx1) {$ctx1.fill(self,"testBasicPerform",{o:o},smalltalk.ObjectTest)})},
  4359. args: [],
  4360. 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",
  4361. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  4362. referencedClasses: ["Object"]
  4363. }),
  4364. smalltalk.ObjectTest);
  4365. smalltalk.addMethod(
  4366. smalltalk.method({
  4367. selector: "testDNU",
  4368. category: 'tests',
  4369. fn: function (){
  4370. var self=this;
  4371. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4372. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  4373. return smalltalk.withContext(function($ctx1) {
  4374. self._should_raise_((function(){
  4375. return smalltalk.withContext(function($ctx2) {
  4376. return _st(_st($Object())._new())._foo();
  4377. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  4378. return self}, function($ctx1) {$ctx1.fill(self,"testDNU",{},smalltalk.ObjectTest)})},
  4379. args: [],
  4380. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  4381. messageSends: ["should:raise:", "foo", "new"],
  4382. referencedClasses: ["Object", "MessageNotUnderstood"]
  4383. }),
  4384. smalltalk.ObjectTest);
  4385. smalltalk.addMethod(
  4386. smalltalk.method({
  4387. selector: "testEquality",
  4388. category: 'tests',
  4389. fn: function (){
  4390. var self=this;
  4391. var o;
  4392. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4393. return smalltalk.withContext(function($ctx1) {
  4394. o=_st($Object())._new();
  4395. self._deny_(_st(o).__eq(_st($Object())._new()));
  4396. self._assert_(_st(o).__eq(o));
  4397. self._assert_(_st(_st(o)._yourself()).__eq(o));
  4398. self._assert_(_st(o).__eq(_st(o)._yourself()));
  4399. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{o:o},smalltalk.ObjectTest)})},
  4400. args: [],
  4401. 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)",
  4402. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  4403. referencedClasses: ["Object"]
  4404. }),
  4405. smalltalk.ObjectTest);
  4406. smalltalk.addMethod(
  4407. smalltalk.method({
  4408. selector: "testHalt",
  4409. category: 'tests',
  4410. fn: function (){
  4411. var self=this;
  4412. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4413. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  4414. return smalltalk.withContext(function($ctx1) {
  4415. self._should_raise_((function(){
  4416. return smalltalk.withContext(function($ctx2) {
  4417. return _st(_st($Object())._new())._halt();
  4418. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  4419. return self}, function($ctx1) {$ctx1.fill(self,"testHalt",{},smalltalk.ObjectTest)})},
  4420. args: [],
  4421. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  4422. messageSends: ["should:raise:", "halt", "new"],
  4423. referencedClasses: ["Object", "Error"]
  4424. }),
  4425. smalltalk.ObjectTest);
  4426. smalltalk.addMethod(
  4427. smalltalk.method({
  4428. selector: "testIdentity",
  4429. category: 'tests',
  4430. fn: function (){
  4431. var self=this;
  4432. var o;
  4433. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4434. return smalltalk.withContext(function($ctx1) {
  4435. o=_st($Object())._new();
  4436. self._deny_(_st(o).__eq_eq(_st($Object())._new()));
  4437. self._assert_(_st(o).__eq_eq(o));
  4438. self._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  4439. self._assert_(_st(o).__eq_eq(_st(o)._yourself()));
  4440. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{o:o},smalltalk.ObjectTest)})},
  4441. args: [],
  4442. 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",
  4443. messageSends: ["new", "deny:", "==", "assert:", "yourself"],
  4444. referencedClasses: ["Object"]
  4445. }),
  4446. smalltalk.ObjectTest);
  4447. smalltalk.addMethod(
  4448. smalltalk.method({
  4449. selector: "testIfNil",
  4450. category: 'tests',
  4451. fn: function (){
  4452. var self=this;
  4453. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4454. return smalltalk.withContext(function($ctx1) {
  4455. var $1,$4,$3,$2,$5,$7,$6,$8,$10,$9,$11,$13,$12;
  4456. self._deny_(_st(_st($Object())._new())._isNil());
  4457. $1=self;
  4458. $4=_st($Object())._new();
  4459. if(($receiver = $4) == nil || $receiver == null){
  4460. $3=true;
  4461. } else {
  4462. $3=$4;
  4463. };
  4464. $2=_st($3).__eq(true);
  4465. _st($1)._deny_($2);
  4466. $5=self;
  4467. $7=_st($Object())._new();
  4468. if(($receiver = $7) == nil || $receiver == null){
  4469. $6=$7;
  4470. } else {
  4471. $6=true;
  4472. };
  4473. _st($5)._assert_equals_($6,true);
  4474. $8=self;
  4475. $10=_st($Object())._new();
  4476. if(($receiver = $10) == nil || $receiver == null){
  4477. $9=false;
  4478. } else {
  4479. $9=true;
  4480. };
  4481. _st($8)._assert_equals_($9,true);
  4482. $11=self;
  4483. $13=_st($Object())._new();
  4484. if(($receiver = $13) == nil || $receiver == null){
  4485. $12=false;
  4486. } else {
  4487. $12=true;
  4488. };
  4489. _st($11)._assert_equals_($12,true);
  4490. return self}, function($ctx1) {$ctx1.fill(self,"testIfNil",{},smalltalk.ObjectTest)})},
  4491. args: [],
  4492. 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",
  4493. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:equals:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  4494. referencedClasses: ["Object"]
  4495. }),
  4496. smalltalk.ObjectTest);
  4497. smalltalk.addMethod(
  4498. smalltalk.method({
  4499. selector: "testInstVars",
  4500. category: 'tests',
  4501. fn: function (){
  4502. var self=this;
  4503. var o;
  4504. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  4505. return smalltalk.withContext(function($ctx1) {
  4506. o=_st($ObjectMock())._new();
  4507. self._assert_equals_(_st(o)._instVarAt_("foo"),nil);
  4508. _st(o)._instVarAt_put_("foo",(1));
  4509. self._assert_equals_(_st(o)._instVarAt_("foo"),(1));
  4510. self._assert_equals_(_st(o)._instVarAt_("foo"),(1));
  4511. return self}, function($ctx1) {$ctx1.fill(self,"testInstVars",{o:o},smalltalk.ObjectTest)})},
  4512. args: [],
  4513. 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",
  4514. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  4515. referencedClasses: ["ObjectMock"]
  4516. }),
  4517. smalltalk.ObjectTest);
  4518. smalltalk.addMethod(
  4519. smalltalk.method({
  4520. selector: "testNilUndefined",
  4521. category: 'tests',
  4522. fn: function (){
  4523. var self=this;
  4524. return smalltalk.withContext(function($ctx1) {
  4525. self._assert_equals_(self._notDefined(),nil);
  4526. return self}, function($ctx1) {$ctx1.fill(self,"testNilUndefined",{},smalltalk.ObjectTest)})},
  4527. args: [],
  4528. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09self assert: self notDefined equals: nil",
  4529. messageSends: ["assert:equals:", "notDefined"],
  4530. referencedClasses: []
  4531. }),
  4532. smalltalk.ObjectTest);
  4533. smalltalk.addMethod(
  4534. smalltalk.method({
  4535. selector: "testYourself",
  4536. category: 'tests',
  4537. fn: function (){
  4538. var self=this;
  4539. var o;
  4540. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  4541. return smalltalk.withContext(function($ctx1) {
  4542. o=_st($ObjectMock())._new();
  4543. self._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  4544. return self}, function($ctx1) {$ctx1.fill(self,"testYourself",{o:o},smalltalk.ObjectTest)})},
  4545. args: [],
  4546. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  4547. messageSends: ["new", "assert:", "==", "yourself"],
  4548. referencedClasses: ["ObjectMock"]
  4549. }),
  4550. smalltalk.ObjectTest);
  4551. smalltalk.addMethod(
  4552. smalltalk.method({
  4553. selector: "testidentityHash",
  4554. category: 'tests',
  4555. fn: function (){
  4556. var self=this;
  4557. var o1,o2;
  4558. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4559. return smalltalk.withContext(function($ctx1) {
  4560. o1=_st($Object())._new();
  4561. o2=_st($Object())._new();
  4562. self._assert_(_st(_st(o1)._identityHash()).__eq_eq(_st(o1)._identityHash()));
  4563. self._deny_(_st(_st(o1)._identityHash()).__eq_eq(_st(o2)._identityHash()));
  4564. return self}, function($ctx1) {$ctx1.fill(self,"testidentityHash",{o1:o1,o2:o2},smalltalk.ObjectTest)})},
  4565. args: [],
  4566. 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",
  4567. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  4568. referencedClasses: ["Object"]
  4569. }),
  4570. smalltalk.ObjectTest);
  4571. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4572. smalltalk.addMethod(
  4573. smalltalk.method({
  4574. selector: "testAccessing",
  4575. category: 'tests',
  4576. fn: function (){
  4577. var self=this;
  4578. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  4579. return smalltalk.withContext(function($ctx1) {
  4580. self._assert_equals_(_st(_st($Point())._x_y_((3),(4)))._x(),(3));
  4581. self._assert_equals_(_st(_st($Point())._x_y_((3),(4)))._y(),(4));
  4582. self._assert_equals_(_st(_st(_st($Point())._new())._x_((3)))._x(),(3));
  4583. self._assert_equals_(_st(_st(_st($Point())._new())._y_((4)))._y(),(4));
  4584. return self}, function($ctx1) {$ctx1.fill(self,"testAccessing",{},smalltalk.PointTest)})},
  4585. args: [],
  4586. 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",
  4587. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  4588. referencedClasses: ["Point"]
  4589. }),
  4590. smalltalk.PointTest);
  4591. smalltalk.addMethod(
  4592. smalltalk.method({
  4593. selector: "testArithmetic",
  4594. category: 'tests',
  4595. fn: function (){
  4596. var self=this;
  4597. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  4598. return smalltalk.withContext(function($ctx1) {
  4599. self._assert_equals_(_st((3).__at((4))).__star((3).__at((4))),_st($Point())._x_y_((9),(16)));
  4600. self._assert_equals_(_st((3).__at((4))).__plus((3).__at((4))),_st($Point())._x_y_((6),(8)));
  4601. self._assert_equals_(_st((3).__at((4))).__minus((3).__at((4))),_st($Point())._x_y_((0),(0)));
  4602. self._assert_equals_(_st((6).__at((8))).__slash((3).__at((4))),_st($Point())._x_y_((2),(2)));
  4603. return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.PointTest)})},
  4604. args: [],
  4605. 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)",
  4606. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  4607. referencedClasses: ["Point"]
  4608. }),
  4609. smalltalk.PointTest);
  4610. smalltalk.addMethod(
  4611. smalltalk.method({
  4612. selector: "testAt",
  4613. category: 'tests',
  4614. fn: function (){
  4615. var self=this;
  4616. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  4617. return smalltalk.withContext(function($ctx1) {
  4618. self._assert_equals_((3).__at((4)),_st($Point())._x_y_((3),(4)));
  4619. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.PointTest)})},
  4620. args: [],
  4621. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  4622. messageSends: ["assert:equals:", "@", "x:y:"],
  4623. referencedClasses: ["Point"]
  4624. }),
  4625. smalltalk.PointTest);
  4626. smalltalk.addMethod(
  4627. smalltalk.method({
  4628. selector: "testEgality",
  4629. category: 'tests',
  4630. fn: function (){
  4631. var self=this;
  4632. return smalltalk.withContext(function($ctx1) {
  4633. self._assert_(_st((3).__at((4))).__eq((3).__at((4))));
  4634. self._deny_(_st((3).__at((5))).__eq((3).__at((6))));
  4635. return self}, function($ctx1) {$ctx1.fill(self,"testEgality",{},smalltalk.PointTest)})},
  4636. args: [],
  4637. source: "testEgality\x0a\x09self assert: (3@4 = (3@4)).\x0a\x09self deny: 3@5 = (3@6)",
  4638. messageSends: ["assert:", "=", "@", "deny:"],
  4639. referencedClasses: []
  4640. }),
  4641. smalltalk.PointTest);
  4642. smalltalk.addMethod(
  4643. smalltalk.method({
  4644. selector: "testNew",
  4645. category: 'tests',
  4646. fn: function (){
  4647. var self=this;
  4648. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  4649. return smalltalk.withContext(function($ctx1) {
  4650. self._assert_equals_(_st(_st(_st($Point())._new())._x_((3)))._y(),nil);
  4651. self._deny_(_st(_st(_st(_st($Point())._new())._x_((3)))._x()).__eq((0)));
  4652. self._assert_equals_(_st(_st(_st($Point())._new())._y_((4)))._x(),nil);
  4653. self._deny_(_st(_st(_st(_st($Point())._new())._y_((4)))._y()).__eq((0)));
  4654. return self}, function($ctx1) {$ctx1.fill(self,"testNew",{},smalltalk.PointTest)})},
  4655. args: [],
  4656. source: "testNew\x0a\x0a\x09self assert: (Point new x: 3)y equals: nil.\x0a\x09self deny: (Point new x: 3)x = 0.\x0a\x09self assert: (Point new y: 4)x equals: nil.\x0a\x09self deny: (Point new y: 4)y = 0.",
  4657. messageSends: ["assert:equals:", "y", "x:", "new", "deny:", "=", "x", "y:"],
  4658. referencedClasses: ["Point"]
  4659. }),
  4660. smalltalk.PointTest);
  4661. smalltalk.addMethod(
  4662. smalltalk.method({
  4663. selector: "testTranslateBy",
  4664. category: 'tests',
  4665. fn: function (){
  4666. var self=this;
  4667. return smalltalk.withContext(function($ctx1) {
  4668. self._assert_equals_(_st((3).__at((3)))._translateBy_((0).__at((1))),(3).__at((4)));
  4669. self._assert_equals_(_st((3).__at((3)))._translateBy_((0).__at((1)._negated())),(3).__at((2)));
  4670. self._assert_equals_(_st((3).__at((3)))._translateBy_((2).__at((3))),(5).__at((6)));
  4671. self._assert_equals_(_st((3).__at((3)))._translateBy_(_st((3)._negated()).__at((0))),(0).__at((3)));
  4672. return self}, function($ctx1) {$ctx1.fill(self,"testTranslateBy",{},smalltalk.PointTest)})},
  4673. args: [],
  4674. 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.",
  4675. messageSends: ["assert:equals:", "translateBy:", "@", "negated"],
  4676. referencedClasses: []
  4677. }),
  4678. smalltalk.PointTest);
  4679. smalltalk.addClass('QueueTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4680. smalltalk.addMethod(
  4681. smalltalk.method({
  4682. selector: "testNextIfAbsent",
  4683. category: 'not yet classified',
  4684. fn: function (){
  4685. var self=this;
  4686. var queueVal;
  4687. function $Queue(){return smalltalk.Queue||(typeof Queue=="undefined"?nil:Queue)}
  4688. return smalltalk.withContext(function($ctx1) {
  4689. queueVal=_st($Queue())._new();
  4690. _st(queueVal)._nextPut_("index1");
  4691. self._assert_(_st(_st(queueVal)._nextIfAbsent_("empty")).__eq("index1"));
  4692. self._deny_(_st(_st(queueVal)._nextIfAbsent_("empty")).__eq("index1"));
  4693. return self}, function($ctx1) {$ctx1.fill(self,"testNextIfAbsent",{queueVal:queueVal},smalltalk.QueueTest)})},
  4694. args: [],
  4695. source: "testNextIfAbsent\x0a\x09| queueVal | \x0a\x0a\x09queueVal:= Queue new.\x0a\x09queueVal nextPut: 'index1'. \x0a\x0a\x09self assert: (queueVal nextIfAbsent:'empty') = 'index1'.\x0a\x09self deny: (queueVal nextIfAbsent:'empty') = 'index1'.",
  4696. messageSends: ["new", "nextPut:", "assert:", "=", "nextIfAbsent:", "deny:"],
  4697. referencedClasses: ["Queue"]
  4698. }),
  4699. smalltalk.QueueTest);
  4700. smalltalk.addMethod(
  4701. smalltalk.method({
  4702. selector: "testQueueNext",
  4703. category: 'not yet classified',
  4704. fn: function (){
  4705. var self=this;
  4706. var collec;
  4707. function $Queue(){return smalltalk.Queue||(typeof Queue=="undefined"?nil:Queue)}
  4708. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  4709. return smalltalk.withContext(function($ctx1) {
  4710. var $1,$2;
  4711. collec=_st($Queue())._new();
  4712. $1=collec;
  4713. _st($1)._nextPut_("index1");
  4714. $2=_st($1)._nextPut_("index2");
  4715. self._assert_(_st(_st(collec)._next()).__eq("index1"));
  4716. self._deny_(_st(_st(collec)._next()).__eq("index"));
  4717. self._should_raise_((function(){
  4718. return smalltalk.withContext(function($ctx2) {
  4719. return _st(collec)._next();
  4720. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  4721. return self}, function($ctx1) {$ctx1.fill(self,"testQueueNext",{collec:collec},smalltalk.QueueTest)})},
  4722. args: [],
  4723. source: "testQueueNext\x0a\x09| collec | \x0a\x0a\x09collec:= Queue new.\x0a\x09collec nextPut: 'index1' ;\x0a nextPut: 'index2' . \x0a\x0a\x09self assert: collec next = 'index1'.\x0a\x09self deny: collec next = 'index'.\x0a\x09self should:[ collec next ] raise: Error.",
  4724. messageSends: ["new", "nextPut:", "assert:", "=", "next", "deny:", "should:raise:"],
  4725. referencedClasses: ["Queue", "Error"]
  4726. }),
  4727. smalltalk.QueueTest);
  4728. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4729. smalltalk.addMethod(
  4730. smalltalk.method({
  4731. selector: "testAtRandom",
  4732. category: 'tests',
  4733. fn: function (){
  4734. var self=this;
  4735. var val;
  4736. return smalltalk.withContext(function($ctx1) {
  4737. (10000)._timesRepeat_((function(){
  4738. return smalltalk.withContext(function($ctx2) {
  4739. val="abc"._atRandom();
  4740. val;
  4741. return self._assert_(_st(_st(_st(val).__eq("a")).__or(_st(val).__eq("b"))).__or(_st(val).__eq("c")));
  4742. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  4743. (10000)._timesRepeat_((function(){
  4744. return smalltalk.withContext(function($ctx2) {
  4745. val=(10)._atRandom();
  4746. val;
  4747. self._assert_(_st(val).__gt((0)));
  4748. return self._assert_(_st(val).__lt((11)));
  4749. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  4750. return self}, function($ctx1) {$ctx1.fill(self,"testAtRandom",{val:val},smalltalk.RandomTest)})},
  4751. args: [],
  4752. source: "testAtRandom\x0a|val|\x0a\x0910000 timesRepeat: [\x0a\x09val := 'abc' atRandom.\x0a\x09self assert: ((val = 'a') | (val = 'b') | (val = 'c' )).\x0a\x09].\x0a\x09\x0a\x0910000 timesRepeat: [\x0a\x09\x09val := 10 atRandom.\x0a\x09\x09self assert: (val > 0).\x0a\x09\x09self assert: (val <11)\x0a\x09]",
  4753. messageSends: ["timesRepeat:", "atRandom", "assert:", "|", "=", ">", "<"],
  4754. referencedClasses: []
  4755. }),
  4756. smalltalk.RandomTest);
  4757. smalltalk.addMethod(
  4758. smalltalk.method({
  4759. selector: "textNext",
  4760. category: 'tests',
  4761. fn: function (){
  4762. var self=this;
  4763. function $Random(){return smalltalk.Random||(typeof Random=="undefined"?nil:Random)}
  4764. return smalltalk.withContext(function($ctx1) {
  4765. (10000)._timesRepeat_((function(){
  4766. var current,next;
  4767. return smalltalk.withContext(function($ctx2) {
  4768. next=_st(_st($Random())._new())._next();
  4769. next;
  4770. self._assert_(_st(next).__gt_eq((0)));
  4771. self._assert_(_st(next).__lt((1)));
  4772. self._deny_(_st(current).__eq(next));
  4773. return _st(next).__eq(current);
  4774. }, function($ctx2) {$ctx2.fillBlock({current:current,next:next},$ctx1,1)})}));
  4775. return self}, function($ctx1) {$ctx1.fill(self,"textNext",{},smalltalk.RandomTest)})},
  4776. args: [],
  4777. 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]",
  4778. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  4779. referencedClasses: ["Random"]
  4780. }),
  4781. smalltalk.RandomTest);
  4782. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4783. smalltalk.addMethod(
  4784. smalltalk.method({
  4785. selector: "testAddRemove",
  4786. category: 'tests',
  4787. fn: function (){
  4788. var self=this;
  4789. var set;
  4790. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4791. return smalltalk.withContext(function($ctx1) {
  4792. set=_st($Set())._new();
  4793. self._assert_(_st(set)._isEmpty());
  4794. _st(set)._add_((3));
  4795. self._assert_(_st(set)._includes_((3)));
  4796. _st(set)._add_((5));
  4797. self._assert_(_st(set)._includes_((5)));
  4798. _st(set)._remove_((3));
  4799. self._deny_(_st(set)._includes_((3)));
  4800. return self}, function($ctx1) {$ctx1.fill(self,"testAddRemove",{set:set},smalltalk.SetTest)})},
  4801. args: [],
  4802. 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)",
  4803. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  4804. referencedClasses: ["Set"]
  4805. }),
  4806. smalltalk.SetTest);
  4807. smalltalk.addMethod(
  4808. smalltalk.method({
  4809. selector: "testAt",
  4810. category: 'tests',
  4811. fn: function (){
  4812. var self=this;
  4813. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4814. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  4815. return smalltalk.withContext(function($ctx1) {
  4816. self._should_raise_((function(){
  4817. return smalltalk.withContext(function($ctx2) {
  4818. return _st(_st($Set())._new())._at_put_((1),(2));
  4819. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  4820. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.SetTest)})},
  4821. args: [],
  4822. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  4823. messageSends: ["should:raise:", "at:put:", "new"],
  4824. referencedClasses: ["Set", "Error"]
  4825. }),
  4826. smalltalk.SetTest);
  4827. smalltalk.addMethod(
  4828. smalltalk.method({
  4829. selector: "testCollect",
  4830. category: 'tests',
  4831. fn: function (){
  4832. var self=this;
  4833. return smalltalk.withContext(function($ctx1) {
  4834. self._assert_equals_(_st([(5), (6), (8)]._asSet())._collect_((function(x){
  4835. return smalltalk.withContext(function($ctx2) {
  4836. return _st(x).__backslash_backslash((3));
  4837. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})})),[(0), (2)]._asSet());
  4838. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{},smalltalk.SetTest)})},
  4839. args: [],
  4840. source: "testCollect\x0a\x09self assert: (#(5 6 8) asSet collect: [ :x | x \x5c\x5c 3 ]) equals: #(0 2) asSet",
  4841. messageSends: ["assert:equals:", "collect:", "asSet", "\x5c\x5c"],
  4842. referencedClasses: []
  4843. }),
  4844. smalltalk.SetTest);
  4845. smalltalk.addMethod(
  4846. smalltalk.method({
  4847. selector: "testComparing",
  4848. category: 'tests',
  4849. fn: function (){
  4850. var self=this;
  4851. return smalltalk.withContext(function($ctx1) {
  4852. self._assert_equals_([(0), (2)]._asSet(),[(0), (2)]._asSet());
  4853. self._assert_equals_([(2), (0)]._asSet(),[(0), (2)]._asSet());
  4854. self._deny_(_st([(0), (2), (3)]._asSet()).__eq([(0), (2)]._asSet()));
  4855. self._deny_(_st([(1), (2)]._asSet()).__eq([(0), (2)]._asSet()));
  4856. return self}, function($ctx1) {$ctx1.fill(self,"testComparing",{},smalltalk.SetTest)})},
  4857. args: [],
  4858. 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",
  4859. messageSends: ["assert:equals:", "asSet", "deny:", "="],
  4860. referencedClasses: []
  4861. }),
  4862. smalltalk.SetTest);
  4863. smalltalk.addMethod(
  4864. smalltalk.method({
  4865. selector: "testPrintString",
  4866. category: 'tests',
  4867. fn: function (){
  4868. var self=this;
  4869. var set;
  4870. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4871. return smalltalk.withContext(function($ctx1) {
  4872. var $1,$2,$3,$4;
  4873. set=_st($Set())._new();
  4874. self._assert_equals_(_st(set)._printString(),"a Set ()");
  4875. $1=set;
  4876. _st($1)._add_((1));
  4877. $2=_st($1)._add_((3));
  4878. self._assert_equals_(_st(set)._printString(),"a Set (1 3)");
  4879. _st(set)._add_("foo");
  4880. self._assert_equals_(_st(set)._printString(),"a Set (1 3 'foo')");
  4881. $3=set;
  4882. _st($3)._remove_((1));
  4883. $4=_st($3)._remove_((3));
  4884. self._assert_equals_(_st(set)._printString(),"a Set ('foo')");
  4885. _st(set)._add_((3));
  4886. self._assert_equals_(_st(set)._printString(),"a Set ('foo' 3)");
  4887. _st(set)._add_((3));
  4888. self._assert_equals_(_st(set)._printString(),"a Set ('foo' 3)");
  4889. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{set:set},smalltalk.SetTest)})},
  4890. args: [],
  4891. 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)'",
  4892. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:"],
  4893. referencedClasses: ["Set"]
  4894. }),
  4895. smalltalk.SetTest);
  4896. smalltalk.addMethod(
  4897. smalltalk.method({
  4898. selector: "testSize",
  4899. category: 'tests',
  4900. fn: function (){
  4901. var self=this;
  4902. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4903. return smalltalk.withContext(function($ctx1) {
  4904. self._assert_equals_(_st(_st($Set())._new())._size(),(0));
  4905. self._assert_equals_(_st(_st($Set())._withAll_([(1), (2), (3), (4)]))._size(),(4));
  4906. self._assert_equals_(_st(_st($Set())._withAll_([(1), (1), (1), (1)]))._size(),(1));
  4907. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.SetTest)})},
  4908. args: [],
  4909. 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",
  4910. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  4911. referencedClasses: ["Set"]
  4912. }),
  4913. smalltalk.SetTest);
  4914. smalltalk.addMethod(
  4915. smalltalk.method({
  4916. selector: "testUnboxedObjects",
  4917. category: 'tests',
  4918. fn: function (){
  4919. var self=this;
  4920. return smalltalk.withContext(function($ctx1) {
  4921. self._assert_equals_(_st(_st(["foo"._yourself(),"foo"._yourself()])._asSet())._asArray(),["foo"]);
  4922. return self}, function($ctx1) {$ctx1.fill(self,"testUnboxedObjects",{},smalltalk.SetTest)})},
  4923. args: [],
  4924. source: "testUnboxedObjects\x0a\x09self assert: {'foo' yourself. 'foo' yourself} asSet asArray equals: #('foo')",
  4925. messageSends: ["assert:equals:", "asArray", "asSet", "yourself"],
  4926. referencedClasses: []
  4927. }),
  4928. smalltalk.SetTest);
  4929. smalltalk.addMethod(
  4930. smalltalk.method({
  4931. selector: "testUnicity",
  4932. category: 'tests',
  4933. fn: function (){
  4934. var self=this;
  4935. var set;
  4936. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4937. return smalltalk.withContext(function($ctx1) {
  4938. set=_st($Set())._new();
  4939. _st(set)._add_((21));
  4940. _st(set)._add_("hello");
  4941. _st(set)._add_((21));
  4942. self._assert_equals_(_st(set)._size(),(2));
  4943. _st(set)._add_("hello");
  4944. self._assert_equals_(_st(set)._size(),(2));
  4945. self._assert_equals_(_st(set)._asArray(),[(21), "hello"]);
  4946. return self}, function($ctx1) {$ctx1.fill(self,"testUnicity",{set:set},smalltalk.SetTest)})},
  4947. args: [],
  4948. 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')",
  4949. messageSends: ["new", "add:", "assert:equals:", "size", "asArray"],
  4950. referencedClasses: ["Set"]
  4951. }),
  4952. smalltalk.SetTest);
  4953. smalltalk.addClass('StreamTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4954. smalltalk.addMethod(
  4955. smalltalk.method({
  4956. selector: "collectionClass",
  4957. category: 'accessing',
  4958. fn: function (){
  4959. var self=this;
  4960. return smalltalk.withContext(function($ctx1) {
  4961. var $1;
  4962. $1=_st(self._class())._collectionClass();
  4963. return $1;
  4964. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest)})},
  4965. args: [],
  4966. source: "collectionClass\x0a\x09^ self class collectionClass",
  4967. messageSends: ["collectionClass", "class"],
  4968. referencedClasses: []
  4969. }),
  4970. smalltalk.StreamTest);
  4971. smalltalk.addMethod(
  4972. smalltalk.method({
  4973. selector: "newCollection",
  4974. category: 'accessing',
  4975. fn: function (){
  4976. var self=this;
  4977. return smalltalk.withContext(function($ctx1) {
  4978. var $1;
  4979. $1=_st(self._collectionClass())._new();
  4980. return $1;
  4981. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StreamTest)})},
  4982. args: [],
  4983. source: "newCollection\x0a\x09^ self collectionClass new",
  4984. messageSends: ["new", "collectionClass"],
  4985. referencedClasses: []
  4986. }),
  4987. smalltalk.StreamTest);
  4988. smalltalk.addMethod(
  4989. smalltalk.method({
  4990. selector: "newStream",
  4991. category: 'accessing',
  4992. fn: function (){
  4993. var self=this;
  4994. return smalltalk.withContext(function($ctx1) {
  4995. var $1;
  4996. $1=_st(_st(self._collectionClass())._new())._stream();
  4997. return $1;
  4998. }, function($ctx1) {$ctx1.fill(self,"newStream",{},smalltalk.StreamTest)})},
  4999. args: [],
  5000. source: "newStream\x0a\x09^ self collectionClass new stream",
  5001. messageSends: ["stream", "new", "collectionClass"],
  5002. referencedClasses: []
  5003. }),
  5004. smalltalk.StreamTest);
  5005. smalltalk.addMethod(
  5006. smalltalk.method({
  5007. selector: "testAtStartAtEnd",
  5008. category: 'tests',
  5009. fn: function (){
  5010. var self=this;
  5011. var stream;
  5012. return smalltalk.withContext(function($ctx1) {
  5013. stream=self._newStream();
  5014. self._assert_(_st(stream)._atStart());
  5015. self._assert_(_st(stream)._atEnd());
  5016. _st(stream)._nextPutAll_(self._newCollection());
  5017. self._assert_(_st(stream)._atEnd());
  5018. self._deny_(_st(stream)._atStart());
  5019. _st(stream)._position_((1));
  5020. self._deny_(_st(stream)._atEnd());
  5021. self._deny_(_st(stream)._atStart());
  5022. return self}, function($ctx1) {$ctx1.fill(self,"testAtStartAtEnd",{stream:stream},smalltalk.StreamTest)})},
  5023. args: [],
  5024. 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",
  5025. messageSends: ["newStream", "assert:", "atStart", "atEnd", "nextPutAll:", "newCollection", "deny:", "position:"],
  5026. referencedClasses: []
  5027. }),
  5028. smalltalk.StreamTest);
  5029. smalltalk.addMethod(
  5030. smalltalk.method({
  5031. selector: "testContents",
  5032. category: 'tests',
  5033. fn: function (){
  5034. var self=this;
  5035. var stream;
  5036. return smalltalk.withContext(function($ctx1) {
  5037. stream=self._newStream();
  5038. _st(stream)._nextPutAll_(self._newCollection());
  5039. self._assert_equals_(_st(stream)._contents(),self._newCollection());
  5040. return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
  5041. args: [],
  5042. 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",
  5043. messageSends: ["newStream", "nextPutAll:", "newCollection", "assert:equals:", "contents"],
  5044. referencedClasses: []
  5045. }),
  5046. smalltalk.StreamTest);
  5047. smalltalk.addMethod(
  5048. smalltalk.method({
  5049. selector: "testIsEmpty",
  5050. category: 'tests',
  5051. fn: function (){
  5052. var self=this;
  5053. var stream;
  5054. return smalltalk.withContext(function($ctx1) {
  5055. stream=self._newStream();
  5056. self._assert_(_st(stream)._isEmpty());
  5057. _st(stream)._nextPutAll_(self._newCollection());
  5058. self._deny_(_st(stream)._isEmpty());
  5059. return self}, function($ctx1) {$ctx1.fill(self,"testIsEmpty",{stream:stream},smalltalk.StreamTest)})},
  5060. args: [],
  5061. 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",
  5062. messageSends: ["newStream", "assert:", "isEmpty", "nextPutAll:", "newCollection", "deny:"],
  5063. referencedClasses: []
  5064. }),
  5065. smalltalk.StreamTest);
  5066. smalltalk.addMethod(
  5067. smalltalk.method({
  5068. selector: "testPosition",
  5069. category: 'tests',
  5070. fn: function (){
  5071. var self=this;
  5072. var collection,stream;
  5073. return smalltalk.withContext(function($ctx1) {
  5074. collection=self._newCollection();
  5075. stream=self._newStream();
  5076. _st(stream)._nextPutAll_(collection);
  5077. self._assert_equals_(_st(stream)._position(),_st(collection)._size());
  5078. _st(stream)._position_((0));
  5079. self._assert_equals_(_st(stream)._position(),(0));
  5080. _st(stream)._next();
  5081. self._assert_equals_(_st(stream)._position(),(1));
  5082. _st(stream)._next();
  5083. self._assert_equals_(_st(stream)._position(),(2));
  5084. return self}, function($ctx1) {$ctx1.fill(self,"testPosition",{collection:collection,stream:stream},smalltalk.StreamTest)})},
  5085. args: [],
  5086. 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",
  5087. messageSends: ["newCollection", "newStream", "nextPutAll:", "assert:equals:", "position", "size", "position:", "next"],
  5088. referencedClasses: []
  5089. }),
  5090. smalltalk.StreamTest);
  5091. smalltalk.addMethod(
  5092. smalltalk.method({
  5093. selector: "testReading",
  5094. category: 'tests',
  5095. fn: function (){
  5096. var self=this;
  5097. var stream,collection;
  5098. return smalltalk.withContext(function($ctx1) {
  5099. var $1,$2;
  5100. collection=self._newCollection();
  5101. stream=self._newStream();
  5102. $1=stream;
  5103. _st($1)._nextPutAll_(collection);
  5104. $2=_st($1)._position_((0));
  5105. _st(collection)._do_((function(each){
  5106. return smalltalk.withContext(function($ctx2) {
  5107. return self._assert_equals_(_st(stream)._next(),each);
  5108. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  5109. self._assert_(_st(_st(stream)._next())._isNil());
  5110. return self}, function($ctx1) {$ctx1.fill(self,"testReading",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  5111. args: [],
  5112. 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",
  5113. messageSends: ["newCollection", "newStream", "nextPutAll:", "position:", "do:", "assert:equals:", "next", "assert:", "isNil"],
  5114. referencedClasses: []
  5115. }),
  5116. smalltalk.StreamTest);
  5117. smalltalk.addMethod(
  5118. smalltalk.method({
  5119. selector: "testStreamContents",
  5120. category: 'tests',
  5121. fn: function (){
  5122. var self=this;
  5123. return smalltalk.withContext(function($ctx1) {
  5124. return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StreamTest)})},
  5125. args: [],
  5126. source: "testStreamContents",
  5127. messageSends: [],
  5128. referencedClasses: []
  5129. }),
  5130. smalltalk.StreamTest);
  5131. smalltalk.addMethod(
  5132. smalltalk.method({
  5133. selector: "testWrite",
  5134. category: 'tests',
  5135. fn: function (){
  5136. var self=this;
  5137. var stream,collection;
  5138. return smalltalk.withContext(function($ctx1) {
  5139. collection=self._newCollection();
  5140. stream=self._newStream();
  5141. _st(collection)._do_((function(each){
  5142. return smalltalk.withContext(function($ctx2) {
  5143. return _st(stream).__lt_lt(each);
  5144. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  5145. self._assert_equals_(_st(stream)._contents(),collection);
  5146. return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  5147. args: [],
  5148. 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",
  5149. messageSends: ["newCollection", "newStream", "do:", "<<", "assert:equals:", "contents"],
  5150. referencedClasses: []
  5151. }),
  5152. smalltalk.StreamTest);
  5153. smalltalk.addMethod(
  5154. smalltalk.method({
  5155. selector: "testWriting",
  5156. category: 'tests',
  5157. fn: function (){
  5158. var self=this;
  5159. var stream,collection;
  5160. return smalltalk.withContext(function($ctx1) {
  5161. collection=self._newCollection();
  5162. stream=self._newStream();
  5163. _st(collection)._do_((function(each){
  5164. return smalltalk.withContext(function($ctx2) {
  5165. return _st(stream)._nextPut_(each);
  5166. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  5167. self._assert_equals_(_st(stream)._contents(),collection);
  5168. stream=self._newStream();
  5169. _st(stream)._nextPutAll_(collection);
  5170. self._assert_equals_(_st(stream)._contents(),collection);
  5171. return self}, function($ctx1) {$ctx1.fill(self,"testWriting",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  5172. args: [],
  5173. 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",
  5174. messageSends: ["newCollection", "newStream", "do:", "nextPut:", "assert:equals:", "contents", "nextPutAll:"],
  5175. referencedClasses: []
  5176. }),
  5177. smalltalk.StreamTest);
  5178. smalltalk.addMethod(
  5179. smalltalk.method({
  5180. selector: "collectionClass",
  5181. category: 'accessing',
  5182. fn: function (){
  5183. var self=this;
  5184. return smalltalk.withContext(function($ctx1) {
  5185. return nil;
  5186. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest.klass)})},
  5187. args: [],
  5188. source: "collectionClass\x0a\x09^ nil",
  5189. messageSends: [],
  5190. referencedClasses: []
  5191. }),
  5192. smalltalk.StreamTest.klass);
  5193. smalltalk.addMethod(
  5194. smalltalk.method({
  5195. selector: "isAbstract",
  5196. category: 'testing',
  5197. fn: function (){
  5198. var self=this;
  5199. return smalltalk.withContext(function($ctx1) {
  5200. var $1;
  5201. $1=_st(self._collectionClass())._isNil();
  5202. return $1;
  5203. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.StreamTest.klass)})},
  5204. args: [],
  5205. source: "isAbstract\x0a\x09^ self collectionClass isNil",
  5206. messageSends: ["isNil", "collectionClass"],
  5207. referencedClasses: []
  5208. }),
  5209. smalltalk.StreamTest.klass);
  5210. smalltalk.addClass('ArrayStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
  5211. smalltalk.addMethod(
  5212. smalltalk.method({
  5213. selector: "newCollection",
  5214. category: 'accessing',
  5215. fn: function (){
  5216. var self=this;
  5217. return smalltalk.withContext(function($ctx1) {
  5218. var $1;
  5219. $1=[true,(1),(3).__at((4)),"foo"];
  5220. return $1;
  5221. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.ArrayStreamTest)})},
  5222. args: [],
  5223. source: "newCollection\x0a\x09^ { true. 1. 3@4. 'foo' }",
  5224. messageSends: ["@"],
  5225. referencedClasses: []
  5226. }),
  5227. smalltalk.ArrayStreamTest);
  5228. smalltalk.addMethod(
  5229. smalltalk.method({
  5230. selector: "collectionClass",
  5231. category: 'accessing',
  5232. fn: function (){
  5233. var self=this;
  5234. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  5235. return smalltalk.withContext(function($ctx1) {
  5236. var $1;
  5237. $1=$Array();
  5238. return $1;
  5239. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayStreamTest.klass)})},
  5240. args: [],
  5241. source: "collectionClass\x0a\x09^ Array",
  5242. messageSends: [],
  5243. referencedClasses: ["Array"]
  5244. }),
  5245. smalltalk.ArrayStreamTest.klass);
  5246. smalltalk.addClass('StringStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
  5247. smalltalk.addMethod(
  5248. smalltalk.method({
  5249. selector: "newCollection",
  5250. category: 'accessing',
  5251. fn: function (){
  5252. var self=this;
  5253. return smalltalk.withContext(function($ctx1) {
  5254. return "hello world";
  5255. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StringStreamTest)})},
  5256. args: [],
  5257. source: "newCollection\x0a\x09^ 'hello world'",
  5258. messageSends: [],
  5259. referencedClasses: []
  5260. }),
  5261. smalltalk.StringStreamTest);
  5262. smalltalk.addMethod(
  5263. smalltalk.method({
  5264. selector: "collectionClass",
  5265. category: 'accessing',
  5266. fn: function (){
  5267. var self=this;
  5268. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  5269. return smalltalk.withContext(function($ctx1) {
  5270. var $1;
  5271. $1=$String();
  5272. return $1;
  5273. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringStreamTest.klass)})},
  5274. args: [],
  5275. source: "collectionClass\x0a\x09^ String",
  5276. messageSends: [],
  5277. referencedClasses: ["String"]
  5278. }),
  5279. smalltalk.StringStreamTest.klass);
  5280. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  5281. smalltalk.addMethod(
  5282. smalltalk.method({
  5283. selector: "testCopying",
  5284. category: 'tests',
  5285. fn: function (){
  5286. var self=this;
  5287. return smalltalk.withContext(function($ctx1) {
  5288. self._assert_equals_(nil._copy(),nil);
  5289. return self}, function($ctx1) {$ctx1.fill(self,"testCopying",{},smalltalk.UndefinedTest)})},
  5290. args: [],
  5291. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  5292. messageSends: ["assert:equals:", "copy"],
  5293. referencedClasses: []
  5294. }),
  5295. smalltalk.UndefinedTest);
  5296. smalltalk.addMethod(
  5297. smalltalk.method({
  5298. selector: "testDeepCopy",
  5299. category: 'tests',
  5300. fn: function (){
  5301. var self=this;
  5302. return smalltalk.withContext(function($ctx1) {
  5303. self._assert_(_st(nil._deepCopy()).__eq(nil));
  5304. return self}, function($ctx1) {$ctx1.fill(self,"testDeepCopy",{},smalltalk.UndefinedTest)})},
  5305. args: [],
  5306. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  5307. messageSends: ["assert:", "=", "deepCopy"],
  5308. referencedClasses: []
  5309. }),
  5310. smalltalk.UndefinedTest);
  5311. smalltalk.addMethod(
  5312. smalltalk.method({
  5313. selector: "testIfNil",
  5314. category: 'tests',
  5315. fn: function (){
  5316. var self=this;
  5317. return smalltalk.withContext(function($ctx1) {
  5318. var $1,$2,$3,$5,$4,$6,$7,$8,$10,$9;
  5319. $1=self;
  5320. if(($receiver = nil) == nil || $receiver == null){
  5321. $2=true;
  5322. } else {
  5323. $2=nil;
  5324. };
  5325. _st($1)._assert_equals_($2,true);
  5326. $3=self;
  5327. if(($receiver = nil) == nil || $receiver == null){
  5328. $5=nil;
  5329. } else {
  5330. $5=true;
  5331. };
  5332. $4=_st($5).__eq(true);
  5333. _st($3)._deny_($4);
  5334. $6=self;
  5335. if(($receiver = nil) == nil || $receiver == null){
  5336. $7=true;
  5337. } else {
  5338. $7=false;
  5339. };
  5340. _st($6)._assert_equals_($7,true);
  5341. $8=self;
  5342. if(($receiver = nil) == nil || $receiver == null){
  5343. $10=false;
  5344. } else {
  5345. $10=true;
  5346. };
  5347. $9=_st($10).__eq(true);
  5348. _st($8)._deny_($9);
  5349. return self}, function($ctx1) {$ctx1.fill(self,"testIfNil",{},smalltalk.UndefinedTest)})},
  5350. args: [],
  5351. 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",
  5352. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  5353. referencedClasses: []
  5354. }),
  5355. smalltalk.UndefinedTest);
  5356. smalltalk.addMethod(
  5357. smalltalk.method({
  5358. selector: "testIsNil",
  5359. category: 'tests',
  5360. fn: function (){
  5361. var self=this;
  5362. return smalltalk.withContext(function($ctx1) {
  5363. self._assert_(nil._isNil());
  5364. self._deny_(nil._notNil());
  5365. return self}, function($ctx1) {$ctx1.fill(self,"testIsNil",{},smalltalk.UndefinedTest)})},
  5366. args: [],
  5367. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  5368. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  5369. referencedClasses: []
  5370. }),
  5371. smalltalk.UndefinedTest);
  5372. });