Kernel-Tests.js 217 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185
  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: "testAddFirst",
  1893. category: 'tests',
  1894. fn: function (){
  1895. var self=this;
  1896. return smalltalk.withContext(function($ctx1) {
  1897. var $1,$2;
  1898. $1=[(2), (3), (4), (5)];
  1899. _st($1)._addFirst_((1));
  1900. $2=_st($1)._yourself();
  1901. self._assert_equals_($2,[(1), (2), (3), (4), (5)]);
  1902. return self}, function($ctx1) {$ctx1.fill(self,"testAddFirst",{},smalltalk.ArrayTest)})},
  1903. args: [],
  1904. source: "testAddFirst\x0a\x09self assert: (#(2 3 4 5) addFirst: 1; yourself) equals: #(1 2 3 4 5)",
  1905. messageSends: ["assert:equals:", "addFirst:", "yourself"],
  1906. referencedClasses: []
  1907. }),
  1908. smalltalk.ArrayTest);
  1909. smalltalk.addMethod(
  1910. smalltalk.method({
  1911. selector: "testAtIfAbsent",
  1912. category: 'tests',
  1913. fn: function (){
  1914. var self=this;
  1915. var array;
  1916. return smalltalk.withContext(function($ctx1) {
  1917. array=["hello", "world"];
  1918. self._assert_equals_(_st(array)._at_((1)),"hello");
  1919. self._assert_equals_(_st(array)._at_((2)),"world");
  1920. self._assert_equals_(_st(array)._at_ifAbsent_((2),(function(){
  1921. return smalltalk.withContext(function($ctx2) {
  1922. return "not found";
  1923. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"world");
  1924. self._assert_equals_(_st(array)._at_ifAbsent_((0),(function(){
  1925. return smalltalk.withContext(function($ctx2) {
  1926. return "not found";
  1927. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"not found");
  1928. self._assert_equals_(_st(array)._at_ifAbsent_((-10),(function(){
  1929. return smalltalk.withContext(function($ctx2) {
  1930. return "not found";
  1931. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})})),"not found");
  1932. self._assert_equals_(_st(array)._at_ifAbsent_((3),(function(){
  1933. return smalltalk.withContext(function($ctx2) {
  1934. return "not found";
  1935. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})})),"not found");
  1936. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{array:array},smalltalk.ArrayTest)})},
  1937. args: [],
  1938. 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'.",
  1939. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  1940. referencedClasses: []
  1941. }),
  1942. smalltalk.ArrayTest);
  1943. smalltalk.addMethod(
  1944. smalltalk.method({
  1945. selector: "testFirstN",
  1946. category: 'tests',
  1947. fn: function (){
  1948. var self=this;
  1949. return smalltalk.withContext(function($ctx1) {
  1950. self._assert_equals_(_st([(1),(2),(3),(4),(5)])._first_((3)),[(1),(2),(3)]);
  1951. return self}, function($ctx1) {$ctx1.fill(self,"testFirstN",{},smalltalk.ArrayTest)})},
  1952. args: [],
  1953. source: "testFirstN\x0a\x09self assert: ({1. 2. 3. 4. 5} first: 3) equals: {1. 2. 3}",
  1954. messageSends: ["assert:equals:", "first:"],
  1955. referencedClasses: []
  1956. }),
  1957. smalltalk.ArrayTest);
  1958. smalltalk.addMethod(
  1959. smalltalk.method({
  1960. selector: "testIfEmpty",
  1961. category: 'tests',
  1962. fn: function (){
  1963. var self=this;
  1964. return smalltalk.withContext(function($ctx1) {
  1965. self._assert_equals_(""._ifEmpty_((function(){
  1966. return smalltalk.withContext(function($ctx2) {
  1967. return "zork";
  1968. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"zork");
  1969. return self}, function($ctx1) {$ctx1.fill(self,"testIfEmpty",{},smalltalk.ArrayTest)})},
  1970. args: [],
  1971. source: "testIfEmpty\x0a\x09self assert: ( '' ifEmpty: ['zork'] ) equals: 'zork'",
  1972. messageSends: ["assert:equals:", "ifEmpty:"],
  1973. referencedClasses: []
  1974. }),
  1975. smalltalk.ArrayTest);
  1976. smalltalk.addMethod(
  1977. smalltalk.method({
  1978. selector: "testPrintString",
  1979. category: 'tests',
  1980. fn: function (){
  1981. var self=this;
  1982. var array;
  1983. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  1984. return smalltalk.withContext(function($ctx1) {
  1985. var $1,$2,$3,$4;
  1986. array=_st($Array())._new();
  1987. self._assert_equals_(_st(array)._printString(),"an Array ()");
  1988. $1=array;
  1989. _st($1)._add_((1));
  1990. $2=_st($1)._add_((3));
  1991. self._assert_equals_(_st(array)._printString(),"an Array (1 3)");
  1992. _st(array)._add_("foo");
  1993. self._assert_equals_(_st(array)._printString(),"an Array (1 3 'foo')");
  1994. $3=array;
  1995. _st($3)._remove_((1));
  1996. $4=_st($3)._remove_((3));
  1997. self._assert_equals_(_st(array)._printString(),"an Array ('foo')");
  1998. _st(array)._addLast_((3));
  1999. self._assert_equals_(_st(array)._printString(),"an Array ('foo' 3)");
  2000. _st(array)._addLast_((3));
  2001. self._assert_equals_(_st(array)._printString(),"an Array ('foo' 3 3)");
  2002. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{array:array},smalltalk.ArrayTest)})},
  2003. args: [],
  2004. 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)'.",
  2005. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:", "addLast:"],
  2006. referencedClasses: ["Array"]
  2007. }),
  2008. smalltalk.ArrayTest);
  2009. smalltalk.addMethod(
  2010. smalltalk.method({
  2011. selector: "testRemoveFromTo",
  2012. category: 'tests',
  2013. fn: function (){
  2014. var self=this;
  2015. return smalltalk.withContext(function($ctx1) {
  2016. self._assert_equals_([(1), (2), (3), (4)]._removeFrom_to_((1),(3)),[(4)]);
  2017. self._assert_equals_([(1), (2), (3), (4)]._removeFrom_to_((2),(3)),[(1), (4)]);
  2018. self._assert_equals_([(1), (2), (3), (4)]._removeFrom_to_((2),(4)),[(1)]);
  2019. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveFromTo",{},smalltalk.ArrayTest)})},
  2020. args: [],
  2021. 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)",
  2022. messageSends: ["assert:equals:", "removeFrom:to:"],
  2023. referencedClasses: []
  2024. }),
  2025. smalltalk.ArrayTest);
  2026. smalltalk.addMethod(
  2027. smalltalk.method({
  2028. selector: "testRemoveIndex",
  2029. category: 'tests',
  2030. fn: function (){
  2031. var self=this;
  2032. return smalltalk.withContext(function($ctx1) {
  2033. self._assert_equals_([(1), (2), (3), (4)]._removeIndex_((2)),[(1), (3), (4)]);
  2034. self._assert_equals_([(1), (2), (3), (4)]._removeIndex_((1)),[(2), (3), (4)]);
  2035. self._assert_equals_(["hello"]._removeIndex_((1)),[]);
  2036. return self}, function($ctx1) {$ctx1.fill(self,"testRemoveIndex",{},smalltalk.ArrayTest)})},
  2037. args: [],
  2038. 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: #()",
  2039. messageSends: ["assert:equals:", "removeIndex:"],
  2040. referencedClasses: []
  2041. }),
  2042. smalltalk.ArrayTest);
  2043. smalltalk.addMethod(
  2044. smalltalk.method({
  2045. selector: "collectionClass",
  2046. category: 'accessing',
  2047. fn: function (){
  2048. var self=this;
  2049. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  2050. return smalltalk.withContext(function($ctx1) {
  2051. var $1;
  2052. $1=$Array();
  2053. return $1;
  2054. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayTest.klass)})},
  2055. args: [],
  2056. source: "collectionClass\x0a\x09^ Array",
  2057. messageSends: [],
  2058. referencedClasses: ["Array"]
  2059. }),
  2060. smalltalk.ArrayTest.klass);
  2061. smalltalk.addClass('StringTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  2062. smalltalk.addMethod(
  2063. smalltalk.method({
  2064. selector: "collection",
  2065. category: 'accessing',
  2066. fn: function (){
  2067. var self=this;
  2068. return smalltalk.withContext(function($ctx1) {
  2069. return "hello";
  2070. }, function($ctx1) {$ctx1.fill(self,"collection",{},smalltalk.StringTest)})},
  2071. args: [],
  2072. source: "collection\x0a\x09^'hello'",
  2073. messageSends: [],
  2074. referencedClasses: []
  2075. }),
  2076. smalltalk.StringTest);
  2077. smalltalk.addMethod(
  2078. smalltalk.method({
  2079. selector: "collectionWithDuplicates",
  2080. category: 'accessing',
  2081. fn: function (){
  2082. var self=this;
  2083. return smalltalk.withContext(function($ctx1) {
  2084. return "abbaerte";
  2085. }, function($ctx1) {$ctx1.fill(self,"collectionWithDuplicates",{},smalltalk.StringTest)})},
  2086. args: [],
  2087. source: "collectionWithDuplicates\x0a\x09^ 'abbaerte'",
  2088. messageSends: [],
  2089. referencedClasses: []
  2090. }),
  2091. smalltalk.StringTest);
  2092. smalltalk.addMethod(
  2093. smalltalk.method({
  2094. selector: "testAddRemove",
  2095. category: 'tests',
  2096. fn: function (){
  2097. var self=this;
  2098. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2099. return smalltalk.withContext(function($ctx1) {
  2100. self._should_raise_((function(){
  2101. return smalltalk.withContext(function($ctx2) {
  2102. return "hello"._add_("a");
  2103. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2104. self._should_raise_((function(){
  2105. return smalltalk.withContext(function($ctx2) {
  2106. return "hello"._remove_("h");
  2107. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$Error());
  2108. return self}, function($ctx1) {$ctx1.fill(self,"testAddRemove",{},smalltalk.StringTest)})},
  2109. args: [],
  2110. source: "testAddRemove\x0a\x09self should: ['hello' add: 'a'] raise: Error.\x0a\x09self should: ['hello' remove: 'h'] raise: Error",
  2111. messageSends: ["should:raise:", "add:", "remove:"],
  2112. referencedClasses: ["Error"]
  2113. }),
  2114. smalltalk.StringTest);
  2115. smalltalk.addMethod(
  2116. smalltalk.method({
  2117. selector: "testAsArray",
  2118. category: 'tests',
  2119. fn: function (){
  2120. var self=this;
  2121. return smalltalk.withContext(function($ctx1) {
  2122. self._assert_equals_("hello"._asArray(),["h", "e", "l", "l", "o"]);
  2123. return self}, function($ctx1) {$ctx1.fill(self,"testAsArray",{},smalltalk.StringTest)})},
  2124. args: [],
  2125. source: "testAsArray\x0a\x09self assert: 'hello' asArray equals: #('h' 'e' 'l' 'l' 'o').",
  2126. messageSends: ["assert:equals:", "asArray"],
  2127. referencedClasses: []
  2128. }),
  2129. smalltalk.StringTest);
  2130. smalltalk.addMethod(
  2131. smalltalk.method({
  2132. selector: "testAsNumber",
  2133. category: 'tests',
  2134. fn: function (){
  2135. var self=this;
  2136. return smalltalk.withContext(function($ctx1) {
  2137. self._assert_equals_("3"._asNumber(),(3));
  2138. self._assert_equals_("-3"._asNumber(),(-3));
  2139. self._assert_equals_("-1.5"._asNumber(),(-1.5));
  2140. return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.StringTest)})},
  2141. args: [],
  2142. 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.",
  2143. messageSends: ["assert:equals:", "asNumber"],
  2144. referencedClasses: []
  2145. }),
  2146. smalltalk.StringTest);
  2147. smalltalk.addMethod(
  2148. smalltalk.method({
  2149. selector: "testAt",
  2150. category: 'tests',
  2151. fn: function (){
  2152. var self=this;
  2153. return smalltalk.withContext(function($ctx1) {
  2154. self._assert_equals_("hello"._at_((1)),"h");
  2155. self._assert_equals_("hello"._at_((5)),"o");
  2156. self._assert_equals_("hello"._at_ifAbsent_((6),(function(){
  2157. return smalltalk.withContext(function($ctx2) {
  2158. return nil;
  2159. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),nil);
  2160. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.StringTest)})},
  2161. args: [],
  2162. 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",
  2163. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  2164. referencedClasses: []
  2165. }),
  2166. smalltalk.StringTest);
  2167. smalltalk.addMethod(
  2168. smalltalk.method({
  2169. selector: "testAtPut",
  2170. category: 'tests',
  2171. fn: function (){
  2172. var self=this;
  2173. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2174. return smalltalk.withContext(function($ctx1) {
  2175. self._should_raise_((function(){
  2176. return smalltalk.withContext(function($ctx2) {
  2177. return "hello"._at_put_((1),"a");
  2178. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2179. return self}, function($ctx1) {$ctx1.fill(self,"testAtPut",{},smalltalk.StringTest)})},
  2180. args: [],
  2181. source: "testAtPut\x0a\x09\x22String instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  2182. messageSends: ["should:raise:", "at:put:"],
  2183. referencedClasses: ["Error"]
  2184. }),
  2185. smalltalk.StringTest);
  2186. smalltalk.addMethod(
  2187. smalltalk.method({
  2188. selector: "testCapitalized",
  2189. category: 'tests',
  2190. fn: function (){
  2191. var self=this;
  2192. return smalltalk.withContext(function($ctx1) {
  2193. self._assert_equals_("test"._capitalized(),"Test");
  2194. self._assert_equals_("Test"._capitalized(),"Test");
  2195. self._assert_equals_(""._capitalized(),"");
  2196. self._assert_equals_("Test"._isCapitalized(),true);
  2197. self._assert_equals_("test"._isCapitalized(),false);
  2198. return self}, function($ctx1) {$ctx1.fill(self,"testCapitalized",{},smalltalk.StringTest)})},
  2199. args: [],
  2200. 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.",
  2201. messageSends: ["assert:equals:", "capitalized", "isCapitalized"],
  2202. referencedClasses: []
  2203. }),
  2204. smalltalk.StringTest);
  2205. smalltalk.addMethod(
  2206. smalltalk.method({
  2207. selector: "testCollect",
  2208. category: 'tests',
  2209. fn: function (){
  2210. var self=this;
  2211. var newCollection;
  2212. return smalltalk.withContext(function($ctx1) {
  2213. newCollection="hheelllloo";
  2214. self._assertSameContents_as_(_st(self._collection())._collect_((function(each){
  2215. return smalltalk.withContext(function($ctx2) {
  2216. return _st(each).__comma(each);
  2217. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),newCollection);
  2218. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{newCollection:newCollection},smalltalk.StringTest)})},
  2219. args: [],
  2220. 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",
  2221. messageSends: ["assertSameContents:as:", "collect:", "collection", ","],
  2222. referencedClasses: []
  2223. }),
  2224. smalltalk.StringTest);
  2225. smalltalk.addMethod(
  2226. smalltalk.method({
  2227. selector: "testCopyWithoutAll",
  2228. category: 'tests',
  2229. fn: function (){
  2230. var self=this;
  2231. return smalltalk.withContext(function($ctx1) {
  2232. self._assert_equals_("*hello* *world*"._copyWithoutAll_("*"),"hello world");
  2233. return self}, function($ctx1) {$ctx1.fill(self,"testCopyWithoutAll",{},smalltalk.StringTest)})},
  2234. args: [],
  2235. source: "testCopyWithoutAll\x0a\x09self\x0a\x09\x09assert: ('*hello* *world*' copyWithoutAll: '*')\x0a\x09\x09equals: 'hello world'",
  2236. messageSends: ["assert:equals:", "copyWithoutAll:"],
  2237. referencedClasses: []
  2238. }),
  2239. smalltalk.StringTest);
  2240. smalltalk.addMethod(
  2241. smalltalk.method({
  2242. selector: "testDetect",
  2243. category: 'tests',
  2244. fn: function (){
  2245. var self=this;
  2246. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2247. return smalltalk.withContext(function($ctx1) {
  2248. self._assert_equals_(_st(self._collection())._detect_((function(each){
  2249. return smalltalk.withContext(function($ctx2) {
  2250. return _st(each).__eq("h");
  2251. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),"h");
  2252. self._should_raise_((function(){
  2253. return smalltalk.withContext(function($ctx2) {
  2254. return _st(self._collection())._detect_((function(each){
  2255. return smalltalk.withContext(function($ctx3) {
  2256. return _st(each).__eq((6));
  2257. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,3)})}));
  2258. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$Error());
  2259. return self}, function($ctx1) {$ctx1.fill(self,"testDetect",{},smalltalk.StringTest)})},
  2260. args: [],
  2261. 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",
  2262. messageSends: ["assert:equals:", "detect:", "collection", "=", "should:raise:"],
  2263. referencedClasses: ["Error"]
  2264. }),
  2265. smalltalk.StringTest);
  2266. smalltalk.addMethod(
  2267. smalltalk.method({
  2268. selector: "testEquality",
  2269. category: 'tests',
  2270. fn: function (){
  2271. var self=this;
  2272. return smalltalk.withContext(function($ctx1) {
  2273. self._assert_equals_("hello","hello");
  2274. self._deny_("hello".__eq("world"));
  2275. self._deny_("hello".__eq([]._at_ifAbsent_((1),(function(){
  2276. return smalltalk.withContext(function($ctx2) {
  2277. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))));
  2278. self._assert_equals_("hello","hello"._yourself());
  2279. self._assert_equals_("hello"._yourself(),"hello");
  2280. self._deny_("".__eq((0)));
  2281. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.StringTest)})},
  2282. args: [],
  2283. 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",
  2284. messageSends: ["assert:equals:", "deny:", "=", "at:ifAbsent:", "yourself"],
  2285. referencedClasses: []
  2286. }),
  2287. smalltalk.StringTest);
  2288. smalltalk.addMethod(
  2289. smalltalk.method({
  2290. selector: "testIdentity",
  2291. category: 'tests',
  2292. fn: function (){
  2293. var self=this;
  2294. return smalltalk.withContext(function($ctx1) {
  2295. self._assert_("hello".__eq_eq("hello"));
  2296. self._deny_("hello".__eq_eq("world"));
  2297. self._assert_("hello".__eq_eq("hello"._yourself()));
  2298. self._assert_(_st("hello"._yourself()).__eq_eq("hello"));
  2299. self._deny_("".__eq_eq((0)));
  2300. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.StringTest)})},
  2301. args: [],
  2302. 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",
  2303. messageSends: ["assert:", "==", "deny:", "yourself"],
  2304. referencedClasses: []
  2305. }),
  2306. smalltalk.StringTest);
  2307. smalltalk.addMethod(
  2308. smalltalk.method({
  2309. selector: "testIncludesSubString",
  2310. category: 'tests',
  2311. fn: function (){
  2312. var self=this;
  2313. return smalltalk.withContext(function($ctx1) {
  2314. self._assert_("amber"._includesSubString_("ber"));
  2315. self._deny_("amber"._includesSubString_("zork"));
  2316. return self}, function($ctx1) {$ctx1.fill(self,"testIncludesSubString",{},smalltalk.StringTest)})},
  2317. args: [],
  2318. source: "testIncludesSubString\x0a\x09self assert: ('amber' includesSubString: 'ber').\x0a\x09self deny: ('amber' includesSubString: 'zork').",
  2319. messageSends: ["assert:", "includesSubString:", "deny:"],
  2320. referencedClasses: []
  2321. }),
  2322. smalltalk.StringTest);
  2323. smalltalk.addMethod(
  2324. smalltalk.method({
  2325. selector: "testIndexOf",
  2326. category: 'tests',
  2327. fn: function (){
  2328. var self=this;
  2329. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2330. return smalltalk.withContext(function($ctx1) {
  2331. self._assert_equals_(_st(self._collection())._indexOf_("e"),(2));
  2332. self._should_raise_((function(){
  2333. return smalltalk.withContext(function($ctx2) {
  2334. return _st(self._collection())._indexOf_((999));
  2335. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2336. self._assert_equals_(_st(self._collection())._indexOf_ifAbsent_((999),(function(){
  2337. return smalltalk.withContext(function($ctx2) {
  2338. return "sentinel";
  2339. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"sentinel");
  2340. return self}, function($ctx1) {$ctx1.fill(self,"testIndexOf",{},smalltalk.StringTest)})},
  2341. args: [],
  2342. 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'",
  2343. messageSends: ["assert:equals:", "indexOf:", "collection", "should:raise:", "indexOf:ifAbsent:"],
  2344. referencedClasses: ["Error"]
  2345. }),
  2346. smalltalk.StringTest);
  2347. smalltalk.addMethod(
  2348. smalltalk.method({
  2349. selector: "testJoin",
  2350. category: 'tests',
  2351. fn: function (){
  2352. var self=this;
  2353. return smalltalk.withContext(function($ctx1) {
  2354. self._assert_equals_(","._join_(["hello", "world"]),"hello,world");
  2355. return self}, function($ctx1) {$ctx1.fill(self,"testJoin",{},smalltalk.StringTest)})},
  2356. args: [],
  2357. source: "testJoin\x0a\x09self assert: (',' join: #('hello' 'world')) equals: 'hello,world'",
  2358. messageSends: ["assert:equals:", "join:"],
  2359. referencedClasses: []
  2360. }),
  2361. smalltalk.StringTest);
  2362. smalltalk.addMethod(
  2363. smalltalk.method({
  2364. selector: "testSelect",
  2365. category: 'tests',
  2366. fn: function (){
  2367. var self=this;
  2368. var newCollection;
  2369. return smalltalk.withContext(function($ctx1) {
  2370. newCollection="o";
  2371. self._assertSameContents_as_(_st(self._collection())._select_((function(each){
  2372. return smalltalk.withContext(function($ctx2) {
  2373. return _st(each).__eq("o");
  2374. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})),newCollection);
  2375. return self}, function($ctx1) {$ctx1.fill(self,"testSelect",{newCollection:newCollection},smalltalk.StringTest)})},
  2376. args: [],
  2377. 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",
  2378. messageSends: ["assertSameContents:as:", "select:", "collection", "="],
  2379. referencedClasses: []
  2380. }),
  2381. smalltalk.StringTest);
  2382. smalltalk.addMethod(
  2383. smalltalk.method({
  2384. selector: "testSize",
  2385. category: 'tests',
  2386. fn: function (){
  2387. var self=this;
  2388. return smalltalk.withContext(function($ctx1) {
  2389. self._assert_equals_("smalltalk"._size(),(9));
  2390. self._assert_equals_(""._size(),(0));
  2391. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.StringTest)})},
  2392. args: [],
  2393. source: "testSize\x0a\x09self assert: 'smalltalk' size equals: 9.\x0a\x09self assert: '' size equals: 0",
  2394. messageSends: ["assert:equals:", "size"],
  2395. referencedClasses: []
  2396. }),
  2397. smalltalk.StringTest);
  2398. smalltalk.addMethod(
  2399. smalltalk.method({
  2400. selector: "testStreamContents",
  2401. category: 'tests',
  2402. fn: function (){
  2403. var self=this;
  2404. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2405. return smalltalk.withContext(function($ctx1) {
  2406. var $1,$2;
  2407. self._assert_equals_(_st($String())._streamContents_((function(aStream){
  2408. return smalltalk.withContext(function($ctx2) {
  2409. $1=aStream;
  2410. _st($1)._nextPutAll_("hello");
  2411. _st($1)._space();
  2412. $2=_st($1)._nextPutAll_("world");
  2413. return $2;
  2414. }, function($ctx2) {$ctx2.fillBlock({aStream:aStream},$ctx1,1)})})),"hello world");
  2415. return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StringTest)})},
  2416. args: [],
  2417. 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'",
  2418. messageSends: ["assert:equals:", "streamContents:", "nextPutAll:", "space"],
  2419. referencedClasses: ["String"]
  2420. }),
  2421. smalltalk.StringTest);
  2422. smalltalk.addMethod(
  2423. smalltalk.method({
  2424. selector: "collectionClass",
  2425. category: 'accessing',
  2426. fn: function (){
  2427. var self=this;
  2428. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  2429. return smalltalk.withContext(function($ctx1) {
  2430. var $1;
  2431. $1=$String();
  2432. return $1;
  2433. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringTest.klass)})},
  2434. args: [],
  2435. source: "collectionClass\x0a\x09^ String",
  2436. messageSends: [],
  2437. referencedClasses: ["String"]
  2438. }),
  2439. smalltalk.StringTest.klass);
  2440. smalltalk.addClass('ConsoleTranscriptTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2441. smalltalk.addMethod(
  2442. smalltalk.method({
  2443. selector: "testShow",
  2444. category: 'tests',
  2445. fn: function (){
  2446. var self=this;
  2447. var originalTranscript;
  2448. function $Transcript(){return smalltalk.Transcript||(typeof Transcript=="undefined"?nil:Transcript)}
  2449. function $ConsoleTranscript(){return smalltalk.ConsoleTranscript||(typeof ConsoleTranscript=="undefined"?nil:ConsoleTranscript)}
  2450. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2451. return smalltalk.withContext(function($ctx1) {
  2452. originalTranscript=_st($Transcript())._current();
  2453. _st($Transcript())._register_(_st($ConsoleTranscript())._new());
  2454. self._shouldnt_raise_((function(){
  2455. return smalltalk.withContext(function($ctx2) {
  2456. return _st($Transcript())._show_("Hello console!");
  2457. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  2458. self._shouldnt_raise_((function(){
  2459. return smalltalk.withContext(function($ctx2) {
  2460. return _st($Transcript())._show_(console);
  2461. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$Error());
  2462. _st($Transcript())._register_(originalTranscript);
  2463. return self}, function($ctx1) {$ctx1.fill(self,"testShow",{originalTranscript:originalTranscript},smalltalk.ConsoleTranscriptTest)})},
  2464. args: [],
  2465. 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.",
  2466. messageSends: ["current", "register:", "new", "shouldnt:raise:", "show:"],
  2467. referencedClasses: ["Transcript", "ConsoleTranscript", "Error"]
  2468. }),
  2469. smalltalk.ConsoleTranscriptTest);
  2470. smalltalk.addClass('JSObjectProxyTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2471. smalltalk.addMethod(
  2472. smalltalk.method({
  2473. selector: "jsObject",
  2474. category: 'accessing',
  2475. fn: function (){
  2476. var self=this;
  2477. return smalltalk.withContext(function($ctx1) {
  2478. return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null, 'f': void 0};
  2479. return self}, function($ctx1) {$ctx1.fill(self,"jsObject",{},smalltalk.JSObjectProxyTest)})},
  2480. args: [],
  2481. source: "jsObject\x0a\x09<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: '', 'e': null, 'f': void 0}>",
  2482. messageSends: [],
  2483. referencedClasses: []
  2484. }),
  2485. smalltalk.JSObjectProxyTest);
  2486. smalltalk.addMethod(
  2487. smalltalk.method({
  2488. selector: "testAtIfAbsent",
  2489. category: 'tests',
  2490. fn: function (){
  2491. var self=this;
  2492. var testObject;
  2493. return smalltalk.withContext(function($ctx1) {
  2494. testObject=self._jsObject();
  2495. self._assert_equals_(_st(testObject)._at_ifAbsent_("abc",(function(){
  2496. return smalltalk.withContext(function($ctx2) {
  2497. return "Property does not exist";
  2498. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})),"Property does not exist");
  2499. self._assert_equals_(_st(testObject)._at_ifAbsent_("e",(function(){
  2500. return smalltalk.withContext(function($ctx2) {
  2501. return "Property does not exist";
  2502. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),nil);
  2503. self._assert_equals_(_st(testObject)._at_ifAbsent_("a",(function(){
  2504. return smalltalk.withContext(function($ctx2) {
  2505. return "Property does not exist";
  2506. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})})),(1));
  2507. self._assert_equals_(_st(testObject)._at_ifAbsent_("f",(function(){
  2508. return smalltalk.withContext(function($ctx2) {
  2509. return "Property does not exist";
  2510. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})})),nil);
  2511. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfAbsent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2512. args: [],
  2513. 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.",
  2514. messageSends: ["jsObject", "assert:equals:", "at:ifAbsent:"],
  2515. referencedClasses: []
  2516. }),
  2517. smalltalk.JSObjectProxyTest);
  2518. smalltalk.addMethod(
  2519. smalltalk.method({
  2520. selector: "testAtIfPresent",
  2521. category: 'tests',
  2522. fn: function (){
  2523. var self=this;
  2524. var testObject;
  2525. return smalltalk.withContext(function($ctx1) {
  2526. testObject=self._jsObject();
  2527. self._assert_equals_(_st(testObject)._at_ifPresent_("abc",(function(x){
  2528. return smalltalk.withContext(function($ctx2) {
  2529. return "hello ".__comma(_st(x)._asString());
  2530. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})})),nil);
  2531. self._assert_equals_(_st(testObject)._at_ifPresent_("e",(function(x){
  2532. return smalltalk.withContext(function($ctx2) {
  2533. return "hello ".__comma(_st(x)._asString());
  2534. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,2)})})),"hello nil");
  2535. self._assert_equals_(_st(testObject)._at_ifPresent_("a",(function(x){
  2536. return smalltalk.withContext(function($ctx2) {
  2537. return "hello ".__comma(_st(x)._asString());
  2538. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,3)})})),"hello 1");
  2539. self._assert_equals_(_st(testObject)._at_ifPresent_("f",(function(x){
  2540. return smalltalk.withContext(function($ctx2) {
  2541. return "hello ".__comma(_st(x)._asString());
  2542. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,4)})})),"hello nil");
  2543. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfPresent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2544. args: [],
  2545. 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'.",
  2546. messageSends: ["jsObject", "assert:equals:", "at:ifPresent:", ",", "asString"],
  2547. referencedClasses: []
  2548. }),
  2549. smalltalk.JSObjectProxyTest);
  2550. smalltalk.addMethod(
  2551. smalltalk.method({
  2552. selector: "testAtIfPresentIfAbsent",
  2553. category: 'tests',
  2554. fn: function (){
  2555. var self=this;
  2556. var testObject;
  2557. return smalltalk.withContext(function($ctx1) {
  2558. testObject=self._jsObject();
  2559. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("abc",(function(x){
  2560. return smalltalk.withContext(function($ctx2) {
  2561. return "hello ".__comma(_st(x)._asString());
  2562. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})}),(function(){
  2563. return smalltalk.withContext(function($ctx2) {
  2564. return "not present";
  2565. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})})),"not present");
  2566. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("e",(function(x){
  2567. return smalltalk.withContext(function($ctx2) {
  2568. return "hello ".__comma(_st(x)._asString());
  2569. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,3)})}),(function(){
  2570. return smalltalk.withContext(function($ctx2) {
  2571. return "not present";
  2572. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})})),"hello nil");
  2573. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("a",(function(x){
  2574. return smalltalk.withContext(function($ctx2) {
  2575. return "hello ".__comma(_st(x)._asString());
  2576. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,5)})}),(function(){
  2577. return smalltalk.withContext(function($ctx2) {
  2578. return "not present";
  2579. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})})),"hello 1");
  2580. self._assert_equals_(_st(testObject)._at_ifPresent_ifAbsent_("f",(function(x){
  2581. return smalltalk.withContext(function($ctx2) {
  2582. return "hello ".__comma(_st(x)._asString());
  2583. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,7)})}),(function(){
  2584. return smalltalk.withContext(function($ctx2) {
  2585. return "not present";
  2586. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,8)})})),"hello nil");
  2587. return self}, function($ctx1) {$ctx1.fill(self,"testAtIfPresentIfAbsent",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2588. args: [],
  2589. 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'.",
  2590. messageSends: ["jsObject", "assert:equals:", "at:ifPresent:ifAbsent:", ",", "asString"],
  2591. referencedClasses: []
  2592. }),
  2593. smalltalk.JSObjectProxyTest);
  2594. smalltalk.addMethod(
  2595. smalltalk.method({
  2596. selector: "testDNU",
  2597. category: 'tests',
  2598. fn: function (){
  2599. var self=this;
  2600. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  2601. return smalltalk.withContext(function($ctx1) {
  2602. self._should_raise_((function(){
  2603. return smalltalk.withContext(function($ctx2) {
  2604. return _st(self._jsObject())._foo();
  2605. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  2606. return self}, function($ctx1) {$ctx1.fill(self,"testDNU",{},smalltalk.JSObjectProxyTest)})},
  2607. args: [],
  2608. source: "testDNU\x0a\x09self should: [self jsObject foo] raise: MessageNotUnderstood",
  2609. messageSends: ["should:raise:", "foo", "jsObject"],
  2610. referencedClasses: ["MessageNotUnderstood"]
  2611. }),
  2612. smalltalk.JSObjectProxyTest);
  2613. smalltalk.addMethod(
  2614. smalltalk.method({
  2615. selector: "testMessageSend",
  2616. category: 'tests',
  2617. fn: function (){
  2618. var self=this;
  2619. return smalltalk.withContext(function($ctx1) {
  2620. self._assert_equals_(_st(self._jsObject())._a(),(1));
  2621. self._assert_equals_(_st(self._jsObject())._b(),(2));
  2622. self._assert_equals_(_st(self._jsObject())._c_((3)),(3));
  2623. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.JSObjectProxyTest)})},
  2624. args: [],
  2625. 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",
  2626. messageSends: ["assert:equals:", "a", "jsObject", "b", "c:"],
  2627. referencedClasses: []
  2628. }),
  2629. smalltalk.JSObjectProxyTest);
  2630. smalltalk.addMethod(
  2631. smalltalk.method({
  2632. selector: "testMethodWithArguments",
  2633. category: 'tests',
  2634. fn: function (){
  2635. var self=this;
  2636. return smalltalk.withContext(function($ctx1) {
  2637. self._assert_equals_(_st(self._jsObject())._c_((1)),(1));
  2638. return self}, function($ctx1) {$ctx1.fill(self,"testMethodWithArguments",{},smalltalk.JSObjectProxyTest)})},
  2639. args: [],
  2640. source: "testMethodWithArguments\x0a\x09self assert: (self jsObject c: 1) equals: 1",
  2641. messageSends: ["assert:equals:", "c:", "jsObject"],
  2642. referencedClasses: []
  2643. }),
  2644. smalltalk.JSObjectProxyTest);
  2645. smalltalk.addMethod(
  2646. smalltalk.method({
  2647. selector: "testPrinting",
  2648. category: 'tests',
  2649. fn: function (){
  2650. var self=this;
  2651. return smalltalk.withContext(function($ctx1) {
  2652. self._assert_equals_(_st(self._jsObject())._printString(),"[object Object]");
  2653. return self}, function($ctx1) {$ctx1.fill(self,"testPrinting",{},smalltalk.JSObjectProxyTest)})},
  2654. args: [],
  2655. source: "testPrinting\x0a\x09self assert: self jsObject printString equals: '[object Object]'",
  2656. messageSends: ["assert:equals:", "printString", "jsObject"],
  2657. referencedClasses: []
  2658. }),
  2659. smalltalk.JSObjectProxyTest);
  2660. smalltalk.addMethod(
  2661. smalltalk.method({
  2662. selector: "testPropertyThatReturnsEmptyString",
  2663. category: 'tests',
  2664. fn: function (){
  2665. var self=this;
  2666. var object;
  2667. return smalltalk.withContext(function($ctx1) {
  2668. object=self._jsObject();
  2669. self._assert_equals_(_st(object)._d(),"");
  2670. _st(object)._d_("hello");
  2671. self._assert_equals_(_st(object)._d(),"hello");
  2672. return self}, function($ctx1) {$ctx1.fill(self,"testPropertyThatReturnsEmptyString",{object:object},smalltalk.JSObjectProxyTest)})},
  2673. args: [],
  2674. 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'",
  2675. messageSends: ["jsObject", "assert:equals:", "d", "d:"],
  2676. referencedClasses: []
  2677. }),
  2678. smalltalk.JSObjectProxyTest);
  2679. smalltalk.addMethod(
  2680. smalltalk.method({
  2681. selector: "testPropertyThatReturnsUndefined",
  2682. category: 'tests',
  2683. fn: function (){
  2684. var self=this;
  2685. var object;
  2686. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  2687. return smalltalk.withContext(function($ctx1) {
  2688. object=self._jsObject();
  2689. self._shouldnt_raise_((function(){
  2690. return smalltalk.withContext(function($ctx2) {
  2691. return _st(object)._e();
  2692. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  2693. self._assert_(_st(_st(object)._e())._isNil());
  2694. return self}, function($ctx1) {$ctx1.fill(self,"testPropertyThatReturnsUndefined",{object:object},smalltalk.JSObjectProxyTest)})},
  2695. args: [],
  2696. source: "testPropertyThatReturnsUndefined\x0a\x09| object |\x0a\x0a\x09object := self jsObject.\x0a\x09self shouldnt: [ object e ] raise: MessageNotUnderstood.\x0a\x09self assert: object e isNil",
  2697. messageSends: ["jsObject", "shouldnt:raise:", "e", "assert:", "isNil"],
  2698. referencedClasses: ["MessageNotUnderstood"]
  2699. }),
  2700. smalltalk.JSObjectProxyTest);
  2701. smalltalk.addMethod(
  2702. smalltalk.method({
  2703. selector: "testValue",
  2704. category: 'tests',
  2705. fn: function (){
  2706. var self=this;
  2707. var testObject;
  2708. return smalltalk.withContext(function($ctx1) {
  2709. testObject=self._jsObject();
  2710. self._assert_equals_(_st(_st(testObject)._value())._printString(),"[object Object]");
  2711. _st(testObject)._at_put_("value","aValue");
  2712. self._assert_equals_(_st(testObject)._value(),"aValue");
  2713. return self}, function($ctx1) {$ctx1.fill(self,"testValue",{testObject:testObject},smalltalk.JSObjectProxyTest)})},
  2714. args: [],
  2715. 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'",
  2716. messageSends: ["jsObject", "assert:equals:", "printString", "value", "at:put:"],
  2717. referencedClasses: []
  2718. }),
  2719. smalltalk.JSObjectProxyTest);
  2720. smalltalk.addMethod(
  2721. smalltalk.method({
  2722. selector: "testYourself",
  2723. category: 'tests',
  2724. fn: function (){
  2725. var self=this;
  2726. var object;
  2727. return smalltalk.withContext(function($ctx1) {
  2728. var $1,$2;
  2729. $1=self._jsObject();
  2730. _st($1)._d_("test");
  2731. $2=_st($1)._yourself();
  2732. object=$2;
  2733. self._assert_equals_(_st(object)._d(),"test");
  2734. return self}, function($ctx1) {$ctx1.fill(self,"testYourself",{object:object},smalltalk.JSObjectProxyTest)})},
  2735. args: [],
  2736. source: "testYourself\x0a\x09| object |\x0a\x09object := self jsObject\x0a\x09\x09d: 'test';\x0a\x09\x09yourself.\x0a\x0a\x09self assert: object d equals: 'test'",
  2737. messageSends: ["d:", "jsObject", "yourself", "assert:equals:", "d"],
  2738. referencedClasses: []
  2739. }),
  2740. smalltalk.JSObjectProxyTest);
  2741. smalltalk.addClass('JavaScriptExceptionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2742. smalltalk.addMethod(
  2743. smalltalk.method({
  2744. selector: "testCatchingException",
  2745. category: 'tests',
  2746. fn: function (){
  2747. var self=this;
  2748. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  2749. return smalltalk.withContext(function($ctx1) {
  2750. _st((function(){
  2751. return smalltalk.withContext(function($ctx2) {
  2752. return self._throwException();
  2753. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(error){
  2754. return smalltalk.withContext(function($ctx2) {
  2755. return self._assert_(_st(_st(error)._exception()).__eq("test"));
  2756. }, function($ctx2) {$ctx2.fillBlock({error:error},$ctx1,2)})}));
  2757. return self}, function($ctx1) {$ctx1.fill(self,"testCatchingException",{},smalltalk.JavaScriptExceptionTest)})},
  2758. args: [],
  2759. source: "testCatchingException\x0a\x09[ self throwException ]\x0a\x09\x09on: Error\x0a\x09\x09do: [ :error |\x0a\x09\x09\x09self assert: error exception = 'test' ]",
  2760. messageSends: ["on:do:", "throwException", "assert:", "=", "exception"],
  2761. referencedClasses: ["Error"]
  2762. }),
  2763. smalltalk.JavaScriptExceptionTest);
  2764. smalltalk.addMethod(
  2765. smalltalk.method({
  2766. selector: "testRaisingException",
  2767. category: 'tests',
  2768. fn: function (){
  2769. var self=this;
  2770. function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
  2771. return smalltalk.withContext(function($ctx1) {
  2772. self._should_raise_((function(){
  2773. return smalltalk.withContext(function($ctx2) {
  2774. return self._throwException();
  2775. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$JavaScriptException());
  2776. return self}, function($ctx1) {$ctx1.fill(self,"testRaisingException",{},smalltalk.JavaScriptExceptionTest)})},
  2777. args: [],
  2778. source: "testRaisingException\x0a\x09self should: [ self throwException ] raise: JavaScriptException",
  2779. messageSends: ["should:raise:", "throwException"],
  2780. referencedClasses: ["JavaScriptException"]
  2781. }),
  2782. smalltalk.JavaScriptExceptionTest);
  2783. smalltalk.addMethod(
  2784. smalltalk.method({
  2785. selector: "throwException",
  2786. category: 'helpers',
  2787. fn: function (){
  2788. var self=this;
  2789. return smalltalk.withContext(function($ctx1) {
  2790. throw 'test';
  2791. return self}, function($ctx1) {$ctx1.fill(self,"throwException",{},smalltalk.JavaScriptExceptionTest)})},
  2792. args: [],
  2793. source: "throwException\x0a\x09<throw 'test'>",
  2794. messageSends: [],
  2795. referencedClasses: []
  2796. }),
  2797. smalltalk.JavaScriptExceptionTest);
  2798. smalltalk.addClass('MessageSendTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2799. smalltalk.addMethod(
  2800. smalltalk.method({
  2801. selector: "testValue",
  2802. category: 'tests',
  2803. fn: function (){
  2804. var self=this;
  2805. var messageSend;
  2806. function $MessageSend(){return smalltalk.MessageSend||(typeof MessageSend=="undefined"?nil:MessageSend)}
  2807. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  2808. return smalltalk.withContext(function($ctx1) {
  2809. var $1,$2;
  2810. $1=_st($MessageSend())._new();
  2811. _st($1)._receiver_(_st($Object())._new());
  2812. _st($1)._selector_("asString");
  2813. $2=_st($1)._yourself();
  2814. messageSend=$2;
  2815. self._assert_equals_(_st(messageSend)._value(),"an Object");
  2816. return self}, function($ctx1) {$ctx1.fill(self,"testValue",{messageSend:messageSend},smalltalk.MessageSendTest)})},
  2817. args: [],
  2818. 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'",
  2819. messageSends: ["receiver:", "new", "selector:", "yourself", "assert:equals:", "value"],
  2820. referencedClasses: ["MessageSend", "Object"]
  2821. }),
  2822. smalltalk.MessageSendTest);
  2823. smalltalk.addMethod(
  2824. smalltalk.method({
  2825. selector: "testValueWithArguments",
  2826. category: 'tests',
  2827. fn: function (){
  2828. var self=this;
  2829. var messageSend;
  2830. function $MessageSend(){return smalltalk.MessageSend||(typeof MessageSend=="undefined"?nil:MessageSend)}
  2831. return smalltalk.withContext(function($ctx1) {
  2832. var $1,$2;
  2833. $1=_st($MessageSend())._new();
  2834. _st($1)._receiver_((2));
  2835. _st($1)._selector_("+");
  2836. $2=_st($1)._yourself();
  2837. messageSend=$2;
  2838. self._assert_equals_(_st(messageSend)._value_((3)),(5));
  2839. self._assert_equals_(_st(messageSend)._valueWithPossibleArguments_([(4)]),(6));
  2840. return self}, function($ctx1) {$ctx1.fill(self,"testValueWithArguments",{messageSend:messageSend},smalltalk.MessageSendTest)})},
  2841. args: [],
  2842. 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",
  2843. messageSends: ["receiver:", "new", "selector:", "yourself", "assert:equals:", "value:", "valueWithPossibleArguments:"],
  2844. referencedClasses: ["MessageSend"]
  2845. }),
  2846. smalltalk.MessageSendTest);
  2847. smalltalk.addClass('MethodInheritanceTest', smalltalk.TestCase, ['receiverTop', 'receiverMiddle', 'receiverBottom', 'method', 'performBlock'], 'Kernel-Tests');
  2848. smalltalk.addMethod(
  2849. smalltalk.method({
  2850. selector: "codeGeneratorClass",
  2851. category: 'accessing',
  2852. fn: function (){
  2853. var self=this;
  2854. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  2855. return smalltalk.withContext(function($ctx1) {
  2856. var $1;
  2857. $1=$CodeGenerator();
  2858. return $1;
  2859. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.MethodInheritanceTest)})},
  2860. args: [],
  2861. source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
  2862. messageSends: [],
  2863. referencedClasses: ["CodeGenerator"]
  2864. }),
  2865. smalltalk.MethodInheritanceTest);
  2866. smalltalk.addMethod(
  2867. smalltalk.method({
  2868. selector: "compiler",
  2869. category: 'factory',
  2870. fn: function (){
  2871. var self=this;
  2872. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  2873. return smalltalk.withContext(function($ctx1) {
  2874. var $2,$3,$1;
  2875. $2=_st($Compiler())._new();
  2876. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  2877. $3=_st($2)._yourself();
  2878. $1=$3;
  2879. return $1;
  2880. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.MethodInheritanceTest)})},
  2881. args: [],
  2882. source: "compiler\x0a\x09^ Compiler new\x0a\x09\x09codeGeneratorClass: self codeGeneratorClass;\x0a\x09\x09yourself",
  2883. messageSends: ["codeGeneratorClass:", "new", "codeGeneratorClass", "yourself"],
  2884. referencedClasses: ["Compiler"]
  2885. }),
  2886. smalltalk.MethodInheritanceTest);
  2887. smalltalk.addMethod(
  2888. smalltalk.method({
  2889. selector: "deinstallBottom",
  2890. category: 'testing',
  2891. fn: function (){
  2892. var self=this;
  2893. return smalltalk.withContext(function($ctx1) {
  2894. _st(self._targetClassBottom())._removeCompiledMethod_(self["@method"]);
  2895. return self}, function($ctx1) {$ctx1.fill(self,"deinstallBottom",{},smalltalk.MethodInheritanceTest)})},
  2896. args: [],
  2897. source: "deinstallBottom\x0a\x09self targetClassBottom removeCompiledMethod: method",
  2898. messageSends: ["removeCompiledMethod:", "targetClassBottom"],
  2899. referencedClasses: []
  2900. }),
  2901. smalltalk.MethodInheritanceTest);
  2902. smalltalk.addMethod(
  2903. smalltalk.method({
  2904. selector: "deinstallMiddle",
  2905. category: 'testing',
  2906. fn: function (){
  2907. var self=this;
  2908. return smalltalk.withContext(function($ctx1) {
  2909. _st(self._targetClassMiddle())._removeCompiledMethod_(self["@method"]);
  2910. return self}, function($ctx1) {$ctx1.fill(self,"deinstallMiddle",{},smalltalk.MethodInheritanceTest)})},
  2911. args: [],
  2912. source: "deinstallMiddle\x0a\x09self targetClassMiddle removeCompiledMethod: method",
  2913. messageSends: ["removeCompiledMethod:", "targetClassMiddle"],
  2914. referencedClasses: []
  2915. }),
  2916. smalltalk.MethodInheritanceTest);
  2917. smalltalk.addMethod(
  2918. smalltalk.method({
  2919. selector: "deinstallTop",
  2920. category: 'testing',
  2921. fn: function (){
  2922. var self=this;
  2923. return smalltalk.withContext(function($ctx1) {
  2924. _st(self._targetClassTop())._removeCompiledMethod_(self["@method"]);
  2925. return self}, function($ctx1) {$ctx1.fill(self,"deinstallTop",{},smalltalk.MethodInheritanceTest)})},
  2926. args: [],
  2927. source: "deinstallTop\x0a\x09self targetClassTop removeCompiledMethod: method",
  2928. messageSends: ["removeCompiledMethod:", "targetClassTop"],
  2929. referencedClasses: []
  2930. }),
  2931. smalltalk.MethodInheritanceTest);
  2932. smalltalk.addMethod(
  2933. smalltalk.method({
  2934. selector: "installBottom:",
  2935. category: 'testing',
  2936. fn: function (aString){
  2937. var self=this;
  2938. return smalltalk.withContext(function($ctx1) {
  2939. self["@method"]=_st(self._compiler())._install_forClass_category_(aString,self._targetClassBottom(),"tests");
  2940. return self}, function($ctx1) {$ctx1.fill(self,"installBottom:",{aString:aString},smalltalk.MethodInheritanceTest)})},
  2941. args: ["aString"],
  2942. source: "installBottom: aString\x0a\x09method := self compiler install: aString forClass: self targetClassBottom category: 'tests'",
  2943. messageSends: ["install:forClass:category:", "compiler", "targetClassBottom"],
  2944. referencedClasses: []
  2945. }),
  2946. smalltalk.MethodInheritanceTest);
  2947. smalltalk.addMethod(
  2948. smalltalk.method({
  2949. selector: "installMiddle:",
  2950. category: 'testing',
  2951. fn: function (aString){
  2952. var self=this;
  2953. return smalltalk.withContext(function($ctx1) {
  2954. self["@method"]=_st(self._compiler())._install_forClass_category_(aString,self._targetClassMiddle(),"tests");
  2955. return self}, function($ctx1) {$ctx1.fill(self,"installMiddle:",{aString:aString},smalltalk.MethodInheritanceTest)})},
  2956. args: ["aString"],
  2957. source: "installMiddle: aString\x0a\x09method := self compiler install: aString forClass: self targetClassMiddle category: 'tests'",
  2958. messageSends: ["install:forClass:category:", "compiler", "targetClassMiddle"],
  2959. referencedClasses: []
  2960. }),
  2961. smalltalk.MethodInheritanceTest);
  2962. smalltalk.addMethod(
  2963. smalltalk.method({
  2964. selector: "installTop:",
  2965. category: 'testing',
  2966. fn: function (aString){
  2967. var self=this;
  2968. return smalltalk.withContext(function($ctx1) {
  2969. self["@method"]=_st(self._compiler())._install_forClass_category_(aString,self._targetClassTop(),"tests");
  2970. return self}, function($ctx1) {$ctx1.fill(self,"installTop:",{aString:aString},smalltalk.MethodInheritanceTest)})},
  2971. args: ["aString"],
  2972. source: "installTop: aString\x0a\x09method := self compiler install: aString forClass: self targetClassTop category: 'tests'",
  2973. messageSends: ["install:forClass:category:", "compiler", "targetClassTop"],
  2974. referencedClasses: []
  2975. }),
  2976. smalltalk.MethodInheritanceTest);
  2977. smalltalk.addMethod(
  2978. smalltalk.method({
  2979. selector: "setUp",
  2980. category: 'initialization',
  2981. fn: function (){
  2982. var self=this;
  2983. return smalltalk.withContext(function($ctx1) {
  2984. self["@receiverTop"]=_st(self._targetClassTop())._new();
  2985. self["@receiverMiddle"]=_st(self._targetClassMiddle())._new();
  2986. self["@receiverBottom"]=_st(self._targetClassBottom())._new();
  2987. self["@method"]=nil;
  2988. self["@performBlock"]=(function(){
  2989. return smalltalk.withContext(function($ctx2) {
  2990. return self._error_("performBlock not initialized");
  2991. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})});
  2992. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.MethodInheritanceTest)})},
  2993. args: [],
  2994. 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' ]",
  2995. messageSends: ["new", "targetClassTop", "targetClassMiddle", "targetClassBottom", "error:"],
  2996. referencedClasses: []
  2997. }),
  2998. smalltalk.MethodInheritanceTest);
  2999. smalltalk.addMethod(
  3000. smalltalk.method({
  3001. selector: "shouldMNU",
  3002. category: 'testing',
  3003. fn: function (){
  3004. var self=this;
  3005. return smalltalk.withContext(function($ctx1) {
  3006. self._shouldMNUTop();
  3007. self._shouldMNUMiddle();
  3008. self._shouldMNUBottom();
  3009. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNU",{},smalltalk.MethodInheritanceTest)})},
  3010. args: [],
  3011. source: "shouldMNU\x0a\x09self shouldMNUTop.\x0a\x09self shouldMNUMiddle.\x0a\x09self shouldMNUBottom",
  3012. messageSends: ["shouldMNUTop", "shouldMNUMiddle", "shouldMNUBottom"],
  3013. referencedClasses: []
  3014. }),
  3015. smalltalk.MethodInheritanceTest);
  3016. smalltalk.addMethod(
  3017. smalltalk.method({
  3018. selector: "shouldMNUBottom",
  3019. category: 'testing',
  3020. fn: function (){
  3021. var self=this;
  3022. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3023. return smalltalk.withContext(function($ctx1) {
  3024. self._should_raise_((function(){
  3025. return smalltalk.withContext(function($ctx2) {
  3026. return _st(self["@performBlock"])._value_(self["@receiverBottom"]);
  3027. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3028. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNUBottom",{},smalltalk.MethodInheritanceTest)})},
  3029. args: [],
  3030. source: "shouldMNUBottom\x0a\x09self should: [ performBlock value: receiverBottom ] raise: MessageNotUnderstood",
  3031. messageSends: ["should:raise:", "value:"],
  3032. referencedClasses: ["MessageNotUnderstood"]
  3033. }),
  3034. smalltalk.MethodInheritanceTest);
  3035. smalltalk.addMethod(
  3036. smalltalk.method({
  3037. selector: "shouldMNUMiddle",
  3038. category: 'testing',
  3039. fn: function (){
  3040. var self=this;
  3041. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3042. return smalltalk.withContext(function($ctx1) {
  3043. self._should_raise_((function(){
  3044. return smalltalk.withContext(function($ctx2) {
  3045. return _st(self["@performBlock"])._value_(self["@receiverMiddle"]);
  3046. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3047. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNUMiddle",{},smalltalk.MethodInheritanceTest)})},
  3048. args: [],
  3049. source: "shouldMNUMiddle\x0a\x09self should: [ performBlock value: receiverMiddle ] raise: MessageNotUnderstood",
  3050. messageSends: ["should:raise:", "value:"],
  3051. referencedClasses: ["MessageNotUnderstood"]
  3052. }),
  3053. smalltalk.MethodInheritanceTest);
  3054. smalltalk.addMethod(
  3055. smalltalk.method({
  3056. selector: "shouldMNUTop",
  3057. category: 'testing',
  3058. fn: function (){
  3059. var self=this;
  3060. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3061. return smalltalk.withContext(function($ctx1) {
  3062. self._should_raise_((function(){
  3063. return smalltalk.withContext(function($ctx2) {
  3064. return _st(self["@performBlock"])._value_(self["@receiverTop"]);
  3065. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3066. return self}, function($ctx1) {$ctx1.fill(self,"shouldMNUTop",{},smalltalk.MethodInheritanceTest)})},
  3067. args: [],
  3068. source: "shouldMNUTop\x0a\x09self should: [ performBlock value: receiverTop ] raise: MessageNotUnderstood",
  3069. messageSends: ["should:raise:", "value:"],
  3070. referencedClasses: ["MessageNotUnderstood"]
  3071. }),
  3072. smalltalk.MethodInheritanceTest);
  3073. smalltalk.addMethod(
  3074. smalltalk.method({
  3075. selector: "shouldReturn:",
  3076. category: 'testing',
  3077. fn: function (anObject){
  3078. var self=this;
  3079. var result;
  3080. return smalltalk.withContext(function($ctx1) {
  3081. result=_st(self["@performBlock"])._value_(self["@receiverTop"]);
  3082. self._assert_equals_(["top",anObject],["top",result]);
  3083. result=_st(self["@performBlock"])._value_(self["@receiverMiddle"]);
  3084. self._assert_equals_(["middle",anObject],["middle",result]);
  3085. result=_st(self["@performBlock"])._value_(self["@receiverBottom"]);
  3086. self._assert_equals_(["bottom",anObject],["bottom",result]);
  3087. return self}, function($ctx1) {$ctx1.fill(self,"shouldReturn:",{anObject:anObject,result:result},smalltalk.MethodInheritanceTest)})},
  3088. args: ["anObject"],
  3089. 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 }",
  3090. messageSends: ["value:", "assert:equals:"],
  3091. referencedClasses: []
  3092. }),
  3093. smalltalk.MethodInheritanceTest);
  3094. smalltalk.addMethod(
  3095. smalltalk.method({
  3096. selector: "shouldReturn:and:and:",
  3097. category: 'testing',
  3098. fn: function (anObject,anObject2,anObject3){
  3099. var self=this;
  3100. var result;
  3101. return smalltalk.withContext(function($ctx1) {
  3102. result=_st(self["@performBlock"])._value_(self["@receiverTop"]);
  3103. self._assert_equals_(["top",anObject],["top",result]);
  3104. result=_st(self["@performBlock"])._value_(self["@receiverMiddle"]);
  3105. self._assert_equals_(["middle",anObject2],["middle",result]);
  3106. result=_st(self["@performBlock"])._value_(self["@receiverBottom"]);
  3107. self._assert_equals_(["bottom",anObject3],["bottom",result]);
  3108. return self}, function($ctx1) {$ctx1.fill(self,"shouldReturn:and:and:",{anObject:anObject,anObject2:anObject2,anObject3:anObject3,result:result},smalltalk.MethodInheritanceTest)})},
  3109. args: ["anObject", "anObject2", "anObject3"],
  3110. 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 }",
  3111. messageSends: ["value:", "assert:equals:"],
  3112. referencedClasses: []
  3113. }),
  3114. smalltalk.MethodInheritanceTest);
  3115. smalltalk.addMethod(
  3116. smalltalk.method({
  3117. selector: "targetClassBottom",
  3118. category: 'accessing',
  3119. fn: function (){
  3120. var self=this;
  3121. function $JavaScriptException(){return smalltalk.JavaScriptException||(typeof JavaScriptException=="undefined"?nil:JavaScriptException)}
  3122. return smalltalk.withContext(function($ctx1) {
  3123. var $1;
  3124. $1=$JavaScriptException();
  3125. return $1;
  3126. }, function($ctx1) {$ctx1.fill(self,"targetClassBottom",{},smalltalk.MethodInheritanceTest)})},
  3127. args: [],
  3128. source: "targetClassBottom\x0a\x09^ JavaScriptException",
  3129. messageSends: [],
  3130. referencedClasses: ["JavaScriptException"]
  3131. }),
  3132. smalltalk.MethodInheritanceTest);
  3133. smalltalk.addMethod(
  3134. smalltalk.method({
  3135. selector: "targetClassMiddle",
  3136. category: 'accessing',
  3137. fn: function (){
  3138. var self=this;
  3139. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3140. return smalltalk.withContext(function($ctx1) {
  3141. var $1;
  3142. $1=$Error();
  3143. return $1;
  3144. }, function($ctx1) {$ctx1.fill(self,"targetClassMiddle",{},smalltalk.MethodInheritanceTest)})},
  3145. args: [],
  3146. source: "targetClassMiddle\x0a\x09^ Error",
  3147. messageSends: [],
  3148. referencedClasses: ["Error"]
  3149. }),
  3150. smalltalk.MethodInheritanceTest);
  3151. smalltalk.addMethod(
  3152. smalltalk.method({
  3153. selector: "targetClassTop",
  3154. category: 'accessing',
  3155. fn: function (){
  3156. var self=this;
  3157. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3158. return smalltalk.withContext(function($ctx1) {
  3159. var $1;
  3160. $1=$Object();
  3161. return $1;
  3162. }, function($ctx1) {$ctx1.fill(self,"targetClassTop",{},smalltalk.MethodInheritanceTest)})},
  3163. args: [],
  3164. source: "targetClassTop\x0a\x09^ Object",
  3165. messageSends: [],
  3166. referencedClasses: ["Object"]
  3167. }),
  3168. smalltalk.MethodInheritanceTest);
  3169. smalltalk.addMethod(
  3170. smalltalk.method({
  3171. selector: "tearDown",
  3172. category: 'initialization',
  3173. fn: function (){
  3174. var self=this;
  3175. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3176. return smalltalk.withContext(function($ctx1) {
  3177. _st((function(){
  3178. return smalltalk.withContext(function($ctx2) {
  3179. return self._deinstallTop();
  3180. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}))._on_do_($Error(),(function(){
  3181. return smalltalk.withContext(function($ctx2) {
  3182. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  3183. _st((function(){
  3184. return smalltalk.withContext(function($ctx2) {
  3185. return self._deinstallMiddle();
  3186. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}))._on_do_($Error(),(function(){
  3187. return smalltalk.withContext(function($ctx2) {
  3188. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}));
  3189. _st((function(){
  3190. return smalltalk.withContext(function($ctx2) {
  3191. return self._deinstallBottom();
  3192. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}))._on_do_($Error(),(function(){
  3193. return smalltalk.withContext(function($ctx2) {
  3194. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}));
  3195. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.MethodInheritanceTest)})},
  3196. args: [],
  3197. source: "tearDown\x0a\x09[ self deinstallTop ] on: Error do: [].\x0a\x09[ self deinstallMiddle ] on: Error do: [].\x0a\x09[ self deinstallBottom ] on: Error do: []",
  3198. messageSends: ["on:do:", "deinstallTop", "deinstallMiddle", "deinstallBottom"],
  3199. referencedClasses: ["Error"]
  3200. }),
  3201. smalltalk.MethodInheritanceTest);
  3202. smalltalk.addMethod(
  3203. smalltalk.method({
  3204. selector: "testMNU11",
  3205. category: 'tests',
  3206. fn: function (){
  3207. var self=this;
  3208. return smalltalk.withContext(function($ctx1) {
  3209. self["@performBlock"]=(function(x){
  3210. return smalltalk.withContext(function($ctx2) {
  3211. return _st(x)._foo();
  3212. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})});
  3213. self._shouldMNU();
  3214. self._installTop_("foo ^ false");
  3215. self._installTop_("foo ^ true");
  3216. self._deinstallTop();
  3217. self._shouldMNU();
  3218. return self}, function($ctx1) {$ctx1.fill(self,"testMNU11",{},smalltalk.MethodInheritanceTest)})},
  3219. args: [],
  3220. 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",
  3221. messageSends: ["foo", "shouldMNU", "installTop:", "deinstallTop"],
  3222. referencedClasses: []
  3223. }),
  3224. smalltalk.MethodInheritanceTest);
  3225. smalltalk.addMethod(
  3226. smalltalk.method({
  3227. selector: "testMNU22",
  3228. category: 'tests',
  3229. fn: function (){
  3230. var self=this;
  3231. return smalltalk.withContext(function($ctx1) {
  3232. self["@performBlock"]=(function(x){
  3233. return smalltalk.withContext(function($ctx2) {
  3234. return _st(x)._foo();
  3235. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})});
  3236. self._shouldMNU();
  3237. self._installMiddle_("foo ^ false");
  3238. self._installMiddle_("foo ^ true");
  3239. self._deinstallMiddle();
  3240. self._shouldMNU();
  3241. return self}, function($ctx1) {$ctx1.fill(self,"testMNU22",{},smalltalk.MethodInheritanceTest)})},
  3242. args: [],
  3243. 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",
  3244. messageSends: ["foo", "shouldMNU", "installMiddle:", "deinstallMiddle"],
  3245. referencedClasses: []
  3246. }),
  3247. smalltalk.MethodInheritanceTest);
  3248. smalltalk.addMethod(
  3249. smalltalk.method({
  3250. selector: "testReturns1",
  3251. category: 'tests',
  3252. fn: function (){
  3253. var self=this;
  3254. return smalltalk.withContext(function($ctx1) {
  3255. self["@performBlock"]=(function(x){
  3256. return smalltalk.withContext(function($ctx2) {
  3257. return _st(x)._foo();
  3258. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})});
  3259. self._installTop_("foo ^ false");
  3260. self._shouldReturn_(false);
  3261. self._installTop_("foo ^ true");
  3262. self._shouldReturn_(true);
  3263. return self}, function($ctx1) {$ctx1.fill(self,"testReturns1",{},smalltalk.MethodInheritanceTest)})},
  3264. args: [],
  3265. 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",
  3266. messageSends: ["foo", "installTop:", "shouldReturn:"],
  3267. referencedClasses: []
  3268. }),
  3269. smalltalk.MethodInheritanceTest);
  3270. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3271. smalltalk.addMethod(
  3272. smalltalk.method({
  3273. selector: "testAbs",
  3274. category: 'tests',
  3275. fn: function (){
  3276. var self=this;
  3277. return smalltalk.withContext(function($ctx1) {
  3278. self._assert_equals_((4)._abs(),(4));
  3279. self._assert_equals_((-4)._abs(),(4));
  3280. return self}, function($ctx1) {$ctx1.fill(self,"testAbs",{},smalltalk.NumberTest)})},
  3281. args: [],
  3282. source: "testAbs\x0a\x09self assert: 4 abs equals: 4.\x0a\x09self assert: -4 abs equals: 4",
  3283. messageSends: ["assert:equals:", "abs"],
  3284. referencedClasses: []
  3285. }),
  3286. smalltalk.NumberTest);
  3287. smalltalk.addMethod(
  3288. smalltalk.method({
  3289. selector: "testArithmetic",
  3290. category: 'tests',
  3291. fn: function (){
  3292. var self=this;
  3293. return smalltalk.withContext(function($ctx1) {
  3294. self._assert_equals_((1.5).__plus((1)),(2.5));
  3295. self._assert_equals_((2).__minus((1)),(1));
  3296. self._assert_equals_((-2).__minus((1)),(-3));
  3297. self._assert_equals_((12).__slash((2)),(6));
  3298. self._assert_equals_((3).__star((4)),(12));
  3299. self._assert_equals_((7).__slash_slash((2)),(3));
  3300. self._assert_equals_((7).__backslash_backslash((2)),(1));
  3301. self._assert_equals_(_st((1).__plus((2))).__star((3)),(9));
  3302. self._assert_equals_((1).__plus((2).__star((3))),(7));
  3303. return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.NumberTest)})},
  3304. args: [],
  3305. 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",
  3306. messageSends: ["assert:equals:", "+", "-", "/", "*", "//", "\x5c\x5c"],
  3307. referencedClasses: []
  3308. }),
  3309. smalltalk.NumberTest);
  3310. smalltalk.addMethod(
  3311. smalltalk.method({
  3312. selector: "testAsNumber",
  3313. category: 'tests',
  3314. fn: function (){
  3315. var self=this;
  3316. return smalltalk.withContext(function($ctx1) {
  3317. self._assert_equals_((3)._asNumber(),(3));
  3318. return self}, function($ctx1) {$ctx1.fill(self,"testAsNumber",{},smalltalk.NumberTest)})},
  3319. args: [],
  3320. source: "testAsNumber\x0a\x09self assert: 3 asNumber equals: 3.",
  3321. messageSends: ["assert:equals:", "asNumber"],
  3322. referencedClasses: []
  3323. }),
  3324. smalltalk.NumberTest);
  3325. smalltalk.addMethod(
  3326. smalltalk.method({
  3327. selector: "testCeiling",
  3328. category: 'tests',
  3329. fn: function (){
  3330. var self=this;
  3331. return smalltalk.withContext(function($ctx1) {
  3332. self._assert_equals_((1.2)._ceiling(),(2));
  3333. self._assert_equals_((-1.2)._ceiling(),(-1));
  3334. self._assert_equals_((1)._ceiling(),(1));
  3335. return self}, function($ctx1) {$ctx1.fill(self,"testCeiling",{},smalltalk.NumberTest)})},
  3336. args: [],
  3337. 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.",
  3338. messageSends: ["assert:equals:", "ceiling"],
  3339. referencedClasses: []
  3340. }),
  3341. smalltalk.NumberTest);
  3342. smalltalk.addMethod(
  3343. smalltalk.method({
  3344. selector: "testComparison",
  3345. category: 'tests',
  3346. fn: function (){
  3347. var self=this;
  3348. return smalltalk.withContext(function($ctx1) {
  3349. self._assert_((3).__gt((2)));
  3350. self._assert_((2).__lt((3)));
  3351. self._deny_((3).__lt((2)));
  3352. self._deny_((2).__gt((3)));
  3353. self._assert_((3).__gt_eq((3)));
  3354. self._assert_((3.1).__gt_eq((3)));
  3355. self._assert_((3).__lt_eq((3)));
  3356. self._assert_((3).__lt_eq((3.1)));
  3357. return self}, function($ctx1) {$ctx1.fill(self,"testComparison",{},smalltalk.NumberTest)})},
  3358. args: [],
  3359. 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",
  3360. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  3361. referencedClasses: []
  3362. }),
  3363. smalltalk.NumberTest);
  3364. smalltalk.addMethod(
  3365. smalltalk.method({
  3366. selector: "testCopying",
  3367. category: 'tests',
  3368. fn: function (){
  3369. var self=this;
  3370. return smalltalk.withContext(function($ctx1) {
  3371. self._assert_(_st((1)._copy()).__eq_eq((1)));
  3372. self._assert_(_st((1)._deepCopy()).__eq_eq((1)));
  3373. return self}, function($ctx1) {$ctx1.fill(self,"testCopying",{},smalltalk.NumberTest)})},
  3374. args: [],
  3375. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  3376. messageSends: ["assert:", "==", "copy", "deepCopy"],
  3377. referencedClasses: []
  3378. }),
  3379. smalltalk.NumberTest);
  3380. smalltalk.addMethod(
  3381. smalltalk.method({
  3382. selector: "testEquality",
  3383. category: 'tests',
  3384. fn: function (){
  3385. var self=this;
  3386. return smalltalk.withContext(function($ctx1) {
  3387. self._assert_((1).__eq((1)));
  3388. self._assert_((0).__eq((0)));
  3389. self._deny_((1).__eq((0)));
  3390. self._assert_(_st((1)._yourself()).__eq((1)));
  3391. self._assert_((1).__eq((1)._yourself()));
  3392. self._assert_(_st((1)._yourself()).__eq((1)._yourself()));
  3393. self._deny_((0).__eq(false));
  3394. self._deny_(false.__eq((0)));
  3395. self._deny_("".__eq((0)));
  3396. self._deny_((0).__eq(""));
  3397. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{},smalltalk.NumberTest)})},
  3398. args: [],
  3399. 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 = ''",
  3400. messageSends: ["assert:", "=", "deny:", "yourself"],
  3401. referencedClasses: []
  3402. }),
  3403. smalltalk.NumberTest);
  3404. smalltalk.addMethod(
  3405. smalltalk.method({
  3406. selector: "testFloor",
  3407. category: 'tests',
  3408. fn: function (){
  3409. var self=this;
  3410. return smalltalk.withContext(function($ctx1) {
  3411. self._assert_equals_((1.2)._floor(),(1));
  3412. self._assert_equals_((-1.2)._floor(),(-2));
  3413. self._assert_equals_((1)._floor(),(1));
  3414. return self}, function($ctx1) {$ctx1.fill(self,"testFloor",{},smalltalk.NumberTest)})},
  3415. args: [],
  3416. 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.",
  3417. messageSends: ["assert:equals:", "floor"],
  3418. referencedClasses: []
  3419. }),
  3420. smalltalk.NumberTest);
  3421. smalltalk.addMethod(
  3422. smalltalk.method({
  3423. selector: "testHexNumbers",
  3424. category: 'tests',
  3425. fn: function (){
  3426. var self=this;
  3427. return smalltalk.withContext(function($ctx1) {
  3428. self._assert_equals_((9),(9));
  3429. self._assert_equals_((10)._truncated(),(10));
  3430. self._assert_equals_((11)._truncated(),(11));
  3431. self._assert_equals_((12)._truncated(),(12));
  3432. self._assert_equals_((13)._truncated(),(13));
  3433. self._assert_equals_((14)._truncated(),(14));
  3434. self._assert_equals_((15)._truncated(),(15));
  3435. return self}, function($ctx1) {$ctx1.fill(self,"testHexNumbers",{},smalltalk.NumberTest)})},
  3436. args: [],
  3437. 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",
  3438. messageSends: ["assert:equals:", "truncated"],
  3439. referencedClasses: []
  3440. }),
  3441. smalltalk.NumberTest);
  3442. smalltalk.addMethod(
  3443. smalltalk.method({
  3444. selector: "testIdentity",
  3445. category: 'tests',
  3446. fn: function (){
  3447. var self=this;
  3448. return smalltalk.withContext(function($ctx1) {
  3449. self._assert_((1).__eq_eq((1)));
  3450. self._assert_((0).__eq_eq((0)));
  3451. self._deny_((1).__eq_eq((0)));
  3452. self._assert_(_st((1)._yourself()).__eq_eq((1)));
  3453. self._assert_((1).__eq_eq((1)._yourself()));
  3454. self._assert_(_st((1)._yourself()).__eq_eq((1)._yourself()));
  3455. self._deny_((1).__eq_eq((2)));
  3456. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{},smalltalk.NumberTest)})},
  3457. args: [],
  3458. 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",
  3459. messageSends: ["assert:", "==", "deny:", "yourself"],
  3460. referencedClasses: []
  3461. }),
  3462. smalltalk.NumberTest);
  3463. smalltalk.addMethod(
  3464. smalltalk.method({
  3465. selector: "testInvalidHexNumbers",
  3466. category: 'tests',
  3467. fn: function (){
  3468. var self=this;
  3469. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  3470. return smalltalk.withContext(function($ctx1) {
  3471. self._should_raise_((function(){
  3472. return smalltalk.withContext(function($ctx2) {
  3473. return (16)._rG();
  3474. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  3475. self._should_raise_((function(){
  3476. return smalltalk.withContext(function($ctx2) {
  3477. return (16)._rg();
  3478. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),$MessageNotUnderstood());
  3479. self._should_raise_((function(){
  3480. return smalltalk.withContext(function($ctx2) {
  3481. return (16)._rH();
  3482. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}),$MessageNotUnderstood());
  3483. self._should_raise_((function(){
  3484. return smalltalk.withContext(function($ctx2) {
  3485. return (16)._rh();
  3486. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)})}),$MessageNotUnderstood());
  3487. self._should_raise_((function(){
  3488. return smalltalk.withContext(function($ctx2) {
  3489. return (16)._rI();
  3490. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}),$MessageNotUnderstood());
  3491. self._should_raise_((function(){
  3492. return smalltalk.withContext(function($ctx2) {
  3493. return (16)._ri();
  3494. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,6)})}),$MessageNotUnderstood());
  3495. self._should_raise_((function(){
  3496. return smalltalk.withContext(function($ctx2) {
  3497. return (16)._rJ();
  3498. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,7)})}),$MessageNotUnderstood());
  3499. self._should_raise_((function(){
  3500. return smalltalk.withContext(function($ctx2) {
  3501. return (16)._rj();
  3502. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,8)})}),$MessageNotUnderstood());
  3503. self._should_raise_((function(){
  3504. return smalltalk.withContext(function($ctx2) {
  3505. return (16)._rK();
  3506. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,9)})}),$MessageNotUnderstood());
  3507. self._should_raise_((function(){
  3508. return smalltalk.withContext(function($ctx2) {
  3509. return (16)._rk();
  3510. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,10)})}),$MessageNotUnderstood());
  3511. self._should_raise_((function(){
  3512. return smalltalk.withContext(function($ctx2) {
  3513. return (16)._rL();
  3514. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,11)})}),$MessageNotUnderstood());
  3515. self._should_raise_((function(){
  3516. return smalltalk.withContext(function($ctx2) {
  3517. return (16)._rl();
  3518. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,12)})}),$MessageNotUnderstood());
  3519. self._should_raise_((function(){
  3520. return smalltalk.withContext(function($ctx2) {
  3521. return (16)._rM();
  3522. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,13)})}),$MessageNotUnderstood());
  3523. self._should_raise_((function(){
  3524. return smalltalk.withContext(function($ctx2) {
  3525. return (16)._rm();
  3526. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,14)})}),$MessageNotUnderstood());
  3527. self._should_raise_((function(){
  3528. return smalltalk.withContext(function($ctx2) {
  3529. return (16)._rN();
  3530. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,15)})}),$MessageNotUnderstood());
  3531. self._should_raise_((function(){
  3532. return smalltalk.withContext(function($ctx2) {
  3533. return (16)._rn();
  3534. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,16)})}),$MessageNotUnderstood());
  3535. self._should_raise_((function(){
  3536. return smalltalk.withContext(function($ctx2) {
  3537. return (16)._rO();
  3538. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,17)})}),$MessageNotUnderstood());
  3539. self._should_raise_((function(){
  3540. return smalltalk.withContext(function($ctx2) {
  3541. return (16)._ro();
  3542. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,18)})}),$MessageNotUnderstood());
  3543. self._should_raise_((function(){
  3544. return smalltalk.withContext(function($ctx2) {
  3545. return (16)._rP();
  3546. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,19)})}),$MessageNotUnderstood());
  3547. self._should_raise_((function(){
  3548. return smalltalk.withContext(function($ctx2) {
  3549. return (16)._rp();
  3550. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,20)})}),$MessageNotUnderstood());
  3551. self._should_raise_((function(){
  3552. return smalltalk.withContext(function($ctx2) {
  3553. return (16)._rQ();
  3554. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,21)})}),$MessageNotUnderstood());
  3555. self._should_raise_((function(){
  3556. return smalltalk.withContext(function($ctx2) {
  3557. return (16)._rq();
  3558. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,22)})}),$MessageNotUnderstood());
  3559. self._should_raise_((function(){
  3560. return smalltalk.withContext(function($ctx2) {
  3561. return (16)._rR();
  3562. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,23)})}),$MessageNotUnderstood());
  3563. self._should_raise_((function(){
  3564. return smalltalk.withContext(function($ctx2) {
  3565. return (16)._rr();
  3566. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,24)})}),$MessageNotUnderstood());
  3567. self._should_raise_((function(){
  3568. return smalltalk.withContext(function($ctx2) {
  3569. return (16)._rS();
  3570. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,25)})}),$MessageNotUnderstood());
  3571. self._should_raise_((function(){
  3572. return smalltalk.withContext(function($ctx2) {
  3573. return (16)._rs();
  3574. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,26)})}),$MessageNotUnderstood());
  3575. self._should_raise_((function(){
  3576. return smalltalk.withContext(function($ctx2) {
  3577. return (16)._rT();
  3578. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,27)})}),$MessageNotUnderstood());
  3579. self._should_raise_((function(){
  3580. return smalltalk.withContext(function($ctx2) {
  3581. return (16)._rt();
  3582. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,28)})}),$MessageNotUnderstood());
  3583. self._should_raise_((function(){
  3584. return smalltalk.withContext(function($ctx2) {
  3585. return (16)._rU();
  3586. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,29)})}),$MessageNotUnderstood());
  3587. self._should_raise_((function(){
  3588. return smalltalk.withContext(function($ctx2) {
  3589. return (16)._ru();
  3590. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,30)})}),$MessageNotUnderstood());
  3591. self._should_raise_((function(){
  3592. return smalltalk.withContext(function($ctx2) {
  3593. return (16)._rV();
  3594. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,31)})}),$MessageNotUnderstood());
  3595. self._should_raise_((function(){
  3596. return smalltalk.withContext(function($ctx2) {
  3597. return (16)._rv();
  3598. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,32)})}),$MessageNotUnderstood());
  3599. self._should_raise_((function(){
  3600. return smalltalk.withContext(function($ctx2) {
  3601. return (16)._rW();
  3602. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,33)})}),$MessageNotUnderstood());
  3603. self._should_raise_((function(){
  3604. return smalltalk.withContext(function($ctx2) {
  3605. return (16)._rw();
  3606. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,34)})}),$MessageNotUnderstood());
  3607. self._should_raise_((function(){
  3608. return smalltalk.withContext(function($ctx2) {
  3609. return (16)._rX();
  3610. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,35)})}),$MessageNotUnderstood());
  3611. self._should_raise_((function(){
  3612. return smalltalk.withContext(function($ctx2) {
  3613. return (16)._rx();
  3614. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,36)})}),$MessageNotUnderstood());
  3615. self._should_raise_((function(){
  3616. return smalltalk.withContext(function($ctx2) {
  3617. return (16)._rY();
  3618. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,37)})}),$MessageNotUnderstood());
  3619. self._should_raise_((function(){
  3620. return smalltalk.withContext(function($ctx2) {
  3621. return (16)._ry();
  3622. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,38)})}),$MessageNotUnderstood());
  3623. self._should_raise_((function(){
  3624. return smalltalk.withContext(function($ctx2) {
  3625. return (16)._rZ();
  3626. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,39)})}),$MessageNotUnderstood());
  3627. self._should_raise_((function(){
  3628. return smalltalk.withContext(function($ctx2) {
  3629. return (16)._rz();
  3630. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,40)})}),$MessageNotUnderstood());
  3631. self._should_raise_((function(){
  3632. return smalltalk.withContext(function($ctx2) {
  3633. return (11259375)._Z();
  3634. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,41)})}),$MessageNotUnderstood());
  3635. return self}, function($ctx1) {$ctx1.fill(self,"testInvalidHexNumbers",{},smalltalk.NumberTest)})},
  3636. args: [],
  3637. 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.",
  3638. 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"],
  3639. referencedClasses: ["MessageNotUnderstood"]
  3640. }),
  3641. smalltalk.NumberTest);
  3642. smalltalk.addMethod(
  3643. smalltalk.method({
  3644. selector: "testLog",
  3645. category: 'tests',
  3646. fn: function (){
  3647. var self=this;
  3648. function $Number(){return smalltalk.Number||(typeof Number=="undefined"?nil:Number)}
  3649. return smalltalk.withContext(function($ctx1) {
  3650. self._assert_equals_((10000)._log(),(4));
  3651. self._assert_equals_((512)._log_((2)),(9));
  3652. self._assert_equals_(_st(_st($Number())._e())._ln(),(1));
  3653. return self}, function($ctx1) {$ctx1.fill(self,"testLog",{},smalltalk.NumberTest)})},
  3654. args: [],
  3655. 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.",
  3656. messageSends: ["assert:equals:", "log", "log:", "ln", "e"],
  3657. referencedClasses: ["Number"]
  3658. }),
  3659. smalltalk.NumberTest);
  3660. smalltalk.addMethod(
  3661. smalltalk.method({
  3662. selector: "testMinMax",
  3663. category: 'tests',
  3664. fn: function (){
  3665. var self=this;
  3666. return smalltalk.withContext(function($ctx1) {
  3667. self._assert_equals_((2)._max_((5)),(5));
  3668. self._assert_equals_((2)._min_((5)),(2));
  3669. return self}, function($ctx1) {$ctx1.fill(self,"testMinMax",{},smalltalk.NumberTest)})},
  3670. args: [],
  3671. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  3672. messageSends: ["assert:equals:", "max:", "min:"],
  3673. referencedClasses: []
  3674. }),
  3675. smalltalk.NumberTest);
  3676. smalltalk.addMethod(
  3677. smalltalk.method({
  3678. selector: "testNegated",
  3679. category: 'tests',
  3680. fn: function (){
  3681. var self=this;
  3682. return smalltalk.withContext(function($ctx1) {
  3683. self._assert_equals_((3)._negated(),(-3));
  3684. self._assert_equals_((-3)._negated(),(3));
  3685. return self}, function($ctx1) {$ctx1.fill(self,"testNegated",{},smalltalk.NumberTest)})},
  3686. args: [],
  3687. source: "testNegated\x0a\x09self assert: 3 negated equals: -3.\x0a\x09self assert: -3 negated equals: 3",
  3688. messageSends: ["assert:equals:", "negated"],
  3689. referencedClasses: []
  3690. }),
  3691. smalltalk.NumberTest);
  3692. smalltalk.addMethod(
  3693. smalltalk.method({
  3694. selector: "testPrintShowingDecimalPlaces",
  3695. category: 'tests',
  3696. fn: function (){
  3697. var self=this;
  3698. return smalltalk.withContext(function($ctx1) {
  3699. self._assert_equals_((23)._printShowingDecimalPlaces_((2)),"23.00");
  3700. self._assert_equals_((23.5698)._printShowingDecimalPlaces_((2)),"23.57");
  3701. self._assert_equals_(_st((234.567)._negated())._printShowingDecimalPlaces_((5)),"-234.56700");
  3702. self._assert_equals_((23.4567)._printShowingDecimalPlaces_((0)),"23");
  3703. self._assert_equals_((23.5567)._printShowingDecimalPlaces_((0)),"24");
  3704. self._assert_equals_(_st((23.4567)._negated())._printShowingDecimalPlaces_((0)),"-23");
  3705. self._assert_equals_(_st((23.5567)._negated())._printShowingDecimalPlaces_((0)),"-24");
  3706. self._assert_equals_((100000000)._printShowingDecimalPlaces_((1)),"100000000.0");
  3707. self._assert_equals_((0.98)._printShowingDecimalPlaces_((5)),"0.98000");
  3708. self._assert_equals_(_st((0.98)._negated())._printShowingDecimalPlaces_((2)),"-0.98");
  3709. self._assert_equals_((2.567)._printShowingDecimalPlaces_((2)),"2.57");
  3710. self._assert_equals_((-2.567)._printShowingDecimalPlaces_((2)),"-2.57");
  3711. self._assert_equals_((0)._printShowingDecimalPlaces_((2)),"0.00");
  3712. return self}, function($ctx1) {$ctx1.fill(self,"testPrintShowingDecimalPlaces",{},smalltalk.NumberTest)})},
  3713. args: [],
  3714. 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'.",
  3715. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  3716. referencedClasses: []
  3717. }),
  3718. smalltalk.NumberTest);
  3719. smalltalk.addMethod(
  3720. smalltalk.method({
  3721. selector: "testRaisedTo",
  3722. category: 'tests',
  3723. fn: function (){
  3724. var self=this;
  3725. return smalltalk.withContext(function($ctx1) {
  3726. self._assert_equals_((2)._raisedTo_((4)),(16));
  3727. self._assert_equals_((2)._raisedTo_((0)),(1));
  3728. self._assert_equals_((2)._raisedTo_((-3)),(0.125));
  3729. self._assert_equals_((4)._raisedTo_((0.5)),(2));
  3730. self._assert_equals_((2).__star_star((4)),(16));
  3731. return self}, function($ctx1) {$ctx1.fill(self,"testRaisedTo",{},smalltalk.NumberTest)})},
  3732. args: [],
  3733. 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.",
  3734. messageSends: ["assert:equals:", "raisedTo:", "**"],
  3735. referencedClasses: []
  3736. }),
  3737. smalltalk.NumberTest);
  3738. smalltalk.addMethod(
  3739. smalltalk.method({
  3740. selector: "testRounded",
  3741. category: 'tests',
  3742. fn: function (){
  3743. var self=this;
  3744. return smalltalk.withContext(function($ctx1) {
  3745. self._assert_equals_((3)._rounded(),(3));
  3746. self._assert_equals_((3.212)._rounded(),(3));
  3747. self._assert_equals_((3.51)._rounded(),(4));
  3748. return self}, function($ctx1) {$ctx1.fill(self,"testRounded",{},smalltalk.NumberTest)})},
  3749. args: [],
  3750. 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",
  3751. messageSends: ["assert:equals:", "rounded"],
  3752. referencedClasses: []
  3753. }),
  3754. smalltalk.NumberTest);
  3755. smalltalk.addMethod(
  3756. smalltalk.method({
  3757. selector: "testSign",
  3758. category: 'tests',
  3759. fn: function (){
  3760. var self=this;
  3761. return smalltalk.withContext(function($ctx1) {
  3762. self._assert_equals_((5)._sign(),(1));
  3763. self._assert_equals_((0)._sign(),(0));
  3764. self._assert_equals_((-1.4)._sign(),(-1));
  3765. return self}, function($ctx1) {$ctx1.fill(self,"testSign",{},smalltalk.NumberTest)})},
  3766. args: [],
  3767. source: "testSign\x0a\x09self assert: 5 sign equals: 1.\x0a\x09self assert: 0 sign equals: 0.\x0a\x09self assert: -1.4 sign equals: -1.",
  3768. messageSends: ["assert:equals:", "sign"],
  3769. referencedClasses: []
  3770. }),
  3771. smalltalk.NumberTest);
  3772. smalltalk.addMethod(
  3773. smalltalk.method({
  3774. selector: "testSqrt",
  3775. category: 'tests',
  3776. fn: function (){
  3777. var self=this;
  3778. return smalltalk.withContext(function($ctx1) {
  3779. self._assert_equals_((4)._sqrt(),(2));
  3780. self._assert_equals_((16)._sqrt(),(4));
  3781. return self}, function($ctx1) {$ctx1.fill(self,"testSqrt",{},smalltalk.NumberTest)})},
  3782. args: [],
  3783. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt equals: 2.\x0a\x09self assert: 16 sqrt equals: 4",
  3784. messageSends: ["assert:equals:", "sqrt"],
  3785. referencedClasses: []
  3786. }),
  3787. smalltalk.NumberTest);
  3788. smalltalk.addMethod(
  3789. smalltalk.method({
  3790. selector: "testSquared",
  3791. category: 'tests',
  3792. fn: function (){
  3793. var self=this;
  3794. return smalltalk.withContext(function($ctx1) {
  3795. self._assert_equals_((4)._squared(),(16));
  3796. return self}, function($ctx1) {$ctx1.fill(self,"testSquared",{},smalltalk.NumberTest)})},
  3797. args: [],
  3798. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared equals: 16",
  3799. messageSends: ["assert:equals:", "squared"],
  3800. referencedClasses: []
  3801. }),
  3802. smalltalk.NumberTest);
  3803. smalltalk.addMethod(
  3804. smalltalk.method({
  3805. selector: "testTimesRepeat",
  3806. category: 'tests',
  3807. fn: function (){
  3808. var self=this;
  3809. var i;
  3810. return smalltalk.withContext(function($ctx1) {
  3811. i=(0);
  3812. (0)._timesRepeat_((function(){
  3813. return smalltalk.withContext(function($ctx2) {
  3814. i=_st(i).__plus((1));
  3815. return i;
  3816. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  3817. self._assert_equals_(i,(0));
  3818. (5)._timesRepeat_((function(){
  3819. return smalltalk.withContext(function($ctx2) {
  3820. i=_st(i).__plus((1));
  3821. return i;
  3822. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  3823. self._assert_equals_(i,(5));
  3824. return self}, function($ctx1) {$ctx1.fill(self,"testTimesRepeat",{i:i},smalltalk.NumberTest)})},
  3825. args: [],
  3826. 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",
  3827. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  3828. referencedClasses: []
  3829. }),
  3830. smalltalk.NumberTest);
  3831. smalltalk.addMethod(
  3832. smalltalk.method({
  3833. selector: "testTo",
  3834. category: 'tests',
  3835. fn: function (){
  3836. var self=this;
  3837. return smalltalk.withContext(function($ctx1) {
  3838. self._assert_equals_((1)._to_((5)),[(1), (2), (3), (4), (5)]);
  3839. return self}, function($ctx1) {$ctx1.fill(self,"testTo",{},smalltalk.NumberTest)})},
  3840. args: [],
  3841. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  3842. messageSends: ["assert:equals:", "to:"],
  3843. referencedClasses: []
  3844. }),
  3845. smalltalk.NumberTest);
  3846. smalltalk.addMethod(
  3847. smalltalk.method({
  3848. selector: "testToBy",
  3849. category: 'tests',
  3850. fn: function (){
  3851. var self=this;
  3852. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  3853. return smalltalk.withContext(function($ctx1) {
  3854. self._assert_equals_((0)._to_by_((6),(2)),[(0), (2), (4), (6)]);
  3855. self._should_raise_((function(){
  3856. return smalltalk.withContext(function($ctx2) {
  3857. return (1)._to_by_((4),(0));
  3858. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  3859. return self}, function($ctx1) {$ctx1.fill(self,"testToBy",{},smalltalk.NumberTest)})},
  3860. args: [],
  3861. 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",
  3862. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  3863. referencedClasses: ["Error"]
  3864. }),
  3865. smalltalk.NumberTest);
  3866. smalltalk.addMethod(
  3867. smalltalk.method({
  3868. selector: "testTrigonometry",
  3869. category: 'tests',
  3870. fn: function (){
  3871. var self=this;
  3872. return smalltalk.withContext(function($ctx1) {
  3873. self._assert_equals_((0)._cos(),(1));
  3874. self._assert_equals_((0)._sin(),(0));
  3875. self._assert_equals_((0)._tan(),(0));
  3876. self._assert_equals_((1)._arcCos(),(0));
  3877. self._assert_equals_((0)._arcSin(),(0));
  3878. self._assert_equals_((0)._arcTan(),(0));
  3879. return self}, function($ctx1) {$ctx1.fill(self,"testTrigonometry",{},smalltalk.NumberTest)})},
  3880. args: [],
  3881. 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.",
  3882. messageSends: ["assert:equals:", "cos", "sin", "tan", "arcCos", "arcSin", "arcTan"],
  3883. referencedClasses: []
  3884. }),
  3885. smalltalk.NumberTest);
  3886. smalltalk.addMethod(
  3887. smalltalk.method({
  3888. selector: "testTruncated",
  3889. category: 'tests',
  3890. fn: function (){
  3891. var self=this;
  3892. return smalltalk.withContext(function($ctx1) {
  3893. self._assert_equals_((3)._truncated(),(3));
  3894. self._assert_equals_((3.212)._truncated(),(3));
  3895. self._assert_equals_((3.51)._truncated(),(3));
  3896. return self}, function($ctx1) {$ctx1.fill(self,"testTruncated",{},smalltalk.NumberTest)})},
  3897. args: [],
  3898. 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",
  3899. messageSends: ["assert:equals:", "truncated"],
  3900. referencedClasses: []
  3901. }),
  3902. smalltalk.NumberTest);
  3903. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  3904. smalltalk.ObjectMock.comment="ObjectMock is there only to perform tests on classes.";
  3905. smalltalk.addMethod(
  3906. smalltalk.method({
  3907. selector: "foo",
  3908. category: 'not yet classified',
  3909. fn: function (){
  3910. var self=this;
  3911. return smalltalk.withContext(function($ctx1) {
  3912. var $1;
  3913. $1=self["@foo"];
  3914. return $1;
  3915. }, function($ctx1) {$ctx1.fill(self,"foo",{},smalltalk.ObjectMock)})},
  3916. args: [],
  3917. source: "foo\x0a\x09^foo",
  3918. messageSends: [],
  3919. referencedClasses: []
  3920. }),
  3921. smalltalk.ObjectMock);
  3922. smalltalk.addMethod(
  3923. smalltalk.method({
  3924. selector: "foo:",
  3925. category: 'not yet classified',
  3926. fn: function (anObject){
  3927. var self=this;
  3928. return smalltalk.withContext(function($ctx1) {
  3929. self["@foo"]=anObject;
  3930. return self}, function($ctx1) {$ctx1.fill(self,"foo:",{anObject:anObject},smalltalk.ObjectMock)})},
  3931. args: ["anObject"],
  3932. source: "foo: anObject\x0a\x09foo := anObject",
  3933. messageSends: [],
  3934. referencedClasses: []
  3935. }),
  3936. smalltalk.ObjectMock);
  3937. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3938. smalltalk.addMethod(
  3939. smalltalk.method({
  3940. selector: "notDefined",
  3941. category: 'tests',
  3942. fn: function (){
  3943. var self=this;
  3944. return smalltalk.withContext(function($ctx1) {
  3945. return void 0;;
  3946. return self}, function($ctx1) {$ctx1.fill(self,"notDefined",{},smalltalk.ObjectTest)})},
  3947. args: [],
  3948. source: "notDefined\x0a\x09<return void 0;>",
  3949. messageSends: [],
  3950. referencedClasses: []
  3951. }),
  3952. smalltalk.ObjectTest);
  3953. smalltalk.addMethod(
  3954. smalltalk.method({
  3955. selector: "testBasicAccess",
  3956. category: 'tests',
  3957. fn: function (){
  3958. var self=this;
  3959. var o;
  3960. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3961. return smalltalk.withContext(function($ctx1) {
  3962. o=_st($Object())._new();
  3963. _st(o)._basicAt_put_("a",(1));
  3964. self._assert_equals_(_st(o)._basicAt_("a"),(1));
  3965. self._assert_equals_(_st(o)._basicAt_("b"),nil);
  3966. return self}, function($ctx1) {$ctx1.fill(self,"testBasicAccess",{o:o},smalltalk.ObjectTest)})},
  3967. args: [],
  3968. 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",
  3969. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  3970. referencedClasses: ["Object"]
  3971. }),
  3972. smalltalk.ObjectTest);
  3973. smalltalk.addMethod(
  3974. smalltalk.method({
  3975. selector: "testBasicPerform",
  3976. category: 'tests',
  3977. fn: function (){
  3978. var self=this;
  3979. var o;
  3980. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  3981. return smalltalk.withContext(function($ctx1) {
  3982. o=_st($Object())._new();
  3983. _st(o)._basicAt_put_("func",(function(){
  3984. return smalltalk.withContext(function($ctx2) {
  3985. return "hello";
  3986. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  3987. _st(o)._basicAt_put_("func2",(function(a){
  3988. return smalltalk.withContext(function($ctx2) {
  3989. return _st(a).__plus((1));
  3990. }, function($ctx2) {$ctx2.fillBlock({a:a},$ctx1,2)})}));
  3991. self._assert_equals_(_st(o)._basicPerform_("func"),"hello");
  3992. self._assert_equals_(_st(o)._basicPerform_withArguments_("func2",[(3)]),(4));
  3993. return self}, function($ctx1) {$ctx1.fill(self,"testBasicPerform",{o:o},smalltalk.ObjectTest)})},
  3994. args: [],
  3995. 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",
  3996. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  3997. referencedClasses: ["Object"]
  3998. }),
  3999. smalltalk.ObjectTest);
  4000. smalltalk.addMethod(
  4001. smalltalk.method({
  4002. selector: "testDNU",
  4003. category: 'tests',
  4004. fn: function (){
  4005. var self=this;
  4006. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4007. function $MessageNotUnderstood(){return smalltalk.MessageNotUnderstood||(typeof MessageNotUnderstood=="undefined"?nil:MessageNotUnderstood)}
  4008. return smalltalk.withContext(function($ctx1) {
  4009. self._should_raise_((function(){
  4010. return smalltalk.withContext(function($ctx2) {
  4011. return _st(_st($Object())._new())._foo();
  4012. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$MessageNotUnderstood());
  4013. return self}, function($ctx1) {$ctx1.fill(self,"testDNU",{},smalltalk.ObjectTest)})},
  4014. args: [],
  4015. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  4016. messageSends: ["should:raise:", "foo", "new"],
  4017. referencedClasses: ["Object", "MessageNotUnderstood"]
  4018. }),
  4019. smalltalk.ObjectTest);
  4020. smalltalk.addMethod(
  4021. smalltalk.method({
  4022. selector: "testEquality",
  4023. category: 'tests',
  4024. fn: function (){
  4025. var self=this;
  4026. var o;
  4027. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4028. return smalltalk.withContext(function($ctx1) {
  4029. o=_st($Object())._new();
  4030. self._deny_(_st(o).__eq(_st($Object())._new()));
  4031. self._assert_(_st(o).__eq(o));
  4032. self._assert_(_st(_st(o)._yourself()).__eq(o));
  4033. self._assert_(_st(o).__eq(_st(o)._yourself()));
  4034. return self}, function($ctx1) {$ctx1.fill(self,"testEquality",{o:o},smalltalk.ObjectTest)})},
  4035. args: [],
  4036. 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)",
  4037. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  4038. referencedClasses: ["Object"]
  4039. }),
  4040. smalltalk.ObjectTest);
  4041. smalltalk.addMethod(
  4042. smalltalk.method({
  4043. selector: "testHalt",
  4044. category: 'tests',
  4045. fn: function (){
  4046. var self=this;
  4047. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4048. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  4049. return smalltalk.withContext(function($ctx1) {
  4050. self._should_raise_((function(){
  4051. return smalltalk.withContext(function($ctx2) {
  4052. return _st(_st($Object())._new())._halt();
  4053. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  4054. return self}, function($ctx1) {$ctx1.fill(self,"testHalt",{},smalltalk.ObjectTest)})},
  4055. args: [],
  4056. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  4057. messageSends: ["should:raise:", "halt", "new"],
  4058. referencedClasses: ["Object", "Error"]
  4059. }),
  4060. smalltalk.ObjectTest);
  4061. smalltalk.addMethod(
  4062. smalltalk.method({
  4063. selector: "testIdentity",
  4064. category: 'tests',
  4065. fn: function (){
  4066. var self=this;
  4067. var o;
  4068. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4069. return smalltalk.withContext(function($ctx1) {
  4070. o=_st($Object())._new();
  4071. self._deny_(_st(o).__eq_eq(_st($Object())._new()));
  4072. self._assert_(_st(o).__eq_eq(o));
  4073. self._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  4074. self._assert_(_st(o).__eq_eq(_st(o)._yourself()));
  4075. return self}, function($ctx1) {$ctx1.fill(self,"testIdentity",{o:o},smalltalk.ObjectTest)})},
  4076. args: [],
  4077. 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",
  4078. messageSends: ["new", "deny:", "==", "assert:", "yourself"],
  4079. referencedClasses: ["Object"]
  4080. }),
  4081. smalltalk.ObjectTest);
  4082. smalltalk.addMethod(
  4083. smalltalk.method({
  4084. selector: "testIfNil",
  4085. category: 'tests',
  4086. fn: function (){
  4087. var self=this;
  4088. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4089. return smalltalk.withContext(function($ctx1) {
  4090. var $1,$4,$3,$2,$5,$7,$6,$8,$10,$9,$11,$13,$12;
  4091. self._deny_(_st(_st($Object())._new())._isNil());
  4092. $1=self;
  4093. $4=_st($Object())._new();
  4094. if(($receiver = $4) == nil || $receiver == null){
  4095. $3=true;
  4096. } else {
  4097. $3=$4;
  4098. };
  4099. $2=_st($3).__eq(true);
  4100. _st($1)._deny_($2);
  4101. $5=self;
  4102. $7=_st($Object())._new();
  4103. if(($receiver = $7) == nil || $receiver == null){
  4104. $6=$7;
  4105. } else {
  4106. $6=true;
  4107. };
  4108. _st($5)._assert_equals_($6,true);
  4109. $8=self;
  4110. $10=_st($Object())._new();
  4111. if(($receiver = $10) == nil || $receiver == null){
  4112. $9=false;
  4113. } else {
  4114. $9=true;
  4115. };
  4116. _st($8)._assert_equals_($9,true);
  4117. $11=self;
  4118. $13=_st($Object())._new();
  4119. if(($receiver = $13) == nil || $receiver == null){
  4120. $12=false;
  4121. } else {
  4122. $12=true;
  4123. };
  4124. _st($11)._assert_equals_($12,true);
  4125. return self}, function($ctx1) {$ctx1.fill(self,"testIfNil",{},smalltalk.ObjectTest)})},
  4126. args: [],
  4127. 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",
  4128. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:equals:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  4129. referencedClasses: ["Object"]
  4130. }),
  4131. smalltalk.ObjectTest);
  4132. smalltalk.addMethod(
  4133. smalltalk.method({
  4134. selector: "testInstVars",
  4135. category: 'tests',
  4136. fn: function (){
  4137. var self=this;
  4138. var o;
  4139. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  4140. return smalltalk.withContext(function($ctx1) {
  4141. o=_st($ObjectMock())._new();
  4142. self._assert_equals_(_st(o)._instVarAt_("foo"),nil);
  4143. _st(o)._instVarAt_put_("foo",(1));
  4144. self._assert_equals_(_st(o)._instVarAt_("foo"),(1));
  4145. self._assert_equals_(_st(o)._instVarAt_("foo"),(1));
  4146. return self}, function($ctx1) {$ctx1.fill(self,"testInstVars",{o:o},smalltalk.ObjectTest)})},
  4147. args: [],
  4148. 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",
  4149. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  4150. referencedClasses: ["ObjectMock"]
  4151. }),
  4152. smalltalk.ObjectTest);
  4153. smalltalk.addMethod(
  4154. smalltalk.method({
  4155. selector: "testNilUndefined",
  4156. category: 'tests',
  4157. fn: function (){
  4158. var self=this;
  4159. return smalltalk.withContext(function($ctx1) {
  4160. self._assert_equals_(self._notDefined(),nil);
  4161. return self}, function($ctx1) {$ctx1.fill(self,"testNilUndefined",{},smalltalk.ObjectTest)})},
  4162. args: [],
  4163. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09self assert: self notDefined equals: nil",
  4164. messageSends: ["assert:equals:", "notDefined"],
  4165. referencedClasses: []
  4166. }),
  4167. smalltalk.ObjectTest);
  4168. smalltalk.addMethod(
  4169. smalltalk.method({
  4170. selector: "testYourself",
  4171. category: 'tests',
  4172. fn: function (){
  4173. var self=this;
  4174. var o;
  4175. function $ObjectMock(){return smalltalk.ObjectMock||(typeof ObjectMock=="undefined"?nil:ObjectMock)}
  4176. return smalltalk.withContext(function($ctx1) {
  4177. o=_st($ObjectMock())._new();
  4178. self._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  4179. return self}, function($ctx1) {$ctx1.fill(self,"testYourself",{o:o},smalltalk.ObjectTest)})},
  4180. args: [],
  4181. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  4182. messageSends: ["new", "assert:", "==", "yourself"],
  4183. referencedClasses: ["ObjectMock"]
  4184. }),
  4185. smalltalk.ObjectTest);
  4186. smalltalk.addMethod(
  4187. smalltalk.method({
  4188. selector: "testidentityHash",
  4189. category: 'tests',
  4190. fn: function (){
  4191. var self=this;
  4192. var o1,o2;
  4193. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  4194. return smalltalk.withContext(function($ctx1) {
  4195. o1=_st($Object())._new();
  4196. o2=_st($Object())._new();
  4197. self._assert_(_st(_st(o1)._identityHash()).__eq_eq(_st(o1)._identityHash()));
  4198. self._deny_(_st(_st(o1)._identityHash()).__eq_eq(_st(o2)._identityHash()));
  4199. return self}, function($ctx1) {$ctx1.fill(self,"testidentityHash",{o1:o1,o2:o2},smalltalk.ObjectTest)})},
  4200. args: [],
  4201. 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",
  4202. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  4203. referencedClasses: ["Object"]
  4204. }),
  4205. smalltalk.ObjectTest);
  4206. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4207. smalltalk.addMethod(
  4208. smalltalk.method({
  4209. selector: "testAccessing",
  4210. category: 'tests',
  4211. fn: function (){
  4212. var self=this;
  4213. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  4214. return smalltalk.withContext(function($ctx1) {
  4215. self._assert_equals_(_st(_st($Point())._x_y_((3),(4)))._x(),(3));
  4216. self._assert_equals_(_st(_st($Point())._x_y_((3),(4)))._y(),(4));
  4217. self._assert_equals_(_st(_st(_st($Point())._new())._x_((3)))._x(),(3));
  4218. self._assert_equals_(_st(_st(_st($Point())._new())._y_((4)))._y(),(4));
  4219. return self}, function($ctx1) {$ctx1.fill(self,"testAccessing",{},smalltalk.PointTest)})},
  4220. args: [],
  4221. 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",
  4222. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  4223. referencedClasses: ["Point"]
  4224. }),
  4225. smalltalk.PointTest);
  4226. smalltalk.addMethod(
  4227. smalltalk.method({
  4228. selector: "testArithmetic",
  4229. category: 'tests',
  4230. fn: function (){
  4231. var self=this;
  4232. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  4233. return smalltalk.withContext(function($ctx1) {
  4234. self._assert_equals_(_st((3).__at((4))).__star((3).__at((4))),_st($Point())._x_y_((9),(16)));
  4235. self._assert_equals_(_st((3).__at((4))).__plus((3).__at((4))),_st($Point())._x_y_((6),(8)));
  4236. self._assert_equals_(_st((3).__at((4))).__minus((3).__at((4))),_st($Point())._x_y_((0),(0)));
  4237. self._assert_equals_(_st((6).__at((8))).__slash((3).__at((4))),_st($Point())._x_y_((2),(2)));
  4238. return self}, function($ctx1) {$ctx1.fill(self,"testArithmetic",{},smalltalk.PointTest)})},
  4239. args: [],
  4240. 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)",
  4241. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  4242. referencedClasses: ["Point"]
  4243. }),
  4244. smalltalk.PointTest);
  4245. smalltalk.addMethod(
  4246. smalltalk.method({
  4247. selector: "testAt",
  4248. category: 'tests',
  4249. fn: function (){
  4250. var self=this;
  4251. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  4252. return smalltalk.withContext(function($ctx1) {
  4253. self._assert_equals_((3).__at((4)),_st($Point())._x_y_((3),(4)));
  4254. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.PointTest)})},
  4255. args: [],
  4256. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  4257. messageSends: ["assert:equals:", "@", "x:y:"],
  4258. referencedClasses: ["Point"]
  4259. }),
  4260. smalltalk.PointTest);
  4261. smalltalk.addMethod(
  4262. smalltalk.method({
  4263. selector: "testEgality",
  4264. category: 'tests',
  4265. fn: function (){
  4266. var self=this;
  4267. return smalltalk.withContext(function($ctx1) {
  4268. self._assert_(_st((3).__at((4))).__eq((3).__at((4))));
  4269. self._deny_(_st((3).__at((5))).__eq((3).__at((6))));
  4270. return self}, function($ctx1) {$ctx1.fill(self,"testEgality",{},smalltalk.PointTest)})},
  4271. args: [],
  4272. source: "testEgality\x0a\x09self assert: (3@4 = (3@4)).\x0a\x09self deny: 3@5 = (3@6)",
  4273. messageSends: ["assert:", "=", "@", "deny:"],
  4274. referencedClasses: []
  4275. }),
  4276. smalltalk.PointTest);
  4277. smalltalk.addMethod(
  4278. smalltalk.method({
  4279. selector: "testTranslateBy",
  4280. category: 'tests',
  4281. fn: function (){
  4282. var self=this;
  4283. return smalltalk.withContext(function($ctx1) {
  4284. self._assert_equals_(_st((3).__at((3)))._translateBy_((0).__at((1))),(3).__at((4)));
  4285. self._assert_equals_(_st((3).__at((3)))._translateBy_((0).__at((1)._negated())),(3).__at((2)));
  4286. self._assert_equals_(_st((3).__at((3)))._translateBy_((2).__at((3))),(5).__at((6)));
  4287. self._assert_equals_(_st((3).__at((3)))._translateBy_(_st((3)._negated()).__at((0))),(0).__at((3)));
  4288. return self}, function($ctx1) {$ctx1.fill(self,"testTranslateBy",{},smalltalk.PointTest)})},
  4289. args: [],
  4290. 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.",
  4291. messageSends: ["assert:equals:", "translateBy:", "@", "negated"],
  4292. referencedClasses: []
  4293. }),
  4294. smalltalk.PointTest);
  4295. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4296. smalltalk.addMethod(
  4297. smalltalk.method({
  4298. selector: "textNext",
  4299. category: 'tests',
  4300. fn: function (){
  4301. var self=this;
  4302. function $Random(){return smalltalk.Random||(typeof Random=="undefined"?nil:Random)}
  4303. return smalltalk.withContext(function($ctx1) {
  4304. (10000)._timesRepeat_((function(){
  4305. var current,next;
  4306. return smalltalk.withContext(function($ctx2) {
  4307. next=_st(_st($Random())._new())._next();
  4308. next;
  4309. self._assert_(_st(next).__gt_eq((0)));
  4310. self._assert_(_st(next).__lt((1)));
  4311. self._deny_(_st(current).__eq(next));
  4312. return _st(next).__eq(current);
  4313. }, function($ctx2) {$ctx2.fillBlock({current:current,next:next},$ctx1,1)})}));
  4314. return self}, function($ctx1) {$ctx1.fill(self,"textNext",{},smalltalk.RandomTest)})},
  4315. args: [],
  4316. 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]",
  4317. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  4318. referencedClasses: ["Random"]
  4319. }),
  4320. smalltalk.RandomTest);
  4321. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4322. smalltalk.addMethod(
  4323. smalltalk.method({
  4324. selector: "testAddRemove",
  4325. category: 'tests',
  4326. fn: function (){
  4327. var self=this;
  4328. var set;
  4329. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4330. return smalltalk.withContext(function($ctx1) {
  4331. set=_st($Set())._new();
  4332. self._assert_(_st(set)._isEmpty());
  4333. _st(set)._add_((3));
  4334. self._assert_(_st(set)._includes_((3)));
  4335. _st(set)._add_((5));
  4336. self._assert_(_st(set)._includes_((5)));
  4337. _st(set)._remove_((3));
  4338. self._deny_(_st(set)._includes_((3)));
  4339. return self}, function($ctx1) {$ctx1.fill(self,"testAddRemove",{set:set},smalltalk.SetTest)})},
  4340. args: [],
  4341. 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)",
  4342. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  4343. referencedClasses: ["Set"]
  4344. }),
  4345. smalltalk.SetTest);
  4346. smalltalk.addMethod(
  4347. smalltalk.method({
  4348. selector: "testAt",
  4349. category: 'tests',
  4350. fn: function (){
  4351. var self=this;
  4352. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4353. function $Error(){return smalltalk.Error||(typeof Error=="undefined"?nil:Error)}
  4354. return smalltalk.withContext(function($ctx1) {
  4355. self._should_raise_((function(){
  4356. return smalltalk.withContext(function($ctx2) {
  4357. return _st(_st($Set())._new())._at_put_((1),(2));
  4358. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$Error());
  4359. return self}, function($ctx1) {$ctx1.fill(self,"testAt",{},smalltalk.SetTest)})},
  4360. args: [],
  4361. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  4362. messageSends: ["should:raise:", "at:put:", "new"],
  4363. referencedClasses: ["Set", "Error"]
  4364. }),
  4365. smalltalk.SetTest);
  4366. smalltalk.addMethod(
  4367. smalltalk.method({
  4368. selector: "testCollect",
  4369. category: 'tests',
  4370. fn: function (){
  4371. var self=this;
  4372. return smalltalk.withContext(function($ctx1) {
  4373. self._assert_equals_(_st([(5), (6), (8)]._asSet())._collect_((function(x){
  4374. return smalltalk.withContext(function($ctx2) {
  4375. return _st(x).__backslash_backslash((3));
  4376. }, function($ctx2) {$ctx2.fillBlock({x:x},$ctx1,1)})})),[(0), (2)]._asSet());
  4377. return self}, function($ctx1) {$ctx1.fill(self,"testCollect",{},smalltalk.SetTest)})},
  4378. args: [],
  4379. source: "testCollect\x0a\x09self assert: (#(5 6 8) asSet collect: [ :x | x \x5c\x5c 3 ]) equals: #(0 2) asSet",
  4380. messageSends: ["assert:equals:", "collect:", "asSet", "\x5c\x5c"],
  4381. referencedClasses: []
  4382. }),
  4383. smalltalk.SetTest);
  4384. smalltalk.addMethod(
  4385. smalltalk.method({
  4386. selector: "testComparing",
  4387. category: 'tests',
  4388. fn: function (){
  4389. var self=this;
  4390. return smalltalk.withContext(function($ctx1) {
  4391. self._assert_equals_([(0), (2)]._asSet(),[(0), (2)]._asSet());
  4392. self._assert_equals_([(2), (0)]._asSet(),[(0), (2)]._asSet());
  4393. self._deny_(_st([(0), (2), (3)]._asSet()).__eq([(0), (2)]._asSet()));
  4394. self._deny_(_st([(1), (2)]._asSet()).__eq([(0), (2)]._asSet()));
  4395. return self}, function($ctx1) {$ctx1.fill(self,"testComparing",{},smalltalk.SetTest)})},
  4396. args: [],
  4397. 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",
  4398. messageSends: ["assert:equals:", "asSet", "deny:", "="],
  4399. referencedClasses: []
  4400. }),
  4401. smalltalk.SetTest);
  4402. smalltalk.addMethod(
  4403. smalltalk.method({
  4404. selector: "testPrintString",
  4405. category: 'tests',
  4406. fn: function (){
  4407. var self=this;
  4408. var set;
  4409. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4410. return smalltalk.withContext(function($ctx1) {
  4411. var $1,$2,$3,$4;
  4412. set=_st($Set())._new();
  4413. self._assert_equals_(_st(set)._printString(),"a Set ()");
  4414. $1=set;
  4415. _st($1)._add_((1));
  4416. $2=_st($1)._add_((3));
  4417. self._assert_equals_(_st(set)._printString(),"a Set (1 3)");
  4418. _st(set)._add_("foo");
  4419. self._assert_equals_(_st(set)._printString(),"a Set (1 3 'foo')");
  4420. $3=set;
  4421. _st($3)._remove_((1));
  4422. $4=_st($3)._remove_((3));
  4423. self._assert_equals_(_st(set)._printString(),"a Set ('foo')");
  4424. _st(set)._add_((3));
  4425. self._assert_equals_(_st(set)._printString(),"a Set ('foo' 3)");
  4426. _st(set)._add_((3));
  4427. self._assert_equals_(_st(set)._printString(),"a Set ('foo' 3)");
  4428. return self}, function($ctx1) {$ctx1.fill(self,"testPrintString",{set:set},smalltalk.SetTest)})},
  4429. args: [],
  4430. 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)'",
  4431. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:"],
  4432. referencedClasses: ["Set"]
  4433. }),
  4434. smalltalk.SetTest);
  4435. smalltalk.addMethod(
  4436. smalltalk.method({
  4437. selector: "testSize",
  4438. category: 'tests',
  4439. fn: function (){
  4440. var self=this;
  4441. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4442. return smalltalk.withContext(function($ctx1) {
  4443. self._assert_equals_(_st(_st($Set())._new())._size(),(0));
  4444. self._assert_equals_(_st(_st($Set())._withAll_([(1), (2), (3), (4)]))._size(),(4));
  4445. self._assert_equals_(_st(_st($Set())._withAll_([(1), (1), (1), (1)]))._size(),(1));
  4446. return self}, function($ctx1) {$ctx1.fill(self,"testSize",{},smalltalk.SetTest)})},
  4447. args: [],
  4448. 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",
  4449. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  4450. referencedClasses: ["Set"]
  4451. }),
  4452. smalltalk.SetTest);
  4453. smalltalk.addMethod(
  4454. smalltalk.method({
  4455. selector: "testUnboxedObjects",
  4456. category: 'tests',
  4457. fn: function (){
  4458. var self=this;
  4459. return smalltalk.withContext(function($ctx1) {
  4460. self._assert_equals_(_st(_st(["foo"._yourself(),"foo"._yourself()])._asSet())._asArray(),["foo"]);
  4461. return self}, function($ctx1) {$ctx1.fill(self,"testUnboxedObjects",{},smalltalk.SetTest)})},
  4462. args: [],
  4463. source: "testUnboxedObjects\x0a\x09self assert: {'foo' yourself. 'foo' yourself} asSet asArray equals: #('foo')",
  4464. messageSends: ["assert:equals:", "asArray", "asSet", "yourself"],
  4465. referencedClasses: []
  4466. }),
  4467. smalltalk.SetTest);
  4468. smalltalk.addMethod(
  4469. smalltalk.method({
  4470. selector: "testUnicity",
  4471. category: 'tests',
  4472. fn: function (){
  4473. var self=this;
  4474. var set;
  4475. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  4476. return smalltalk.withContext(function($ctx1) {
  4477. set=_st($Set())._new();
  4478. _st(set)._add_((21));
  4479. _st(set)._add_("hello");
  4480. _st(set)._add_((21));
  4481. self._assert_equals_(_st(set)._size(),(2));
  4482. _st(set)._add_("hello");
  4483. self._assert_equals_(_st(set)._size(),(2));
  4484. self._assert_equals_(_st(set)._asArray(),[(21), "hello"]);
  4485. return self}, function($ctx1) {$ctx1.fill(self,"testUnicity",{set:set},smalltalk.SetTest)})},
  4486. args: [],
  4487. 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')",
  4488. messageSends: ["new", "add:", "assert:equals:", "size", "asArray"],
  4489. referencedClasses: ["Set"]
  4490. }),
  4491. smalltalk.SetTest);
  4492. smalltalk.addClass('StreamTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4493. smalltalk.addMethod(
  4494. smalltalk.method({
  4495. selector: "collectionClass",
  4496. category: 'accessing',
  4497. fn: function (){
  4498. var self=this;
  4499. return smalltalk.withContext(function($ctx1) {
  4500. var $1;
  4501. $1=_st(self._class())._collectionClass();
  4502. return $1;
  4503. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest)})},
  4504. args: [],
  4505. source: "collectionClass\x0a\x09^ self class collectionClass",
  4506. messageSends: ["collectionClass", "class"],
  4507. referencedClasses: []
  4508. }),
  4509. smalltalk.StreamTest);
  4510. smalltalk.addMethod(
  4511. smalltalk.method({
  4512. selector: "newCollection",
  4513. category: 'accessing',
  4514. fn: function (){
  4515. var self=this;
  4516. return smalltalk.withContext(function($ctx1) {
  4517. var $1;
  4518. $1=_st(self._collectionClass())._new();
  4519. return $1;
  4520. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StreamTest)})},
  4521. args: [],
  4522. source: "newCollection\x0a\x09^ self collectionClass new",
  4523. messageSends: ["new", "collectionClass"],
  4524. referencedClasses: []
  4525. }),
  4526. smalltalk.StreamTest);
  4527. smalltalk.addMethod(
  4528. smalltalk.method({
  4529. selector: "newStream",
  4530. category: 'accessing',
  4531. fn: function (){
  4532. var self=this;
  4533. return smalltalk.withContext(function($ctx1) {
  4534. var $1;
  4535. $1=_st(_st(self._collectionClass())._new())._stream();
  4536. return $1;
  4537. }, function($ctx1) {$ctx1.fill(self,"newStream",{},smalltalk.StreamTest)})},
  4538. args: [],
  4539. source: "newStream\x0a\x09^ self collectionClass new stream",
  4540. messageSends: ["stream", "new", "collectionClass"],
  4541. referencedClasses: []
  4542. }),
  4543. smalltalk.StreamTest);
  4544. smalltalk.addMethod(
  4545. smalltalk.method({
  4546. selector: "testAtStartAtEnd",
  4547. category: 'tests',
  4548. fn: function (){
  4549. var self=this;
  4550. var stream;
  4551. return smalltalk.withContext(function($ctx1) {
  4552. stream=self._newStream();
  4553. self._assert_(_st(stream)._atStart());
  4554. self._assert_(_st(stream)._atEnd());
  4555. _st(stream)._nextPutAll_(self._newCollection());
  4556. self._assert_(_st(stream)._atEnd());
  4557. self._deny_(_st(stream)._atStart());
  4558. _st(stream)._position_((1));
  4559. self._deny_(_st(stream)._atEnd());
  4560. self._deny_(_st(stream)._atStart());
  4561. return self}, function($ctx1) {$ctx1.fill(self,"testAtStartAtEnd",{stream:stream},smalltalk.StreamTest)})},
  4562. args: [],
  4563. 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",
  4564. messageSends: ["newStream", "assert:", "atStart", "atEnd", "nextPutAll:", "newCollection", "deny:", "position:"],
  4565. referencedClasses: []
  4566. }),
  4567. smalltalk.StreamTest);
  4568. smalltalk.addMethod(
  4569. smalltalk.method({
  4570. selector: "testContents",
  4571. category: 'tests',
  4572. fn: function (){
  4573. var self=this;
  4574. var stream;
  4575. return smalltalk.withContext(function($ctx1) {
  4576. stream=self._newStream();
  4577. _st(stream)._nextPutAll_(self._newCollection());
  4578. self._assert_equals_(_st(stream)._contents(),self._newCollection());
  4579. return self}, function($ctx1) {$ctx1.fill(self,"testContents",{stream:stream},smalltalk.StreamTest)})},
  4580. args: [],
  4581. 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",
  4582. messageSends: ["newStream", "nextPutAll:", "newCollection", "assert:equals:", "contents"],
  4583. referencedClasses: []
  4584. }),
  4585. smalltalk.StreamTest);
  4586. smalltalk.addMethod(
  4587. smalltalk.method({
  4588. selector: "testIsEmpty",
  4589. category: 'tests',
  4590. fn: function (){
  4591. var self=this;
  4592. var stream;
  4593. return smalltalk.withContext(function($ctx1) {
  4594. stream=self._newStream();
  4595. self._assert_(_st(stream)._isEmpty());
  4596. _st(stream)._nextPutAll_(self._newCollection());
  4597. self._deny_(_st(stream)._isEmpty());
  4598. return self}, function($ctx1) {$ctx1.fill(self,"testIsEmpty",{stream:stream},smalltalk.StreamTest)})},
  4599. args: [],
  4600. 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",
  4601. messageSends: ["newStream", "assert:", "isEmpty", "nextPutAll:", "newCollection", "deny:"],
  4602. referencedClasses: []
  4603. }),
  4604. smalltalk.StreamTest);
  4605. smalltalk.addMethod(
  4606. smalltalk.method({
  4607. selector: "testPosition",
  4608. category: 'tests',
  4609. fn: function (){
  4610. var self=this;
  4611. var collection,stream;
  4612. return smalltalk.withContext(function($ctx1) {
  4613. collection=self._newCollection();
  4614. stream=self._newStream();
  4615. _st(stream)._nextPutAll_(collection);
  4616. self._assert_equals_(_st(stream)._position(),_st(collection)._size());
  4617. _st(stream)._position_((0));
  4618. self._assert_equals_(_st(stream)._position(),(0));
  4619. _st(stream)._next();
  4620. self._assert_equals_(_st(stream)._position(),(1));
  4621. _st(stream)._next();
  4622. self._assert_equals_(_st(stream)._position(),(2));
  4623. return self}, function($ctx1) {$ctx1.fill(self,"testPosition",{collection:collection,stream:stream},smalltalk.StreamTest)})},
  4624. args: [],
  4625. 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",
  4626. messageSends: ["newCollection", "newStream", "nextPutAll:", "assert:equals:", "position", "size", "position:", "next"],
  4627. referencedClasses: []
  4628. }),
  4629. smalltalk.StreamTest);
  4630. smalltalk.addMethod(
  4631. smalltalk.method({
  4632. selector: "testReading",
  4633. category: 'tests',
  4634. fn: function (){
  4635. var self=this;
  4636. var stream,collection;
  4637. return smalltalk.withContext(function($ctx1) {
  4638. var $1,$2;
  4639. collection=self._newCollection();
  4640. stream=self._newStream();
  4641. $1=stream;
  4642. _st($1)._nextPutAll_(collection);
  4643. $2=_st($1)._position_((0));
  4644. _st(collection)._do_((function(each){
  4645. return smalltalk.withContext(function($ctx2) {
  4646. return self._assert_equals_(_st(stream)._next(),each);
  4647. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  4648. self._assert_(_st(_st(stream)._next())._isNil());
  4649. return self}, function($ctx1) {$ctx1.fill(self,"testReading",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  4650. args: [],
  4651. 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",
  4652. messageSends: ["newCollection", "newStream", "nextPutAll:", "position:", "do:", "assert:equals:", "next", "assert:", "isNil"],
  4653. referencedClasses: []
  4654. }),
  4655. smalltalk.StreamTest);
  4656. smalltalk.addMethod(
  4657. smalltalk.method({
  4658. selector: "testStreamContents",
  4659. category: 'tests',
  4660. fn: function (){
  4661. var self=this;
  4662. return smalltalk.withContext(function($ctx1) {
  4663. return self}, function($ctx1) {$ctx1.fill(self,"testStreamContents",{},smalltalk.StreamTest)})},
  4664. args: [],
  4665. source: "testStreamContents",
  4666. messageSends: [],
  4667. referencedClasses: []
  4668. }),
  4669. smalltalk.StreamTest);
  4670. smalltalk.addMethod(
  4671. smalltalk.method({
  4672. selector: "testWrite",
  4673. category: 'tests',
  4674. fn: function (){
  4675. var self=this;
  4676. var stream,collection;
  4677. return smalltalk.withContext(function($ctx1) {
  4678. collection=self._newCollection();
  4679. stream=self._newStream();
  4680. _st(collection)._do_((function(each){
  4681. return smalltalk.withContext(function($ctx2) {
  4682. return _st(stream).__lt_lt(each);
  4683. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  4684. self._assert_equals_(_st(stream)._contents(),collection);
  4685. return self}, function($ctx1) {$ctx1.fill(self,"testWrite",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  4686. args: [],
  4687. 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",
  4688. messageSends: ["newCollection", "newStream", "do:", "<<", "assert:equals:", "contents"],
  4689. referencedClasses: []
  4690. }),
  4691. smalltalk.StreamTest);
  4692. smalltalk.addMethod(
  4693. smalltalk.method({
  4694. selector: "testWriting",
  4695. category: 'tests',
  4696. fn: function (){
  4697. var self=this;
  4698. var stream,collection;
  4699. return smalltalk.withContext(function($ctx1) {
  4700. collection=self._newCollection();
  4701. stream=self._newStream();
  4702. _st(collection)._do_((function(each){
  4703. return smalltalk.withContext(function($ctx2) {
  4704. return _st(stream)._nextPut_(each);
  4705. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  4706. self._assert_equals_(_st(stream)._contents(),collection);
  4707. stream=self._newStream();
  4708. _st(stream)._nextPutAll_(collection);
  4709. self._assert_equals_(_st(stream)._contents(),collection);
  4710. return self}, function($ctx1) {$ctx1.fill(self,"testWriting",{stream:stream,collection:collection},smalltalk.StreamTest)})},
  4711. args: [],
  4712. 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",
  4713. messageSends: ["newCollection", "newStream", "do:", "nextPut:", "assert:equals:", "contents", "nextPutAll:"],
  4714. referencedClasses: []
  4715. }),
  4716. smalltalk.StreamTest);
  4717. smalltalk.addMethod(
  4718. smalltalk.method({
  4719. selector: "collectionClass",
  4720. category: 'accessing',
  4721. fn: function (){
  4722. var self=this;
  4723. return smalltalk.withContext(function($ctx1) {
  4724. return nil;
  4725. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StreamTest.klass)})},
  4726. args: [],
  4727. source: "collectionClass\x0a\x09^ nil",
  4728. messageSends: [],
  4729. referencedClasses: []
  4730. }),
  4731. smalltalk.StreamTest.klass);
  4732. smalltalk.addMethod(
  4733. smalltalk.method({
  4734. selector: "isAbstract",
  4735. category: 'testing',
  4736. fn: function (){
  4737. var self=this;
  4738. return smalltalk.withContext(function($ctx1) {
  4739. var $1;
  4740. $1=_st(self._collectionClass())._isNil();
  4741. return $1;
  4742. }, function($ctx1) {$ctx1.fill(self,"isAbstract",{},smalltalk.StreamTest.klass)})},
  4743. args: [],
  4744. source: "isAbstract\x0a\x09^ self collectionClass isNil",
  4745. messageSends: ["isNil", "collectionClass"],
  4746. referencedClasses: []
  4747. }),
  4748. smalltalk.StreamTest.klass);
  4749. smalltalk.addClass('ArrayStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
  4750. smalltalk.addMethod(
  4751. smalltalk.method({
  4752. selector: "newCollection",
  4753. category: 'accessing',
  4754. fn: function (){
  4755. var self=this;
  4756. return smalltalk.withContext(function($ctx1) {
  4757. var $1;
  4758. $1=[true,(1),(3).__at((4)),"foo"];
  4759. return $1;
  4760. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.ArrayStreamTest)})},
  4761. args: [],
  4762. source: "newCollection\x0a\x09^ { true. 1. 3@4. 'foo' }",
  4763. messageSends: ["@"],
  4764. referencedClasses: []
  4765. }),
  4766. smalltalk.ArrayStreamTest);
  4767. smalltalk.addMethod(
  4768. smalltalk.method({
  4769. selector: "collectionClass",
  4770. category: 'accessing',
  4771. fn: function (){
  4772. var self=this;
  4773. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  4774. return smalltalk.withContext(function($ctx1) {
  4775. var $1;
  4776. $1=$Array();
  4777. return $1;
  4778. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.ArrayStreamTest.klass)})},
  4779. args: [],
  4780. source: "collectionClass\x0a\x09^ Array",
  4781. messageSends: [],
  4782. referencedClasses: ["Array"]
  4783. }),
  4784. smalltalk.ArrayStreamTest.klass);
  4785. smalltalk.addClass('StringStreamTest', smalltalk.StreamTest, [], 'Kernel-Tests');
  4786. smalltalk.addMethod(
  4787. smalltalk.method({
  4788. selector: "newCollection",
  4789. category: 'accessing',
  4790. fn: function (){
  4791. var self=this;
  4792. return smalltalk.withContext(function($ctx1) {
  4793. return "hello world";
  4794. }, function($ctx1) {$ctx1.fill(self,"newCollection",{},smalltalk.StringStreamTest)})},
  4795. args: [],
  4796. source: "newCollection\x0a\x09^ 'hello world'",
  4797. messageSends: [],
  4798. referencedClasses: []
  4799. }),
  4800. smalltalk.StringStreamTest);
  4801. smalltalk.addMethod(
  4802. smalltalk.method({
  4803. selector: "collectionClass",
  4804. category: 'accessing',
  4805. fn: function (){
  4806. var self=this;
  4807. function $String(){return smalltalk.String||(typeof String=="undefined"?nil:String)}
  4808. return smalltalk.withContext(function($ctx1) {
  4809. var $1;
  4810. $1=$String();
  4811. return $1;
  4812. }, function($ctx1) {$ctx1.fill(self,"collectionClass",{},smalltalk.StringStreamTest.klass)})},
  4813. args: [],
  4814. source: "collectionClass\x0a\x09^ String",
  4815. messageSends: [],
  4816. referencedClasses: ["String"]
  4817. }),
  4818. smalltalk.StringStreamTest.klass);
  4819. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  4820. smalltalk.addMethod(
  4821. smalltalk.method({
  4822. selector: "testCopying",
  4823. category: 'tests',
  4824. fn: function (){
  4825. var self=this;
  4826. return smalltalk.withContext(function($ctx1) {
  4827. self._assert_equals_(nil._copy(),nil);
  4828. return self}, function($ctx1) {$ctx1.fill(self,"testCopying",{},smalltalk.UndefinedTest)})},
  4829. args: [],
  4830. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  4831. messageSends: ["assert:equals:", "copy"],
  4832. referencedClasses: []
  4833. }),
  4834. smalltalk.UndefinedTest);
  4835. smalltalk.addMethod(
  4836. smalltalk.method({
  4837. selector: "testDeepCopy",
  4838. category: 'tests',
  4839. fn: function (){
  4840. var self=this;
  4841. return smalltalk.withContext(function($ctx1) {
  4842. self._assert_(_st(nil._deepCopy()).__eq(nil));
  4843. return self}, function($ctx1) {$ctx1.fill(self,"testDeepCopy",{},smalltalk.UndefinedTest)})},
  4844. args: [],
  4845. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  4846. messageSends: ["assert:", "=", "deepCopy"],
  4847. referencedClasses: []
  4848. }),
  4849. smalltalk.UndefinedTest);
  4850. smalltalk.addMethod(
  4851. smalltalk.method({
  4852. selector: "testIfNil",
  4853. category: 'tests',
  4854. fn: function (){
  4855. var self=this;
  4856. return smalltalk.withContext(function($ctx1) {
  4857. var $1,$2,$3,$5,$4,$6,$7,$8,$10,$9;
  4858. $1=self;
  4859. if(($receiver = nil) == nil || $receiver == null){
  4860. $2=true;
  4861. } else {
  4862. $2=nil;
  4863. };
  4864. _st($1)._assert_equals_($2,true);
  4865. $3=self;
  4866. if(($receiver = nil) == nil || $receiver == null){
  4867. $5=nil;
  4868. } else {
  4869. $5=true;
  4870. };
  4871. $4=_st($5).__eq(true);
  4872. _st($3)._deny_($4);
  4873. $6=self;
  4874. if(($receiver = nil) == nil || $receiver == null){
  4875. $7=true;
  4876. } else {
  4877. $7=false;
  4878. };
  4879. _st($6)._assert_equals_($7,true);
  4880. $8=self;
  4881. if(($receiver = nil) == nil || $receiver == null){
  4882. $10=false;
  4883. } else {
  4884. $10=true;
  4885. };
  4886. $9=_st($10).__eq(true);
  4887. _st($8)._deny_($9);
  4888. return self}, function($ctx1) {$ctx1.fill(self,"testIfNil",{},smalltalk.UndefinedTest)})},
  4889. args: [],
  4890. 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",
  4891. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  4892. referencedClasses: []
  4893. }),
  4894. smalltalk.UndefinedTest);
  4895. smalltalk.addMethod(
  4896. smalltalk.method({
  4897. selector: "testIsNil",
  4898. category: 'tests',
  4899. fn: function (){
  4900. var self=this;
  4901. return smalltalk.withContext(function($ctx1) {
  4902. self._assert_(nil._isNil());
  4903. self._deny_(nil._notNil());
  4904. return self}, function($ctx1) {$ctx1.fill(self,"testIsNil",{},smalltalk.UndefinedTest)})},
  4905. args: [],
  4906. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  4907. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  4908. referencedClasses: []
  4909. }),
  4910. smalltalk.UndefinedTest);
  4911. });