Kernel-Tests.js 200 KB

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