Kernel-Tests.js 195 KB

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