Kernel-Tests.js 199 KB

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