Kernel-Tests.js 193 KB

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