Kernel-Tests.js 210 KB

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