Kernel-Tests.js 235 KB

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