1
0

Kernel-Tests.js 196 KB

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