1
0

Kernel-Tests.js 209 KB

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