Kernel-Tests.js 191 KB

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