Kernel-Tests.js 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318
  1. smalltalk.addPackage('Kernel-Tests', {});
  2. smalltalk.addClass('BlockClosureTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3. smalltalk.addMethod(
  4. "_testCompiledSource",
  5. smalltalk.method({
  6. selector: "testCompiledSource",
  7. category: 'tests',
  8. fn: function (){
  9. var self=this;
  10. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((function(){
  11. return _st((1)).__plus((1));
  12. }))._compiledSource())._includesSubString_("function"));
  13. return self}, self, "testCompiledSource", [], smalltalk.BlockClosureTest)},
  14. args: [],
  15. source: "testCompiledSource\x0a\x09self assert: ([1+1] compiledSource includesSubString: 'function')",
  16. messageSends: ["assert:", "includesSubString:", "compiledSource", "+"],
  17. referencedClasses: []
  18. }),
  19. smalltalk.BlockClosureTest);
  20. smalltalk.addMethod(
  21. "_testEnsure",
  22. smalltalk.method({
  23. selector: "testEnsure",
  24. category: 'tests',
  25. fn: function (){
  26. var self=this;
  27. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st((function(){
  28. return _st((smalltalk.Error || Error))._new();
  29. }))._ensure_((function(){
  30. return true;
  31. })));
  32. return self}, self, "testEnsure", [], smalltalk.BlockClosureTest)},
  33. args: [],
  34. source: "testEnsure\x0a\x09self assert: ([Error new] ensure: [true])",
  35. messageSends: ["assert:", "ensure:", "new"],
  36. referencedClasses: ["Error"]
  37. }),
  38. smalltalk.BlockClosureTest);
  39. smalltalk.addMethod(
  40. "_testNumArgs",
  41. smalltalk.method({
  42. selector: "testNumArgs",
  43. category: 'tests',
  44. fn: function (){
  45. var self=this;
  46. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((function(){
  47. }))._numArgs(),(0));
  48. _st(self)._assert_equals_(_st((function(a,b){
  49. }))._numArgs(),(2));
  50. return self}, self, "testNumArgs", [], smalltalk.BlockClosureTest)},
  51. args: [],
  52. source: "testNumArgs\x0a\x09self assert: [] numArgs equals: 0.\x0a\x09self assert: [:a :b | ] numArgs equals: 2",
  53. messageSends: ["assert:equals:", "numArgs"],
  54. referencedClasses: []
  55. }),
  56. smalltalk.BlockClosureTest);
  57. smalltalk.addMethod(
  58. "_testOnDo",
  59. smalltalk.method({
  60. selector: "testOnDo",
  61. category: 'tests',
  62. fn: function (){
  63. var self=this;
  64. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st((function(){
  65. return _st(_st((smalltalk.Error || Error))._new())._signal();
  66. }))._on_do_((smalltalk.Error || Error),(function(ex){
  67. return true;
  68. })));
  69. return self}, self, "testOnDo", [], smalltalk.BlockClosureTest)},
  70. args: [],
  71. source: "testOnDo\x0a\x09self assert: ([Error new signal] on: Error do: [:ex | true])",
  72. messageSends: ["assert:", "on:do:", "signal", "new"],
  73. referencedClasses: ["Error"]
  74. }),
  75. smalltalk.BlockClosureTest);
  76. smalltalk.addMethod(
  77. "_testValue",
  78. smalltalk.method({
  79. selector: "testValue",
  80. category: 'tests',
  81. fn: function (){
  82. var self=this;
  83. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((function(){
  84. return _st((1)).__plus((1));
  85. }))._value(),(2));
  86. _st(self)._assert_equals_(_st((function(x){
  87. return _st(x).__plus((1));
  88. }))._value_((2)),(3));
  89. _st(self)._assert_equals_(_st((function(x,y){
  90. return _st(x).__star(y);
  91. }))._value_value_((2),(4)),(8));
  92. _st(self)._assert_equals_(_st((function(a,b,c){
  93. return (1);
  94. }))._value(),(1));
  95. return self}, self, "testValue", [], smalltalk.BlockClosureTest)},
  96. args: [],
  97. 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",
  98. messageSends: ["assert:equals:", "value", "+", "value:", "value:value:", "*"],
  99. referencedClasses: []
  100. }),
  101. smalltalk.BlockClosureTest);
  102. smalltalk.addMethod(
  103. "_testValueWithPossibleArguments",
  104. smalltalk.method({
  105. selector: "testValueWithPossibleArguments",
  106. category: 'tests',
  107. fn: function (){
  108. var self=this;
  109. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((function(){
  110. return (1);
  111. }))._valueWithPossibleArguments_([(3), (4)]),(1));
  112. _st(self)._assert_equals_(_st((function(a){
  113. return _st(a).__plus((4));
  114. }))._valueWithPossibleArguments_([(3), (4)]),(7));
  115. _st(self)._assert_equals_(_st((function(a,b){
  116. return _st(a).__plus(b);
  117. }))._valueWithPossibleArguments_([(3), (4), (5)]),(7));
  118. return self}, self, "testValueWithPossibleArguments", [], smalltalk.BlockClosureTest)},
  119. args: [],
  120. 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.",
  121. messageSends: ["assert:equals:", "valueWithPossibleArguments:", "+"],
  122. referencedClasses: []
  123. }),
  124. smalltalk.BlockClosureTest);
  125. smalltalk.addMethod(
  126. "_testWhileFalse",
  127. smalltalk.method({
  128. selector: "testWhileFalse",
  129. category: 'tests',
  130. fn: function (){
  131. var self=this;
  132. return smalltalk.withContext(function($ctx) { var i;
  133. i=(0);
  134. _st((function(){
  135. return _st(i).__gt((5));
  136. }))._whileFalse_((function(){
  137. i=_st(i).__plus((1));
  138. return i;
  139. }));
  140. _st(self)._assert_equals_(i,(6));
  141. i=(0);
  142. _st((function(){
  143. i=_st(i).__plus((1));
  144. i;
  145. return _st(i).__gt((5));
  146. }))._whileFalse();
  147. _st(self)._assert_equals_(i,(6));
  148. return self}, self, "testWhileFalse", [], smalltalk.BlockClosureTest)},
  149. args: [],
  150. 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",
  151. messageSends: ["whileFalse:", "+", ">", "assert:equals:", "whileFalse"],
  152. referencedClasses: []
  153. }),
  154. smalltalk.BlockClosureTest);
  155. smalltalk.addMethod(
  156. "_testWhileTrue",
  157. smalltalk.method({
  158. selector: "testWhileTrue",
  159. category: 'tests',
  160. fn: function (){
  161. var self=this;
  162. return smalltalk.withContext(function($ctx) { var i;
  163. i=(0);
  164. _st((function(){
  165. return _st(i).__lt((5));
  166. }))._whileTrue_((function(){
  167. i=_st(i).__plus((1));
  168. return i;
  169. }));
  170. _st(self)._assert_equals_(i,(5));
  171. i=(0);
  172. _st((function(){
  173. i=_st(i).__plus((1));
  174. i;
  175. return _st(i).__lt((5));
  176. }))._whileTrue();
  177. _st(self)._assert_equals_(i,(5));
  178. return self}, self, "testWhileTrue", [], smalltalk.BlockClosureTest)},
  179. args: [],
  180. 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",
  181. messageSends: ["whileTrue:", "+", "<", "assert:equals:", "whileTrue"],
  182. referencedClasses: []
  183. }),
  184. smalltalk.BlockClosureTest);
  185. smalltalk.addClass('BooleanTest', smalltalk.TestCase, [], 'Kernel-Tests');
  186. smalltalk.addMethod(
  187. "_testEquality",
  188. smalltalk.method({
  189. selector: "testEquality",
  190. category: 'tests',
  191. fn: function (){
  192. var self=this;
  193. return smalltalk.withContext(function($ctx) { _st(self)._deny_(_st((0)).__eq(false));
  194. _st(self)._deny_(_st(false).__eq((0)));
  195. _st(self)._deny_(_st("").__eq(false));
  196. _st(self)._deny_(_st(false).__eq(""));
  197. _st(self)._assert_(_st(true).__eq(true));
  198. _st(self)._deny_(_st(false).__eq(true));
  199. _st(self)._deny_(_st(true).__eq(false));
  200. _st(self)._assert_(_st(false).__eq(false));
  201. _st(self)._assert_(_st(_st(true)._yourself()).__eq(true));
  202. _st(self)._assert_(_st(_st(true)._yourself()).__eq(_st(true)._yourself()));
  203. return self}, self, "testEquality", [], smalltalk.BooleanTest)},
  204. args: [],
  205. 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",
  206. messageSends: ["deny:", "=", "assert:", "yourself"],
  207. referencedClasses: []
  208. }),
  209. smalltalk.BooleanTest);
  210. smalltalk.addMethod(
  211. "_testIdentity",
  212. smalltalk.method({
  213. selector: "testIdentity",
  214. category: 'tests',
  215. fn: function (){
  216. var self=this;
  217. return smalltalk.withContext(function($ctx) { _st(self)._deny_(_st((0)).__eq_eq(false));
  218. _st(self)._deny_(_st(false).__eq_eq((0)));
  219. _st(self)._deny_(_st("").__eq_eq(false));
  220. _st(self)._deny_(_st(false).__eq_eq(""));
  221. _st(self)._assert_(_st(true).__eq_eq(true));
  222. _st(self)._deny_(_st(false).__eq_eq(true));
  223. _st(self)._deny_(_st(true).__eq_eq(false));
  224. _st(self)._assert_(_st(false).__eq_eq(false));
  225. _st(self)._assert_(_st(_st(true)._yourself()).__eq_eq(true));
  226. _st(self)._assert_(_st(_st(true)._yourself()).__eq_eq(_st(true)._yourself()));
  227. return self}, self, "testIdentity", [], smalltalk.BooleanTest)},
  228. args: [],
  229. 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",
  230. messageSends: ["deny:", "==", "assert:", "yourself"],
  231. referencedClasses: []
  232. }),
  233. smalltalk.BooleanTest);
  234. smalltalk.addMethod(
  235. "_testIfTrueIfFalse",
  236. smalltalk.method({
  237. selector: "testIfTrueIfFalse",
  238. category: 'tests',
  239. fn: function (){
  240. var self=this;
  241. return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4,$5,$6,$7,$8;
  242. if(smalltalk.assert(true)){
  243. $1="alternative block";
  244. };
  245. _st(self)._assert_(_st($1).__eq("alternative block"));
  246. if(! smalltalk.assert(true)){
  247. $2="alternative block";
  248. };
  249. _st(self)._assert_(_st($2).__eq(nil));
  250. if(smalltalk.assert(false)){
  251. $3="alternative block";
  252. };
  253. _st(self)._assert_(_st($3).__eq(nil));
  254. if(! smalltalk.assert(false)){
  255. $4="alternative block";
  256. };
  257. _st(self)._assert_(_st($4).__eq("alternative block"));
  258. if(smalltalk.assert(false)){
  259. $5="alternative block";
  260. } else {
  261. $5="alternative block2";
  262. };
  263. _st(self)._assert_(_st($5).__eq("alternative block2"));
  264. if(smalltalk.assert(false)){
  265. $6="alternative block2";
  266. } else {
  267. $6="alternative block";
  268. };
  269. _st(self)._assert_(_st($6).__eq("alternative block"));
  270. if(smalltalk.assert(true)){
  271. $7="alternative block";
  272. } else {
  273. $7="alternative block2";
  274. };
  275. _st(self)._assert_(_st($7).__eq("alternative block"));
  276. if(smalltalk.assert(true)){
  277. $8="alternative block2";
  278. } else {
  279. $8="alternative block";
  280. };
  281. _st(self)._assert_(_st($8).__eq("alternative block2"));
  282. return self}, self, "testIfTrueIfFalse", [], smalltalk.BooleanTest)},
  283. args: [],
  284. source: "testIfTrueIfFalse\x0a \x0a\x09self assert: (true ifTrue: ['alternative block']) = 'alternative block'.\x0a\x09self assert: (true ifFalse: ['alternative block']) = nil.\x0a\x0a\x09self assert: (false ifTrue: ['alternative block']) = nil.\x0a\x09self assert: (false ifFalse: ['alternative block']) = 'alternative block'.\x0a\x0a\x09self assert: (false ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block2'.\x0a\x09self assert: (false ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block'.\x0a\x0a\x09self assert: (true ifTrue: ['alternative block'] ifFalse: ['alternative block2']) = 'alternative block'.\x0a\x09self assert: (true ifFalse: ['alternative block'] ifTrue: ['alternative block2']) = 'alternative block2'.",
  285. messageSends: ["assert:", "=", "ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:"],
  286. referencedClasses: []
  287. }),
  288. smalltalk.BooleanTest);
  289. smalltalk.addMethod(
  290. "_testLogic",
  291. smalltalk.method({
  292. selector: "testLogic",
  293. category: 'tests',
  294. fn: function (){
  295. var self=this;
  296. return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4;
  297. _st(self)._assert_(_st(true).__and(true));
  298. _st(self)._deny_(_st(true).__and(false));
  299. _st(self)._deny_(_st(false).__and(true));
  300. $1=_st(self)._deny_(_st(false).__and(false));
  301. _st(self)._assert_(_st(true).__or(true));
  302. _st(self)._assert_(_st(true).__or(false));
  303. _st(self)._assert_(_st(false).__or(true));
  304. $2=_st(self)._deny_(_st(false).__or(false));
  305. _st(self)._assert_(_st(true).__and(_st((1)).__gt((0))));
  306. _st(self)._deny_(_st(_st((1)).__gt((0))).__and(false));
  307. $3=_st(self)._deny_(_st(_st((1)).__gt((0))).__and(_st((1)).__gt((2))));
  308. _st(self)._assert_(_st(false).__or(_st((1)).__gt((0))));
  309. _st(self)._assert_(_st(_st((1)).__gt((0))).__or(false));
  310. $4=_st(self)._assert_(_st(_st((1)).__gt((0))).__or(_st((1)).__gt((2))));
  311. return self}, self, "testLogic", [], smalltalk.BooleanTest)},
  312. args: [],
  313. source: "testLogic\x0a \x0a\x09\x22Trivial logic table\x22\x0a\x09self assert: (true & true); deny: (true & false); deny: (false & true); deny: (false & false).\x0a\x09self assert: (true | true); assert: (true | false); assert: (false | true); deny: (false | false).\x0a \x22Checking that expressions work fine too\x22\x0a\x09self assert: (true & (1 > 0)); deny: ((1 > 0) & false); deny: ((1 > 0) & (1 > 2)).\x0a self assert: (false | (1 > 0)); assert: ((1 > 0) | false); assert: ((1 > 0) | (1 > 2))",
  314. messageSends: ["assert:", "&", "deny:", "|", ">"],
  315. referencedClasses: []
  316. }),
  317. smalltalk.BooleanTest);
  318. smalltalk.addMethod(
  319. "_testLogicKeywords",
  320. smalltalk.method({
  321. selector: "testLogicKeywords",
  322. category: 'tests',
  323. fn: function (){
  324. var self=this;
  325. return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4;
  326. _st(self)._assert_(_st(true)._and_((function(){
  327. return true;
  328. })));
  329. _st(self)._deny_(_st(true)._and_((function(){
  330. return false;
  331. })));
  332. _st(self)._deny_(_st(false)._and_((function(){
  333. return true;
  334. })));
  335. $1=_st(self)._deny_(_st(false)._and_((function(){
  336. return false;
  337. })));
  338. _st(self)._assert_(_st(true)._or_((function(){
  339. return true;
  340. })));
  341. _st(self)._assert_(_st(true)._or_((function(){
  342. return false;
  343. })));
  344. _st(self)._assert_(_st(false)._or_((function(){
  345. return true;
  346. })));
  347. $2=_st(self)._deny_(_st(false)._or_((function(){
  348. return false;
  349. })));
  350. _st(self)._assert_(_st(true)._and_((function(){
  351. return _st((1)).__gt((0));
  352. })));
  353. _st(self)._deny_(_st(_st((1)).__gt((0)))._and_((function(){
  354. return false;
  355. })));
  356. $3=_st(self)._deny_(_st(_st((1)).__gt((0)))._and_((function(){
  357. return _st((1)).__gt((2));
  358. })));
  359. _st(self)._assert_(_st(false)._or_((function(){
  360. return _st((1)).__gt((0));
  361. })));
  362. _st(self)._assert_(_st(_st((1)).__gt((0)))._or_((function(){
  363. return false;
  364. })));
  365. $4=_st(self)._assert_(_st(_st((1)).__gt((0)))._or_((function(){
  366. return _st((1)).__gt((2));
  367. })));
  368. return self}, self, "testLogicKeywords", [], smalltalk.BooleanTest)},
  369. args: [],
  370. source: "testLogicKeywords\x0a \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 \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 self \x0a\x09\x09assert: (false or: [ 1 > 0 ]); \x0a\x09\x09assert: ((1 > 0) or: [ false ]); \x0a\x09\x09assert: ((1 > 0) or: [ 1 > 2 ])",
  371. messageSends: ["assert:", "and:", "deny:", "or:", ">"],
  372. referencedClasses: []
  373. }),
  374. smalltalk.BooleanTest);
  375. smalltalk.addMethod(
  376. "_testNonBooleanError",
  377. smalltalk.method({
  378. selector: "testNonBooleanError",
  379. category: 'tests',
  380. fn: function (){
  381. var self=this;
  382. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  383. if(smalltalk.assert("")){
  384. } else {
  385. };
  386. }),(smalltalk.NonBooleanReceiver || NonBooleanReceiver));
  387. return self}, self, "testNonBooleanError", [], smalltalk.BooleanTest)},
  388. args: [],
  389. source: "testNonBooleanError\x0a self should: ['' ifTrue: [] ifFalse: []] raise: NonBooleanReceiver",
  390. messageSends: ["should:raise:", "ifTrue:ifFalse:"],
  391. referencedClasses: ["NonBooleanReceiver"]
  392. }),
  393. smalltalk.BooleanTest);
  394. smalltalk.addClass('ClassBuilderTest', smalltalk.TestCase, ['builder', 'theClass'], 'Kernel-Tests');
  395. smalltalk.addMethod(
  396. "_setUp",
  397. smalltalk.method({
  398. selector: "setUp",
  399. category: 'running',
  400. fn: function (){
  401. var self=this;
  402. return smalltalk.withContext(function($ctx) { self["@builder"]=_st((smalltalk.ClassBuilder || ClassBuilder))._new();
  403. return self}, self, "setUp", [], smalltalk.ClassBuilderTest)},
  404. args: [],
  405. source: "setUp\x0a\x09builder := ClassBuilder new",
  406. messageSends: ["new"],
  407. referencedClasses: ["ClassBuilder"]
  408. }),
  409. smalltalk.ClassBuilderTest);
  410. smalltalk.addMethod(
  411. "_tearDown",
  412. smalltalk.method({
  413. selector: "tearDown",
  414. category: 'running',
  415. fn: function (){
  416. var self=this;
  417. return smalltalk.withContext(function($ctx) { if(($receiver = self["@theClass"]) == nil || $receiver == undefined){
  418. self["@theClass"];
  419. } else {
  420. _st(_st((smalltalk.Smalltalk || Smalltalk))._current())._removeClass_(self["@theClass"]);
  421. self["@theClass"]=nil;
  422. self["@theClass"];
  423. };
  424. return self}, self, "tearDown", [], smalltalk.ClassBuilderTest)},
  425. args: [],
  426. source: "tearDown\x0a\x09theClass ifNotNil: [Smalltalk current removeClass: theClass. theClass := nil]",
  427. messageSends: ["ifNotNil:", "removeClass:", "current"],
  428. referencedClasses: ["Smalltalk"]
  429. }),
  430. smalltalk.ClassBuilderTest);
  431. smalltalk.addMethod(
  432. "_testClassCopy",
  433. smalltalk.method({
  434. selector: "testClassCopy",
  435. category: 'running',
  436. fn: function (){
  437. var self=this;
  438. return smalltalk.withContext(function($ctx) { self["@theClass"]=_st(self["@builder"])._copyClass_named_((smalltalk.ObjectMock || ObjectMock),"ObjectMock2");
  439. _st(self)._assert_(_st(_st(self["@theClass"])._superclass()).__eq_eq(_st((smalltalk.ObjectMock || ObjectMock))._superclass()));
  440. _st(self)._assert_(_st(_st(self["@theClass"])._instanceVariableNames()).__eq_eq(_st((smalltalk.ObjectMock || ObjectMock))._instanceVariableNames()));
  441. _st(self)._assert_equals_(_st(self["@theClass"])._name(),"ObjectMock2");
  442. _st(self)._assert_(_st(_st(self["@theClass"])._package()).__eq_eq(_st((smalltalk.ObjectMock || ObjectMock))._package()));
  443. _st(self)._assert_equals_(_st(_st(self["@theClass"])._methodDictionary())._keys(),_st(_st((smalltalk.ObjectMock || ObjectMock))._methodDictionary())._keys());
  444. return self}, self, "testClassCopy", [], smalltalk.ClassBuilderTest)},
  445. args: [],
  446. 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",
  447. messageSends: ["copyClass:named:", "assert:", "==", "superclass", "instanceVariableNames", "assert:equals:", "name", "package", "keys", "methodDictionary"],
  448. referencedClasses: ["ObjectMock"]
  449. }),
  450. smalltalk.ClassBuilderTest);
  451. smalltalk.addMethod(
  452. "_testInstanceVariableNames",
  453. smalltalk.method({
  454. selector: "testInstanceVariableNames",
  455. category: 'running',
  456. fn: function (){
  457. var self=this;
  458. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(self["@builder"])._instanceVariableNamesFor_(" hello world "),["hello", "world"]);
  459. return self}, self, "testInstanceVariableNames", [], smalltalk.ClassBuilderTest)},
  460. args: [],
  461. source: "testInstanceVariableNames\x0a\x09self assert: (builder instanceVariableNamesFor: ' hello world ') equals: #('hello' 'world')",
  462. messageSends: ["assert:equals:", "instanceVariableNamesFor:"],
  463. referencedClasses: []
  464. }),
  465. smalltalk.ClassBuilderTest);
  466. smalltalk.addClass('CollectionTest', smalltalk.TestCase, [], 'Kernel-Tests');
  467. smalltalk.addMethod(
  468. "_assertSameContents_as_",
  469. smalltalk.method({
  470. selector: "assertSameContents:as:",
  471. category: 'convenience',
  472. fn: function (aCollection,anotherCollection){
  473. var self=this;
  474. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(aCollection)._size()).__eq(_st(anotherCollection)._size()));
  475. _st(aCollection)._do_((function(each){
  476. return _st(self)._assert_(_st(_st(aCollection)._occurrencesOf_(each)).__eq(_st(anotherCollection)._occurrencesOf_(each)));
  477. }));
  478. return self}, self, "assertSameContents:as:", [aCollection,anotherCollection], smalltalk.CollectionTest)},
  479. args: ["aCollection", "anotherCollection"],
  480. source: "assertSameContents: aCollection \x09as: anotherCollection\x0a\x09self assert: aCollection size = anotherCollection size.\x0a\x09aCollection do: [ :each |\x0a\x09\x09self assert: (aCollection occurrencesOf: each) = (anotherCollection occurrencesOf: each) ]",
  481. messageSends: ["assert:", "=", "size", "do:", "occurrencesOf:"],
  482. referencedClasses: []
  483. }),
  484. smalltalk.CollectionTest);
  485. smalltalk.addMethod(
  486. "_collection",
  487. smalltalk.method({
  488. selector: "collection",
  489. category: 'accessing',
  490. fn: function (){
  491. var self=this;
  492. return smalltalk.withContext(function($ctx) { var $1;
  493. $1=_st(_st(self)._collectionClass())._withAll_(_st(self)._defaultValues());
  494. return $1;
  495. }, self, "collection", [], smalltalk.CollectionTest)},
  496. args: [],
  497. source: "collection\x0a\x09^ self collectionClass withAll: self defaultValues",
  498. messageSends: ["withAll:", "defaultValues", "collectionClass"],
  499. referencedClasses: []
  500. }),
  501. smalltalk.CollectionTest);
  502. smalltalk.addMethod(
  503. "_collectionClass",
  504. smalltalk.method({
  505. selector: "collectionClass",
  506. category: 'accessing',
  507. fn: function (){
  508. var self=this;
  509. return smalltalk.withContext(function($ctx) { var $1;
  510. $1=_st(_st(self)._class())._collectionClass();
  511. return $1;
  512. }, self, "collectionClass", [], smalltalk.CollectionTest)},
  513. args: [],
  514. source: "collectionClass\x0a\x09^ self class collectionClass",
  515. messageSends: ["collectionClass", "class"],
  516. referencedClasses: []
  517. }),
  518. smalltalk.CollectionTest);
  519. smalltalk.addMethod(
  520. "_collectionWithDuplicates",
  521. smalltalk.method({
  522. selector: "collectionWithDuplicates",
  523. category: 'accessing',
  524. fn: function (){
  525. var self=this;
  526. return smalltalk.withContext(function($ctx) { var $1;
  527. $1=_st(_st(self)._collectionClass())._withAll_(["a", "b", "c", (1), (2), (1), "a"]);
  528. return $1;
  529. }, self, "collectionWithDuplicates", [], smalltalk.CollectionTest)},
  530. args: [],
  531. source: "collectionWithDuplicates\x0a\x09^ self collectionClass withAll: #('a' 'b' 'c' 1 2 1 'a')",
  532. messageSends: ["withAll:", "collectionClass"],
  533. referencedClasses: []
  534. }),
  535. smalltalk.CollectionTest);
  536. smalltalk.addMethod(
  537. "_defaultValues",
  538. smalltalk.method({
  539. selector: "defaultValues",
  540. category: 'accessing',
  541. fn: function (){
  542. var self=this;
  543. return smalltalk.withContext(function($ctx) { return [(1), (2), (3), (-4)];
  544. }, self, "defaultValues", [], smalltalk.CollectionTest)},
  545. args: [],
  546. source: "defaultValues\x0a\x09^ #(1 2 3 -4)",
  547. messageSends: [],
  548. referencedClasses: []
  549. }),
  550. smalltalk.CollectionTest);
  551. smalltalk.addMethod(
  552. "_isCollectionReadOnly",
  553. smalltalk.method({
  554. selector: "isCollectionReadOnly",
  555. category: 'testing',
  556. fn: function (){
  557. var self=this;
  558. return smalltalk.withContext(function($ctx) { return false;
  559. }, self, "isCollectionReadOnly", [], smalltalk.CollectionTest)},
  560. args: [],
  561. source: "isCollectionReadOnly\x0a\x09^ false",
  562. messageSends: [],
  563. referencedClasses: []
  564. }),
  565. smalltalk.CollectionTest);
  566. smalltalk.addMethod(
  567. "_testAsArray",
  568. smalltalk.method({
  569. selector: "testAsArray",
  570. category: 'tests',
  571. fn: function (){
  572. var self=this;
  573. return smalltalk.withContext(function($ctx) { _st(self)._assertSameContents_as_(_st(self)._collection(),_st(_st(self)._collection())._asArray());
  574. return self}, self, "testAsArray", [], smalltalk.CollectionTest)},
  575. args: [],
  576. source: "testAsArray\x0a\x09self \x0a\x09\x09assertSameContents: self collection \x0a\x09\x09as: self collection asArray",
  577. messageSends: ["assertSameContents:as:", "collection", "asArray"],
  578. referencedClasses: []
  579. }),
  580. smalltalk.CollectionTest);
  581. smalltalk.addMethod(
  582. "_testAsOrderedCollection",
  583. smalltalk.method({
  584. selector: "testAsOrderedCollection",
  585. category: 'tests',
  586. fn: function (){
  587. var self=this;
  588. return smalltalk.withContext(function($ctx) { _st(self)._assertSameContents_as_(_st(self)._collection(),_st(_st(self)._collection())._asOrderedCollection());
  589. return self}, self, "testAsOrderedCollection", [], smalltalk.CollectionTest)},
  590. args: [],
  591. source: "testAsOrderedCollection\x0a\x09self \x0a\x09\x09assertSameContents: self collection \x0a\x09\x09as: self collection asOrderedCollection",
  592. messageSends: ["assertSameContents:as:", "collection", "asOrderedCollection"],
  593. referencedClasses: []
  594. }),
  595. smalltalk.CollectionTest);
  596. smalltalk.addMethod(
  597. "_testAsSet",
  598. smalltalk.method({
  599. selector: "testAsSet",
  600. category: 'tests',
  601. fn: function (){
  602. var self=this;
  603. return smalltalk.withContext(function($ctx) { var c;
  604. var set;
  605. c=_st(self)._collectionWithDuplicates();
  606. set=_st(c)._asSet();
  607. _st(self)._assert_(_st(_st(set)._size()).__eq((5)));
  608. _st(c)._do_((function(each){
  609. return _st(self)._assert_(_st(set)._includes_(each));
  610. }));
  611. return self}, self, "testAsSet", [], smalltalk.CollectionTest)},
  612. args: [],
  613. source: "testAsSet\x0a\x09| c set |\x0a\x09c := self collectionWithDuplicates.\x0a\x09set := c asSet.\x0a\x09self assert: set size = 5.\x0a\x09c do: [ :each |\x0a\x09\x09self assert: (set includes: each) ]",
  614. messageSends: ["collectionWithDuplicates", "asSet", "assert:", "=", "size", "do:", "includes:"],
  615. referencedClasses: []
  616. }),
  617. smalltalk.CollectionTest);
  618. smalltalk.addMethod(
  619. "_testCollect",
  620. smalltalk.method({
  621. selector: "testCollect",
  622. category: 'tests',
  623. fn: function (){
  624. var self=this;
  625. return smalltalk.withContext(function($ctx) { var newCollection;
  626. newCollection=[(1), (2), (3), (4)];
  627. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._collect_((function(each){
  628. return _st(each)._abs();
  629. })),newCollection);
  630. return self}, self, "testCollect", [], smalltalk.CollectionTest)},
  631. args: [],
  632. 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",
  633. messageSends: ["assertSameContents:as:", "collect:", "abs", "collection"],
  634. referencedClasses: []
  635. }),
  636. smalltalk.CollectionTest);
  637. smalltalk.addMethod(
  638. "_testDetect",
  639. smalltalk.method({
  640. selector: "testDetect",
  641. category: 'tests',
  642. fn: function (){
  643. var self=this;
  644. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(self)._collection())._detect_((function(each){
  645. return _st(each).__lt((0));
  646. }))).__eq((-4)));
  647. _st(self)._should_raise_((function(){
  648. return _st(_st(self)._collection())._detect_((function(each){
  649. return _st(each).__eq((6));
  650. }));
  651. }),(smalltalk.Error || Error));
  652. return self}, self, "testDetect", [], smalltalk.CollectionTest)},
  653. args: [],
  654. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each < 0 ]) = -4.\x0a\x09self \x0a\x09\x09should: [ self collection detect: [ :each | each = 6 ] ]\x0a\x09\x09raise: Error",
  655. messageSends: ["assert:", "=", "detect:", "<", "collection", "should:raise:"],
  656. referencedClasses: ["Error"]
  657. }),
  658. smalltalk.CollectionTest);
  659. smalltalk.addMethod(
  660. "_testDo",
  661. smalltalk.method({
  662. selector: "testDo",
  663. category: 'tests',
  664. fn: function (){
  665. var self=this;
  666. return smalltalk.withContext(function($ctx) { var newCollection;
  667. newCollection=_st((smalltalk.OrderedCollection || OrderedCollection))._new();
  668. _st(_st(self)._collection())._do_((function(each){
  669. return _st(newCollection)._add_(each);
  670. }));
  671. _st(self)._assertSameContents_as_(_st(self)._collection(),newCollection);
  672. return self}, self, "testDo", [], smalltalk.CollectionTest)},
  673. args: [],
  674. 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",
  675. messageSends: ["new", "do:", "add:", "collection", "assertSameContents:as:"],
  676. referencedClasses: ["OrderedCollection"]
  677. }),
  678. smalltalk.CollectionTest);
  679. smalltalk.addMethod(
  680. "_testIsEmpty",
  681. smalltalk.method({
  682. selector: "testIsEmpty",
  683. category: 'tests',
  684. fn: function (){
  685. var self=this;
  686. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(self)._collectionClass())._new())._isEmpty());
  687. _st(self)._deny_(_st(_st(self)._collection())._isEmpty());
  688. return self}, self, "testIsEmpty", [], smalltalk.CollectionTest)},
  689. args: [],
  690. source: "testIsEmpty\x0a\x09self assert: self collectionClass new isEmpty.\x0a\x09self deny: self collection isEmpty",
  691. messageSends: ["assert:", "isEmpty", "new", "collectionClass", "deny:", "collection"],
  692. referencedClasses: []
  693. }),
  694. smalltalk.CollectionTest);
  695. smalltalk.addMethod(
  696. "_testSelect",
  697. smalltalk.method({
  698. selector: "testSelect",
  699. category: 'tests',
  700. fn: function (){
  701. var self=this;
  702. return smalltalk.withContext(function($ctx) { var newCollection;
  703. newCollection=[(2), (-4)];
  704. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._select_((function(each){
  705. return _st(each)._even();
  706. })),newCollection);
  707. return self}, self, "testSelect", [], smalltalk.CollectionTest)},
  708. args: [],
  709. 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",
  710. messageSends: ["assertSameContents:as:", "select:", "even", "collection"],
  711. referencedClasses: []
  712. }),
  713. smalltalk.CollectionTest);
  714. smalltalk.addMethod(
  715. "_testSize",
  716. smalltalk.method({
  717. selector: "testSize",
  718. category: 'tests',
  719. fn: function (){
  720. var self=this;
  721. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(_st(self)._collectionClass())._new())._size()).__eq((0)));
  722. _st(self)._assert_(_st(_st(_st(self)._collection())._size()).__eq((4)));
  723. return self}, self, "testSize", [], smalltalk.CollectionTest)},
  724. args: [],
  725. source: "testSize\x0a\x09self assert: self collectionClass new size = 0.\x0a\x09self assert: self collection size = 4",
  726. messageSends: ["assert:", "=", "size", "new", "collectionClass", "collection"],
  727. referencedClasses: []
  728. }),
  729. smalltalk.CollectionTest);
  730. smalltalk.addMethod(
  731. "_collectionClass",
  732. smalltalk.method({
  733. selector: "collectionClass",
  734. category: 'accessing',
  735. fn: function (){
  736. var self=this;
  737. return smalltalk.withContext(function($ctx) { return nil;
  738. }, self, "collectionClass", [], smalltalk.CollectionTest.klass)},
  739. args: [],
  740. source: "collectionClass\x0a\x09^ nil",
  741. messageSends: [],
  742. referencedClasses: []
  743. }),
  744. smalltalk.CollectionTest.klass);
  745. smalltalk.addMethod(
  746. "_isAbstract",
  747. smalltalk.method({
  748. selector: "isAbstract",
  749. category: 'testing',
  750. fn: function (){
  751. var self=this;
  752. return smalltalk.withContext(function($ctx) { var $1;
  753. $1=_st(_st(self)._collectionClass())._isNil();
  754. return $1;
  755. }, self, "isAbstract", [], smalltalk.CollectionTest.klass)},
  756. args: [],
  757. source: "isAbstract\x0a\x09^ self collectionClass isNil",
  758. messageSends: ["isNil", "collectionClass"],
  759. referencedClasses: []
  760. }),
  761. smalltalk.CollectionTest.klass);
  762. smalltalk.addClass('HashedCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
  763. smalltalk.addMethod(
  764. "_collection",
  765. smalltalk.method({
  766. selector: "collection",
  767. category: 'accessing',
  768. fn: function (){
  769. var self=this;
  770. return smalltalk.withContext(function($ctx) { var $1;
  771. $1=smalltalk.HashedCollection._fromPairs_([_st("a").__minus_gt((1)),_st("b").__minus_gt((2)),_st("c").__minus_gt((3)),_st("d").__minus_gt((-4))]);
  772. return $1;
  773. }, self, "collection", [], smalltalk.HashedCollectionTest)},
  774. args: [],
  775. source: "collection\x0a\x09^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4 }",
  776. messageSends: ["->"],
  777. referencedClasses: []
  778. }),
  779. smalltalk.HashedCollectionTest);
  780. smalltalk.addMethod(
  781. "_collectionWithDuplicates",
  782. smalltalk.method({
  783. selector: "collectionWithDuplicates",
  784. category: 'accessing',
  785. fn: function (){
  786. var self=this;
  787. return smalltalk.withContext(function($ctx) { var $1;
  788. $1=smalltalk.HashedCollection._fromPairs_([_st("a").__minus_gt((1)),_st("b").__minus_gt((2)),_st("c").__minus_gt((3)),_st("d").__minus_gt((-4)),_st("e").__minus_gt((1)),_st("f").__minus_gt((2)),_st("g").__minus_gt((10))]);
  789. return $1;
  790. }, self, "collectionWithDuplicates", [], smalltalk.HashedCollectionTest)},
  791. args: [],
  792. source: "collectionWithDuplicates\x0a\x09^ #{ 'a' -> 1. 'b' -> 2. 'c' -> 3. 'd' -> -4. 'e' -> 1. 'f' -> 2. 'g' -> 10 }",
  793. messageSends: ["->"],
  794. referencedClasses: []
  795. }),
  796. smalltalk.HashedCollectionTest);
  797. smalltalk.addMethod(
  798. "_collectionClass",
  799. smalltalk.method({
  800. selector: "collectionClass",
  801. category: 'accessing',
  802. fn: function (){
  803. var self=this;
  804. return smalltalk.withContext(function($ctx) { return (smalltalk.HashedCollection || HashedCollection);
  805. }, self, "collectionClass", [], smalltalk.HashedCollectionTest.klass)},
  806. args: [],
  807. source: "collectionClass\x0a\x09^ HashedCollection",
  808. messageSends: [],
  809. referencedClasses: ["HashedCollection"]
  810. }),
  811. smalltalk.HashedCollectionTest.klass);
  812. smalltalk.addClass('DictionaryTest', smalltalk.HashedCollectionTest, [], 'Kernel-Tests');
  813. smalltalk.addMethod(
  814. "_collection",
  815. smalltalk.method({
  816. selector: "collection",
  817. category: 'accessing',
  818. fn: function (){
  819. var self=this;
  820. return smalltalk.withContext(function($ctx) { var $2,$3,$1;
  821. $2=_st((smalltalk.Dictionary || Dictionary))._new();
  822. _st($2)._at_put_((1),(1));
  823. _st($2)._at_put_("a",(2));
  824. _st($2)._at_put_(true,(3));
  825. _st($2)._at_put_((4),(-4));
  826. $3=_st($2)._yourself();
  827. $1=$3;
  828. return $1;
  829. }, self, "collection", [], smalltalk.DictionaryTest)},
  830. args: [],
  831. 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",
  832. messageSends: ["at:put:", "new", "yourself"],
  833. referencedClasses: ["Dictionary"]
  834. }),
  835. smalltalk.DictionaryTest);
  836. smalltalk.addMethod(
  837. "_collectionWithDuplicates",
  838. smalltalk.method({
  839. selector: "collectionWithDuplicates",
  840. category: 'accessing',
  841. fn: function (){
  842. var self=this;
  843. return smalltalk.withContext(function($ctx) { var $2,$3,$1;
  844. $2=_st((smalltalk.Dictionary || Dictionary))._new();
  845. _st($2)._at_put_((1),(1));
  846. _st($2)._at_put_("a",(2));
  847. _st($2)._at_put_(true,(3));
  848. _st($2)._at_put_((4),(-4));
  849. _st($2)._at_put_("b",(1));
  850. _st($2)._at_put_((3),(3));
  851. _st($2)._at_put_(false,(12));
  852. $3=_st($2)._yourself();
  853. $1=$3;
  854. return $1;
  855. }, self, "collectionWithDuplicates", [], smalltalk.DictionaryTest)},
  856. args: [],
  857. 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",
  858. messageSends: ["at:put:", "new", "yourself"],
  859. referencedClasses: ["Dictionary"]
  860. }),
  861. smalltalk.DictionaryTest);
  862. smalltalk.addMethod(
  863. "_testAccessing",
  864. smalltalk.method({
  865. selector: "testAccessing",
  866. category: 'tests',
  867. fn: function (){
  868. var self=this;
  869. return smalltalk.withContext(function($ctx) { var d;
  870. d=_st((smalltalk.Dictionary || Dictionary))._new();
  871. _st(d)._at_put_("hello","world");
  872. _st(self)._assert_(_st(_st(d)._at_("hello")).__eq("world"));
  873. _st(self)._assert_(_st(_st(d)._at_ifAbsent_("hello",(function(){
  874. return nil;
  875. }))).__eq("world"));
  876. _st(self)._deny_(_st(_st(d)._at_ifAbsent_("foo",(function(){
  877. return nil;
  878. }))).__eq("world"));
  879. _st(d)._at_put_((1),(2));
  880. _st(self)._assert_(_st(_st(d)._at_((1))).__eq((2)));
  881. _st(d)._at_put_(_st((1)).__at((3)),(3));
  882. _st(self)._assert_(_st(_st(d)._at_(_st((1)).__at((3)))).__eq((3)));
  883. return self}, self, "testAccessing", [], smalltalk.DictionaryTest)},
  884. args: [],
  885. source: "testAccessing\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x0a\x09d at: 'hello' put: 'world'.\x0a\x09self assert: (d at: 'hello') = 'world'.\x0a\x09self assert: (d at: 'hello' ifAbsent: [nil]) = 'world'.\x0a\x09self deny: (d at: 'foo' ifAbsent: [nil]) = 'world'.\x0a\x0a\x09d at: 1 put: 2.\x0a\x09self assert: (d at: 1) = 2.\x0a\x0a\x09d at: 1@3 put: 3.\x0a\x09self assert: (d at: 1@3) = 3",
  886. messageSends: ["new", "at:put:", "assert:", "=", "at:", "at:ifAbsent:", "deny:", "@"],
  887. referencedClasses: ["Dictionary"]
  888. }),
  889. smalltalk.DictionaryTest);
  890. smalltalk.addMethod(
  891. "_testDynamicDictionaries",
  892. smalltalk.method({
  893. selector: "testDynamicDictionaries",
  894. category: 'tests',
  895. fn: function (){
  896. var self=this;
  897. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(smalltalk.HashedCollection._fromPairs_([_st("hello").__minus_gt((1))]))._asDictionary()).__eq(_st((smalltalk.Dictionary || Dictionary))._with_(_st("hello").__minus_gt((1)))));
  898. return self}, self, "testDynamicDictionaries", [], smalltalk.DictionaryTest)},
  899. args: [],
  900. source: "testDynamicDictionaries\x0a\x09self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)",
  901. messageSends: ["assert:", "=", "with:", "->", "asDictionary"],
  902. referencedClasses: ["Dictionary"]
  903. }),
  904. smalltalk.DictionaryTest);
  905. smalltalk.addMethod(
  906. "_testEquality",
  907. smalltalk.method({
  908. selector: "testEquality",
  909. category: 'tests',
  910. fn: function (){
  911. var self=this;
  912. return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10;
  913. var d1;
  914. var d2;
  915. _st(self)._assert_(_st(_st((smalltalk.Dictionary || Dictionary))._new()).__eq(_st((smalltalk.Dictionary || Dictionary))._new()));
  916. $1=_st((smalltalk.Dictionary || Dictionary))._new();
  917. _st($1)._at_put_((1),(2));
  918. $2=_st($1)._yourself();
  919. d1=$2;
  920. $3=_st((smalltalk.Dictionary || Dictionary))._new();
  921. _st($3)._at_put_((1),(2));
  922. $4=_st($3)._yourself();
  923. d2=$4;
  924. _st(self)._assert_(_st(d1).__eq(d2));
  925. $5=_st((smalltalk.Dictionary || Dictionary))._new();
  926. _st($5)._at_put_((1),(3));
  927. $6=_st($5)._yourself();
  928. d2=$6;
  929. _st(self)._deny_(_st(d1).__eq(d2));
  930. $7=_st((smalltalk.Dictionary || Dictionary))._new();
  931. _st($7)._at_put_((2),(2));
  932. $8=_st($7)._yourself();
  933. d2=$8;
  934. _st(self)._deny_(_st(d1).__eq(d2));
  935. $9=_st((smalltalk.Dictionary || Dictionary))._new();
  936. _st($9)._at_put_((1),(2));
  937. _st($9)._at_put_((3),(4));
  938. $10=_st($9)._yourself();
  939. d2=$10;
  940. _st(self)._deny_(_st(d1).__eq(d2));
  941. return self}, self, "testEquality", [], smalltalk.DictionaryTest)},
  942. args: [],
  943. 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.",
  944. messageSends: ["assert:", "=", "new", "at:put:", "yourself", "deny:"],
  945. referencedClasses: ["Dictionary"]
  946. }),
  947. smalltalk.DictionaryTest);
  948. smalltalk.addMethod(
  949. "_testIfAbsent",
  950. smalltalk.method({
  951. selector: "testIfAbsent",
  952. category: 'tests',
  953. fn: function (){
  954. var self=this;
  955. return smalltalk.withContext(function($ctx) { var d;
  956. var visited;
  957. visited=false;
  958. d=_st((smalltalk.Dictionary || Dictionary))._new();
  959. _st(d)._at_ifAbsent_("hello",(function(){
  960. visited=true;
  961. return visited;
  962. }));
  963. _st(self)._assert_(visited);
  964. return self}, self, "testIfAbsent", [], smalltalk.DictionaryTest)},
  965. args: [],
  966. 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.",
  967. messageSends: ["new", "at:ifAbsent:", "assert:"],
  968. referencedClasses: ["Dictionary"]
  969. }),
  970. smalltalk.DictionaryTest);
  971. smalltalk.addMethod(
  972. "_testIfPresent",
  973. smalltalk.method({
  974. selector: "testIfPresent",
  975. category: 'tests',
  976. fn: function (){
  977. var self=this;
  978. return smalltalk.withContext(function($ctx) { var d;
  979. var visited;
  980. var absent;
  981. visited=false;
  982. d=_st((smalltalk.Dictionary || Dictionary))._new();
  983. _st(d)._at_put_("hello","world");
  984. _st(d)._at_ifPresent_("hello",(function(value){
  985. visited=value;
  986. return visited;
  987. }));
  988. _st(self)._assert_(_st(visited).__eq("world"));
  989. absent=_st(d)._at_ifPresent_("bye",(function(value){
  990. visited=value;
  991. return visited;
  992. }));
  993. _st(self)._assert_(_st(absent)._isNil());
  994. return self}, self, "testIfPresent", [], smalltalk.DictionaryTest)},
  995. args: [],
  996. 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 = 'world'.\x0a\x0a\x09absent := d at: 'bye' ifPresent: [ :value | visited := value ].\x0a\x09self assert: absent isNil.\x0a",
  997. messageSends: ["new", "at:put:", "at:ifPresent:", "assert:", "=", "isNil"],
  998. referencedClasses: ["Dictionary"]
  999. }),
  1000. smalltalk.DictionaryTest);
  1001. smalltalk.addMethod(
  1002. "_testIfPresentIfAbsent",
  1003. smalltalk.method({
  1004. selector: "testIfPresentIfAbsent",
  1005. category: 'tests',
  1006. fn: function (){
  1007. var self=this;
  1008. return smalltalk.withContext(function($ctx) { var d;
  1009. var visited;
  1010. visited=false;
  1011. d=_st((smalltalk.Dictionary || Dictionary))._new();
  1012. _st(d)._at_put_("hello","world");
  1013. _st(d)._at_ifPresent_ifAbsent_("hello",(function(value){
  1014. visited=value;
  1015. return visited;
  1016. }),(function(){
  1017. visited=true;
  1018. return visited;
  1019. }));
  1020. _st(self)._assert_(_st(visited).__eq("world"));
  1021. _st(d)._at_ifPresent_ifAbsent_("buy",(function(value){
  1022. visited=value;
  1023. return visited;
  1024. }),(function(){
  1025. visited=true;
  1026. return visited;
  1027. }));
  1028. _st(self)._assert_(visited);
  1029. return self}, self, "testIfPresentIfAbsent", [], smalltalk.DictionaryTest)},
  1030. args: [],
  1031. 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 = 'world'.\x0a\x0a\x09d at: 'buy' ifPresent: [ :value | visited := value ] ifAbsent: [ visited := true ].\x0a\x09self assert: visited.",
  1032. messageSends: ["new", "at:put:", "at:ifPresent:ifAbsent:", "assert:", "="],
  1033. referencedClasses: ["Dictionary"]
  1034. }),
  1035. smalltalk.DictionaryTest);
  1036. smalltalk.addMethod(
  1037. "_testKeys",
  1038. smalltalk.method({
  1039. selector: "testKeys",
  1040. category: 'tests',
  1041. fn: function (){
  1042. var self=this;
  1043. return smalltalk.withContext(function($ctx) { var d;
  1044. d=_st((smalltalk.Dictionary || Dictionary))._new();
  1045. _st(d)._at_put_((1),(2));
  1046. _st(d)._at_put_((2),(3));
  1047. _st(d)._at_put_((3),(4));
  1048. _st(self)._assert_(_st(_st(d)._keys()).__eq([(1), (2), (3)]));
  1049. return self}, self, "testKeys", [], smalltalk.DictionaryTest)},
  1050. args: [],
  1051. 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 = #(1 2 3)",
  1052. messageSends: ["new", "at:put:", "assert:", "=", "keys"],
  1053. referencedClasses: ["Dictionary"]
  1054. }),
  1055. smalltalk.DictionaryTest);
  1056. smalltalk.addMethod(
  1057. "_testPrintString",
  1058. smalltalk.method({
  1059. selector: "testPrintString",
  1060. category: 'tests',
  1061. fn: function (){
  1062. var self=this;
  1063. return smalltalk.withContext(function($ctx) { var $1,$2;
  1064. $1=_st((smalltalk.Dictionary || Dictionary))._new();
  1065. _st($1)._at_put_("firstname","James");
  1066. _st($1)._at_put_("lastname","Bond");
  1067. $2=_st($1)._printString();
  1068. _st(self)._assert_equals_("a Dictionary('firstname'->'James' , 'lastname'->'Bond')",$2);
  1069. return self}, self, "testPrintString", [], smalltalk.DictionaryTest)},
  1070. args: [],
  1071. source: "testPrintString\x0a\x09self\x0a\x09\x09assert: 'a Dictionary(''firstname''->''James'' , ''lastname''->''Bond'')' \x0a\x09\x09equals: (Dictionary new \x0a \x09at:'firstname' put: 'James';\x0a \x09at:'lastname' put: 'Bond';\x0a \x09printString)",
  1072. messageSends: ["assert:equals:", "at:put:", "new", "printString"],
  1073. referencedClasses: ["Dictionary"]
  1074. }),
  1075. smalltalk.DictionaryTest);
  1076. smalltalk.addMethod(
  1077. "_testRemoveKey",
  1078. smalltalk.method({
  1079. selector: "testRemoveKey",
  1080. category: 'tests',
  1081. fn: function (){
  1082. var self=this;
  1083. return smalltalk.withContext(function($ctx) { var d;
  1084. var key;
  1085. d=_st((smalltalk.Dictionary || Dictionary))._new();
  1086. _st(d)._at_put_((1),(2));
  1087. _st(d)._at_put_((2),(3));
  1088. _st(d)._at_put_((3),(4));
  1089. key=(2);
  1090. _st(self)._assert_(_st(_st(d)._keys()).__eq([(1), (2), (3)]));
  1091. _st(d)._removeKey_(key);
  1092. _st(self)._assert_(_st(_st(d)._keys()).__eq([(1), (3)]));
  1093. _st(self)._assert_(_st(_st(d)._values()).__eq([(2), (4)]));
  1094. _st(self)._deny_(_st(d)._includesKey_((2)));
  1095. return self}, self, "testRemoveKey", [], smalltalk.DictionaryTest)},
  1096. args: [],
  1097. source: "testRemoveKey\x0a | d key |\x0a\x0a d := Dictionary new.\x0a d at: 1 put: 2.\x0a d at: 2 put: 3.\x0a d at: 3 put: 4.\x0a\x0a key := 2.\x0a\x0a self assert: d keys = #(1 2 3).\x0a\x0a d removeKey: key.\x0a self assert: d keys = #(1 3).\x0a self assert: d values = #(2 4).\x0a self deny: (d includesKey: 2)",
  1098. messageSends: ["new", "at:put:", "assert:", "=", "keys", "removeKey:", "values", "deny:", "includesKey:"],
  1099. referencedClasses: ["Dictionary"]
  1100. }),
  1101. smalltalk.DictionaryTest);
  1102. smalltalk.addMethod(
  1103. "_testRemoveKeyIfAbsent",
  1104. smalltalk.method({
  1105. selector: "testRemoveKeyIfAbsent",
  1106. category: 'tests',
  1107. fn: function (){
  1108. var self=this;
  1109. return smalltalk.withContext(function($ctx) { var d;
  1110. var key;
  1111. d=_st((smalltalk.Dictionary || Dictionary))._new();
  1112. _st(d)._at_put_((1),(2));
  1113. _st(d)._at_put_((2),(3));
  1114. _st(d)._at_put_((3),(4));
  1115. key=(2);
  1116. _st(self)._assert_(_st(_st(d)._removeKey_(key)).__eq((3)));
  1117. key=(3);
  1118. _st(self)._assert_(_st(_st(d)._removeKey_ifAbsent_(key,(function(){
  1119. return (42);
  1120. }))).__eq((4)));
  1121. key="why";
  1122. _st(self)._assert_(_st(_st(d)._removeKey_ifAbsent_(key,(function(){
  1123. return (42);
  1124. }))).__eq((42)));
  1125. return self}, self, "testRemoveKeyIfAbsent", [], smalltalk.DictionaryTest)},
  1126. args: [],
  1127. source: "testRemoveKeyIfAbsent\x0a | d key |\x0a\x0a d := Dictionary new.\x0a d at: 1 put: 2.\x0a d at: 2 put: 3.\x0a d at: 3 put: 4.\x0a\x0a key := 2.\x0a self assert: (d removeKey: key) = 3.\x0a\x0a key := 3.\x0a self assert: (d removeKey: key ifAbsent: [42]) = 4.\x0a\x0a key := 'why'.\x0a self assert: (d removeKey: key ifAbsent: [42] ) = 42.",
  1128. messageSends: ["new", "at:put:", "assert:", "=", "removeKey:", "removeKey:ifAbsent:"],
  1129. referencedClasses: ["Dictionary"]
  1130. }),
  1131. smalltalk.DictionaryTest);
  1132. smalltalk.addMethod(
  1133. "_testSize",
  1134. smalltalk.method({
  1135. selector: "testSize",
  1136. category: 'tests',
  1137. fn: function (){
  1138. var self=this;
  1139. return smalltalk.withContext(function($ctx) { var d;
  1140. d=_st((smalltalk.Dictionary || Dictionary))._new();
  1141. _st(self)._assert_(_st(_st(d)._size()).__eq((0)));
  1142. _st(d)._at_put_((1),(2));
  1143. _st(self)._assert_(_st(_st(d)._size()).__eq((1)));
  1144. _st(d)._at_put_((2),(3));
  1145. _st(self)._assert_(_st(_st(d)._size()).__eq((2)));
  1146. return self}, self, "testSize", [], smalltalk.DictionaryTest)},
  1147. args: [],
  1148. source: "testSize\x0a\x09| d |\x0a\x0a\x09d := Dictionary new.\x0a\x09self assert: d size = 0.\x0a\x0a\x09d at: 1 put: 2.\x0a\x09self assert: d size = 1.\x0a\x0a\x09d at: 2 put: 3.\x0a\x09self assert: d size = 2.",
  1149. messageSends: ["new", "assert:", "=", "size", "at:put:"],
  1150. referencedClasses: ["Dictionary"]
  1151. }),
  1152. smalltalk.DictionaryTest);
  1153. smalltalk.addMethod(
  1154. "_testValues",
  1155. smalltalk.method({
  1156. selector: "testValues",
  1157. category: 'tests',
  1158. fn: function (){
  1159. var self=this;
  1160. return smalltalk.withContext(function($ctx) { var d;
  1161. d=_st((smalltalk.Dictionary || Dictionary))._new();
  1162. _st(d)._at_put_((1),(2));
  1163. _st(d)._at_put_((2),(3));
  1164. _st(d)._at_put_((3),(4));
  1165. _st(self)._assert_(_st(_st(d)._values()).__eq([(2), (3), (4)]));
  1166. return self}, self, "testValues", [], smalltalk.DictionaryTest)},
  1167. args: [],
  1168. 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 = #(2 3 4)",
  1169. messageSends: ["new", "at:put:", "assert:", "=", "values"],
  1170. referencedClasses: ["Dictionary"]
  1171. }),
  1172. smalltalk.DictionaryTest);
  1173. smalltalk.addMethod(
  1174. "_collectionClass",
  1175. smalltalk.method({
  1176. selector: "collectionClass",
  1177. category: 'accessing',
  1178. fn: function (){
  1179. var self=this;
  1180. return smalltalk.withContext(function($ctx) { return (smalltalk.Dictionary || Dictionary);
  1181. }, self, "collectionClass", [], smalltalk.DictionaryTest.klass)},
  1182. args: [],
  1183. source: "collectionClass\x0a\x09^ Dictionary",
  1184. messageSends: [],
  1185. referencedClasses: ["Dictionary"]
  1186. }),
  1187. smalltalk.DictionaryTest.klass);
  1188. smalltalk.addClass('SequenceableCollectionTest', smalltalk.CollectionTest, [], 'Kernel-Tests');
  1189. smalltalk.addMethod(
  1190. "_testAt",
  1191. smalltalk.method({
  1192. selector: "testAt",
  1193. category: 'tests',
  1194. fn: function (){
  1195. var self=this;
  1196. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(self)._collection())._at_((4))).__eq((-4)));
  1197. _st(self)._should_raise_((function(){
  1198. return _st(_st(self)._collection())._at_((5));
  1199. }),(smalltalk.Error || Error));
  1200. return self}, self, "testAt", [], smalltalk.SequenceableCollectionTest)},
  1201. args: [],
  1202. source: "testAt\x0a\x09self assert: (self collection at: 4) = -4.\x0a\x09self should: [ self collection at: 5 ] raise: Error",
  1203. messageSends: ["assert:", "=", "at:", "collection", "should:raise:"],
  1204. referencedClasses: ["Error"]
  1205. }),
  1206. smalltalk.SequenceableCollectionTest);
  1207. smalltalk.addMethod(
  1208. "_testAtIfAbsent",
  1209. smalltalk.method({
  1210. selector: "testAtIfAbsent",
  1211. category: 'tests',
  1212. fn: function (){
  1213. var self=this;
  1214. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(self)._collection())._at_ifAbsent_(_st(_st(_st(self)._collection())._size()).__plus((1)),(function(){
  1215. return "none";
  1216. }))).__eq("none"));
  1217. return self}, self, "testAtIfAbsent", [], smalltalk.SequenceableCollectionTest)},
  1218. args: [],
  1219. source: "testAtIfAbsent\x0a\x09self assert: (self collection at: (self collection size + 1) ifAbsent: [ 'none' ]) = 'none'",
  1220. messageSends: ["assert:", "=", "at:ifAbsent:", "+", "size", "collection"],
  1221. referencedClasses: []
  1222. }),
  1223. smalltalk.SequenceableCollectionTest);
  1224. smalltalk.addClass('ArrayTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1225. smalltalk.addMethod(
  1226. "_testAtIfAbsent",
  1227. smalltalk.method({
  1228. selector: "testAtIfAbsent",
  1229. category: 'testing',
  1230. fn: function (){
  1231. var self=this;
  1232. return smalltalk.withContext(function($ctx) { var array;
  1233. array=["hello", "world"];
  1234. _st(self)._assert_equals_(_st(array)._at_((1)),"hello");
  1235. _st(self)._assert_equals_(_st(array)._at_((2)),"world");
  1236. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((2),(function(){
  1237. return "not found";
  1238. })),"world");
  1239. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((0),(function(){
  1240. return "not found";
  1241. })),"not found");
  1242. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((-10),(function(){
  1243. return "not found";
  1244. })),"not found");
  1245. _st(self)._assert_equals_(_st(array)._at_ifAbsent_((3),(function(){
  1246. return "not found";
  1247. })),"not found");
  1248. return self}, self, "testAtIfAbsent", [], smalltalk.ArrayTest)},
  1249. args: [],
  1250. 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'.",
  1251. messageSends: ["assert:equals:", "at:", "at:ifAbsent:"],
  1252. referencedClasses: []
  1253. }),
  1254. smalltalk.ArrayTest);
  1255. smalltalk.addMethod(
  1256. "_testFirstN",
  1257. smalltalk.method({
  1258. selector: "testFirstN",
  1259. category: 'testing',
  1260. fn: function (){
  1261. var self=this;
  1262. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_([(1),(2),(3)],_st([(1),(2),(3),(4),(5)])._first_((3)));
  1263. return self}, self, "testFirstN", [], smalltalk.ArrayTest)},
  1264. args: [],
  1265. source: "testFirstN\x0a\x09self assert: {1. 2. 3} equals: ({1. 2. 3. 4. 5} first: 3).",
  1266. messageSends: ["assert:equals:", "first:"],
  1267. referencedClasses: []
  1268. }),
  1269. smalltalk.ArrayTest);
  1270. smalltalk.addMethod(
  1271. "_testIfEmpty",
  1272. smalltalk.method({
  1273. selector: "testIfEmpty",
  1274. category: 'testing',
  1275. fn: function (){
  1276. var self=this;
  1277. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("zork",_st("")._ifEmpty_((function(){
  1278. return "zork";
  1279. })));
  1280. return self}, self, "testIfEmpty", [], smalltalk.ArrayTest)},
  1281. args: [],
  1282. source: "testIfEmpty\x0a\x09self assert: 'zork' equals: ( '' ifEmpty: ['zork'] )",
  1283. messageSends: ["assert:equals:", "ifEmpty:"],
  1284. referencedClasses: []
  1285. }),
  1286. smalltalk.ArrayTest);
  1287. smalltalk.addMethod(
  1288. "_testPrintString",
  1289. smalltalk.method({
  1290. selector: "testPrintString",
  1291. category: 'testing',
  1292. fn: function (){
  1293. var self=this;
  1294. return smalltalk.withContext(function($ctx) { var $1,$2;
  1295. var array;
  1296. array=_st((smalltalk.Array || Array))._new();
  1297. _st(self)._assert_equals_("a Array ()",_st(array)._printString());
  1298. _st(array)._add_((1));
  1299. $1=_st(array)._add_((3));
  1300. _st(self)._assert_equals_("a Array (1 3)",_st(array)._printString());
  1301. _st(array)._add_("foo");
  1302. _st(self)._assert_equals_("a Array (1 3 'foo')",_st(array)._printString());
  1303. _st(array)._remove_((1));
  1304. $2=_st(array)._remove_((3));
  1305. _st(self)._assert_equals_("a Array ('foo')",_st(array)._printString());
  1306. _st(array)._addLast_((3));
  1307. _st(self)._assert_equals_("a Array ('foo' 3)",_st(array)._printString());
  1308. _st(array)._addLast_((3));
  1309. _st(self)._assert_equals_("a Array ('foo' 3 3)",_st(array)._printString());
  1310. return self}, self, "testPrintString", [], smalltalk.ArrayTest)},
  1311. args: [],
  1312. source: "testPrintString\x0a\x09| array |\x0a\x09array := Array new.\x0a\x09self assert: 'a Array ()' equals: ( array printString ).\x0a\x09array add: 1; add: 3.\x0a\x09self assert: 'a Array (1 3)' equals: ( array printString ).\x0a\x09array add: 'foo'.\x0a\x09self assert: 'a Array (1 3 ''foo'')' equals: ( array printString ).\x0a\x09array remove: 1; remove: 3.\x0a\x09self assert: 'a Array (''foo'')' equals: ( array printString ).\x0a\x09array addLast: 3.\x0a\x09self assert: 'a Array (''foo'' 3)' equals: ( array printString ).\x0a\x09array addLast: 3.\x0a\x09self assert: 'a Array (''foo'' 3 3)' equals: ( array printString ).",
  1313. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:", "addLast:"],
  1314. referencedClasses: ["Array"]
  1315. }),
  1316. smalltalk.ArrayTest);
  1317. smalltalk.addMethod(
  1318. "_collectionClass",
  1319. smalltalk.method({
  1320. selector: "collectionClass",
  1321. category: 'accessing',
  1322. fn: function (){
  1323. var self=this;
  1324. return smalltalk.withContext(function($ctx) { return (smalltalk.Array || Array);
  1325. }, self, "collectionClass", [], smalltalk.ArrayTest.klass)},
  1326. args: [],
  1327. source: "collectionClass\x0a\x09^ Array",
  1328. messageSends: [],
  1329. referencedClasses: ["Array"]
  1330. }),
  1331. smalltalk.ArrayTest.klass);
  1332. smalltalk.addClass('StringTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1333. smalltalk.addMethod(
  1334. "_collection",
  1335. smalltalk.method({
  1336. selector: "collection",
  1337. category: 'accessing',
  1338. fn: function (){
  1339. var self=this;
  1340. return smalltalk.withContext(function($ctx) { return "hello";
  1341. }, self, "collection", [], smalltalk.StringTest)},
  1342. args: [],
  1343. source: "collection\x0a\x09^'hello'",
  1344. messageSends: [],
  1345. referencedClasses: []
  1346. }),
  1347. smalltalk.StringTest);
  1348. smalltalk.addMethod(
  1349. "_collectionWithDuplicates",
  1350. smalltalk.method({
  1351. selector: "collectionWithDuplicates",
  1352. category: 'accessing',
  1353. fn: function (){
  1354. var self=this;
  1355. return smalltalk.withContext(function($ctx) { return "abbaerte";
  1356. }, self, "collectionWithDuplicates", [], smalltalk.StringTest)},
  1357. args: [],
  1358. source: "collectionWithDuplicates\x0a\x09^ 'abbaerte'",
  1359. messageSends: [],
  1360. referencedClasses: []
  1361. }),
  1362. smalltalk.StringTest);
  1363. smalltalk.addMethod(
  1364. "_testAddRemove",
  1365. smalltalk.method({
  1366. selector: "testAddRemove",
  1367. category: 'tests',
  1368. fn: function (){
  1369. var self=this;
  1370. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  1371. return _st("hello")._add_("a");
  1372. }),(smalltalk.Error || Error));
  1373. _st(self)._should_raise_((function(){
  1374. return _st("hello")._remove_("h");
  1375. }),(smalltalk.Error || Error));
  1376. return self}, self, "testAddRemove", [], smalltalk.StringTest)},
  1377. args: [],
  1378. source: "testAddRemove\x0a\x09self should: ['hello' add: 'a'] raise: Error.\x0a\x09self should: ['hello' remove: 'h'] raise: Error",
  1379. messageSends: ["should:raise:", "add:", "remove:"],
  1380. referencedClasses: ["Error"]
  1381. }),
  1382. smalltalk.StringTest);
  1383. smalltalk.addMethod(
  1384. "_testAsArray",
  1385. smalltalk.method({
  1386. selector: "testAsArray",
  1387. category: 'tests',
  1388. fn: function (){
  1389. var self=this;
  1390. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st("hello")._asArray()).__eq(["h", "e", "l", "l", "o"]));
  1391. return self}, self, "testAsArray", [], smalltalk.StringTest)},
  1392. args: [],
  1393. source: "testAsArray\x0a\x09self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').",
  1394. messageSends: ["assert:", "=", "asArray"],
  1395. referencedClasses: []
  1396. }),
  1397. smalltalk.StringTest);
  1398. smalltalk.addMethod(
  1399. "_testAt",
  1400. smalltalk.method({
  1401. selector: "testAt",
  1402. category: 'tests',
  1403. fn: function (){
  1404. var self=this;
  1405. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st("hello")._at_((1))).__eq("h"));
  1406. _st(self)._assert_(_st(_st("hello")._at_((5))).__eq("o"));
  1407. _st(self)._assert_(_st(_st("hello")._at_ifAbsent_((6),(function(){
  1408. return nil;
  1409. }))).__eq(nil));
  1410. return self}, self, "testAt", [], smalltalk.StringTest)},
  1411. args: [],
  1412. source: "testAt\x0a\x09self assert: ('hello' at: 1) = 'h'.\x0a\x09self assert: ('hello' at: 5) = 'o'.\x0a\x09self assert: ('hello' at: 6 ifAbsent: [nil]) = nil",
  1413. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  1414. referencedClasses: []
  1415. }),
  1416. smalltalk.StringTest);
  1417. smalltalk.addMethod(
  1418. "_testAtPut",
  1419. smalltalk.method({
  1420. selector: "testAtPut",
  1421. category: 'tests',
  1422. fn: function (){
  1423. var self=this;
  1424. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  1425. return _st("hello")._at_put_((1),"a");
  1426. }),(smalltalk.Error || Error));
  1427. return self}, self, "testAtPut", [], smalltalk.StringTest)},
  1428. args: [],
  1429. source: "testAtPut\x0a\x09\x22String instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1430. messageSends: ["should:raise:", "at:put:"],
  1431. referencedClasses: ["Error"]
  1432. }),
  1433. smalltalk.StringTest);
  1434. smalltalk.addMethod(
  1435. "_testCollect",
  1436. smalltalk.method({
  1437. selector: "testCollect",
  1438. category: 'tests',
  1439. fn: function (){
  1440. var self=this;
  1441. return smalltalk.withContext(function($ctx) { var newCollection;
  1442. newCollection="hheelllloo";
  1443. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._collect_((function(each){
  1444. return _st(each).__comma(each);
  1445. })),newCollection);
  1446. return self}, self, "testCollect", [], smalltalk.StringTest)},
  1447. args: [],
  1448. 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",
  1449. messageSends: ["assertSameContents:as:", "collect:", ",", "collection"],
  1450. referencedClasses: []
  1451. }),
  1452. smalltalk.StringTest);
  1453. smalltalk.addMethod(
  1454. "_testCopyWithoutAll",
  1455. smalltalk.method({
  1456. selector: "testCopyWithoutAll",
  1457. category: 'tests',
  1458. fn: function (){
  1459. var self=this;
  1460. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("hello world",_st("*hello* *world*")._copyWithoutAll_("*"));
  1461. return self}, self, "testCopyWithoutAll", [], smalltalk.StringTest)},
  1462. args: [],
  1463. source: "testCopyWithoutAll\x0a\x09self \x0a\x09\x09assert: 'hello world' \x0a\x09\x09equals: ('*hello* *world*' copyWithoutAll: '*')",
  1464. messageSends: ["assert:equals:", "copyWithoutAll:"],
  1465. referencedClasses: []
  1466. }),
  1467. smalltalk.StringTest);
  1468. smalltalk.addMethod(
  1469. "_testDetect",
  1470. smalltalk.method({
  1471. selector: "testDetect",
  1472. category: 'tests',
  1473. fn: function (){
  1474. var self=this;
  1475. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(self)._collection())._detect_((function(each){
  1476. return _st(each).__eq("h");
  1477. }))).__eq("h"));
  1478. _st(self)._should_raise_((function(){
  1479. return _st(_st(self)._collection())._detect_((function(each){
  1480. return _st(each).__eq((6));
  1481. }));
  1482. }),(smalltalk.Error || Error));
  1483. return self}, self, "testDetect", [], smalltalk.StringTest)},
  1484. args: [],
  1485. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.\x0a\x09self \x0a\x09\x09should: [ self collection detect: [ :each | each = 6 ] ]\x0a\x09\x09raise: Error",
  1486. messageSends: ["assert:", "=", "detect:", "collection", "should:raise:"],
  1487. referencedClasses: ["Error"]
  1488. }),
  1489. smalltalk.StringTest);
  1490. smalltalk.addMethod(
  1491. "_testEquality",
  1492. smalltalk.method({
  1493. selector: "testEquality",
  1494. category: 'tests',
  1495. fn: function (){
  1496. var self=this;
  1497. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st("hello").__eq("hello"));
  1498. _st(self)._deny_(_st("hello").__eq("world"));
  1499. _st(self)._assert_(_st("hello").__eq(_st("hello")._yourself()));
  1500. _st(self)._assert_(_st(_st("hello")._yourself()).__eq("hello"));
  1501. _st(self)._deny_(_st("").__eq((0)));
  1502. return self}, self, "testEquality", [], smalltalk.StringTest)},
  1503. args: [],
  1504. source: "testEquality\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",
  1505. messageSends: ["assert:", "=", "deny:", "yourself"],
  1506. referencedClasses: []
  1507. }),
  1508. smalltalk.StringTest);
  1509. smalltalk.addMethod(
  1510. "_testIdentity",
  1511. smalltalk.method({
  1512. selector: "testIdentity",
  1513. category: 'tests',
  1514. fn: function (){
  1515. var self=this;
  1516. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st("hello").__eq_eq("hello"));
  1517. _st(self)._deny_(_st("hello").__eq_eq("world"));
  1518. _st(self)._assert_(_st("hello").__eq_eq(_st("hello")._yourself()));
  1519. _st(self)._assert_(_st(_st("hello")._yourself()).__eq_eq("hello"));
  1520. _st(self)._deny_(_st("").__eq_eq((0)));
  1521. return self}, self, "testIdentity", [], smalltalk.StringTest)},
  1522. args: [],
  1523. 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",
  1524. messageSends: ["assert:", "==", "deny:", "yourself"],
  1525. referencedClasses: []
  1526. }),
  1527. smalltalk.StringTest);
  1528. smalltalk.addMethod(
  1529. "_testIncludesSubString",
  1530. smalltalk.method({
  1531. selector: "testIncludesSubString",
  1532. category: 'tests',
  1533. fn: function (){
  1534. var self=this;
  1535. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st("amber")._includesSubString_("ber"));
  1536. _st(self)._deny_(_st("amber")._includesSubString_("zork"));
  1537. return self}, self, "testIncludesSubString", [], smalltalk.StringTest)},
  1538. args: [],
  1539. source: "testIncludesSubString\x0a\x09self assert: ('amber' includesSubString: 'ber').\x0a\x09self deny: ('amber' includesSubString: 'zork').",
  1540. messageSends: ["assert:", "includesSubString:", "deny:"],
  1541. referencedClasses: []
  1542. }),
  1543. smalltalk.StringTest);
  1544. smalltalk.addMethod(
  1545. "_testJoin",
  1546. smalltalk.method({
  1547. selector: "testJoin",
  1548. category: 'tests',
  1549. fn: function (){
  1550. var self=this;
  1551. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("hello,world",_st(",")._join_(["hello", "world"]));
  1552. return self}, self, "testJoin", [], smalltalk.StringTest)},
  1553. args: [],
  1554. source: "testJoin\x0a\x09self assert: 'hello,world' equals: (',' join: #('hello' 'world'))",
  1555. messageSends: ["assert:equals:", "join:"],
  1556. referencedClasses: []
  1557. }),
  1558. smalltalk.StringTest);
  1559. smalltalk.addMethod(
  1560. "_testSelect",
  1561. smalltalk.method({
  1562. selector: "testSelect",
  1563. category: 'tests',
  1564. fn: function (){
  1565. var self=this;
  1566. return smalltalk.withContext(function($ctx) { var newCollection;
  1567. newCollection="o";
  1568. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._select_((function(each){
  1569. return _st(each).__eq("o");
  1570. })),newCollection);
  1571. return self}, self, "testSelect", [], smalltalk.StringTest)},
  1572. args: [],
  1573. 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",
  1574. messageSends: ["assertSameContents:as:", "select:", "=", "collection"],
  1575. referencedClasses: []
  1576. }),
  1577. smalltalk.StringTest);
  1578. smalltalk.addMethod(
  1579. "_testSize",
  1580. smalltalk.method({
  1581. selector: "testSize",
  1582. category: 'tests',
  1583. fn: function (){
  1584. var self=this;
  1585. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st("smalltalk")._size(),(9));
  1586. _st(self)._assert_equals_(_st("")._size(),(0));
  1587. return self}, self, "testSize", [], smalltalk.StringTest)},
  1588. args: [],
  1589. source: "testSize\x0a\x09self assert: 'smalltalk' size equals: 9.\x0a\x09self assert: '' size equals: 0",
  1590. messageSends: ["assert:equals:", "size"],
  1591. referencedClasses: []
  1592. }),
  1593. smalltalk.StringTest);
  1594. smalltalk.addMethod(
  1595. "_testStreamContents",
  1596. smalltalk.method({
  1597. selector: "testStreamContents",
  1598. category: 'tests',
  1599. fn: function (){
  1600. var self=this;
  1601. return smalltalk.withContext(function($ctx) { var $1;
  1602. _st(self)._assert_equals_("hello world",_st((smalltalk.String || String))._streamContents_((function(aStream){
  1603. _st(aStream)._nextPutAll_("hello");
  1604. _st(aStream)._space();
  1605. $1=_st(aStream)._nextPutAll_("world");
  1606. return $1;
  1607. })));
  1608. return self}, self, "testStreamContents", [], smalltalk.StringTest)},
  1609. args: [],
  1610. source: "testStreamContents\x0a\x09self \x0a\x09\x09assert: 'hello world' \x0a\x09\x09equals: (String streamContents: [ :aStream | \x0a\x09\x09\x09aStream \x0a\x09\x09\x09\x09nextPutAll: 'hello'; space; \x0a\x09\x09\x09\x09nextPutAll: 'world' ])",
  1611. messageSends: ["assert:equals:", "streamContents:", "nextPutAll:", "space"],
  1612. referencedClasses: ["String"]
  1613. }),
  1614. smalltalk.StringTest);
  1615. smalltalk.addMethod(
  1616. "_collectionClass",
  1617. smalltalk.method({
  1618. selector: "collectionClass",
  1619. category: 'accessing',
  1620. fn: function (){
  1621. var self=this;
  1622. return smalltalk.withContext(function($ctx) { return (smalltalk.String || String);
  1623. }, self, "collectionClass", [], smalltalk.StringTest.klass)},
  1624. args: [],
  1625. source: "collectionClass\x0a\x09^ String",
  1626. messageSends: [],
  1627. referencedClasses: ["String"]
  1628. }),
  1629. smalltalk.StringTest.klass);
  1630. smalltalk.addClass('SymbolTest', smalltalk.SequenceableCollectionTest, [], 'Kernel-Tests');
  1631. smalltalk.addMethod(
  1632. "_collection",
  1633. smalltalk.method({
  1634. selector: "collection",
  1635. category: 'accessing',
  1636. fn: function (){
  1637. var self=this;
  1638. return smalltalk.withContext(function($ctx) { return smalltalk.symbolFor("hello");
  1639. }, self, "collection", [], smalltalk.SymbolTest)},
  1640. args: [],
  1641. source: "collection\x0a\x09^ #hello",
  1642. messageSends: [],
  1643. referencedClasses: []
  1644. }),
  1645. smalltalk.SymbolTest);
  1646. smalltalk.addMethod(
  1647. "_collectionWithDuplicates",
  1648. smalltalk.method({
  1649. selector: "collectionWithDuplicates",
  1650. category: 'accessing',
  1651. fn: function (){
  1652. var self=this;
  1653. return smalltalk.withContext(function($ctx) { return smalltalk.symbolFor("phhaaarorra");
  1654. }, self, "collectionWithDuplicates", [], smalltalk.SymbolTest)},
  1655. args: [],
  1656. source: "collectionWithDuplicates\x0a\x09^ #phhaaarorra",
  1657. messageSends: [],
  1658. referencedClasses: []
  1659. }),
  1660. smalltalk.SymbolTest);
  1661. smalltalk.addMethod(
  1662. "_testAsString",
  1663. smalltalk.method({
  1664. selector: "testAsString",
  1665. category: 'tests',
  1666. fn: function (){
  1667. var self=this;
  1668. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(smalltalk.symbolFor("hello"))._asString(),"hello");
  1669. return self}, self, "testAsString", [], smalltalk.SymbolTest)},
  1670. args: [],
  1671. source: "testAsString\x0a\x09self assert: #hello asString equals: 'hello'",
  1672. messageSends: ["assert:equals:", "asString"],
  1673. referencedClasses: []
  1674. }),
  1675. smalltalk.SymbolTest);
  1676. smalltalk.addMethod(
  1677. "_testAsSymbol",
  1678. smalltalk.method({
  1679. selector: "testAsSymbol",
  1680. category: 'tests',
  1681. fn: function (){
  1682. var self=this;
  1683. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(smalltalk.symbolFor("hello")).__eq_eq(_st(smalltalk.symbolFor("hello"))._asSymbol()));
  1684. return self}, self, "testAsSymbol", [], smalltalk.SymbolTest)},
  1685. args: [],
  1686. source: "testAsSymbol\x0a\x09self assert: #hello == #hello asSymbol",
  1687. messageSends: ["assert:", "==", "asSymbol"],
  1688. referencedClasses: []
  1689. }),
  1690. smalltalk.SymbolTest);
  1691. smalltalk.addMethod(
  1692. "_testAt",
  1693. smalltalk.method({
  1694. selector: "testAt",
  1695. category: 'tests',
  1696. fn: function (){
  1697. var self=this;
  1698. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(smalltalk.symbolFor("hello"))._at_((1))).__eq("h"));
  1699. _st(self)._assert_(_st(_st(smalltalk.symbolFor("hello"))._at_((5))).__eq("o"));
  1700. _st(self)._assert_(_st(_st(smalltalk.symbolFor("hello"))._at_ifAbsent_((6),(function(){
  1701. return nil;
  1702. }))).__eq(nil));
  1703. return self}, self, "testAt", [], smalltalk.SymbolTest)},
  1704. args: [],
  1705. source: "testAt\x0a\x09self assert: (#hello at: 1) = 'h'.\x0a\x09self assert: (#hello at: 5) = 'o'.\x0a\x09self assert: (#hello at: 6 ifAbsent: [nil]) = nil",
  1706. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  1707. referencedClasses: []
  1708. }),
  1709. smalltalk.SymbolTest);
  1710. smalltalk.addMethod(
  1711. "_testAtPut",
  1712. smalltalk.method({
  1713. selector: "testAtPut",
  1714. category: 'tests',
  1715. fn: function (){
  1716. var self=this;
  1717. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  1718. return _st("hello")._at_put_((1),"a");
  1719. }),(smalltalk.Error || Error));
  1720. return self}, self, "testAtPut", [], smalltalk.SymbolTest)},
  1721. args: [],
  1722. source: "testAtPut\x0a\x09\x22Symbol instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1723. messageSends: ["should:raise:", "at:put:"],
  1724. referencedClasses: ["Error"]
  1725. }),
  1726. smalltalk.SymbolTest);
  1727. smalltalk.addMethod(
  1728. "_testCollect",
  1729. smalltalk.method({
  1730. selector: "testCollect",
  1731. category: 'tests',
  1732. fn: function (){
  1733. var self=this;
  1734. return smalltalk.withContext(function($ctx) { var newCollection;
  1735. newCollection=smalltalk.symbolFor("hheelllloo");
  1736. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._collect_((function(each){
  1737. return _st(each).__comma(each);
  1738. })),newCollection);
  1739. return self}, self, "testCollect", [], smalltalk.SymbolTest)},
  1740. args: [],
  1741. 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",
  1742. messageSends: ["assertSameContents:as:", "collect:", ",", "collection"],
  1743. referencedClasses: []
  1744. }),
  1745. smalltalk.SymbolTest);
  1746. smalltalk.addMethod(
  1747. "_testComparing",
  1748. smalltalk.method({
  1749. selector: "testComparing",
  1750. category: 'tests',
  1751. fn: function (){
  1752. var self=this;
  1753. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(smalltalk.symbolFor("ab")).__gt(smalltalk.symbolFor("aa")));
  1754. _st(self)._deny_(_st(smalltalk.symbolFor("ab")).__gt(smalltalk.symbolFor("ba")));
  1755. _st(self)._assert_(_st(smalltalk.symbolFor("ab")).__lt(smalltalk.symbolFor("ba")));
  1756. _st(self)._deny_(_st(smalltalk.symbolFor("bb")).__lt(smalltalk.symbolFor("ba")));
  1757. _st(self)._assert_(_st(smalltalk.symbolFor("ab")).__gt_eq(smalltalk.symbolFor("aa")));
  1758. _st(self)._deny_(_st(smalltalk.symbolFor("ab")).__gt_eq(smalltalk.symbolFor("ba")));
  1759. _st(self)._assert_(_st(smalltalk.symbolFor("ab")).__lt_eq(smalltalk.symbolFor("ba")));
  1760. _st(self)._deny_(_st(smalltalk.symbolFor("bb")).__lt_eq(smalltalk.symbolFor("ba")));
  1761. return self}, self, "testComparing", [], smalltalk.SymbolTest)},
  1762. args: [],
  1763. source: "testComparing\x0a\x09self assert: #ab > #aa.\x0a\x09self deny: #ab > #ba.\x0a\x0a\x09self assert: #ab < #ba.\x0a\x09self deny: #bb < #ba.\x0a\x0a\x09self assert: #ab >= #aa.\x0a\x09self deny: #ab >= #ba.\x0a\x0a\x09self assert: #ab <= #ba.\x0a\x09self deny: #bb <= #ba",
  1764. messageSends: ["assert:", ">", "deny:", "<", ">=", "<="],
  1765. referencedClasses: []
  1766. }),
  1767. smalltalk.SymbolTest);
  1768. smalltalk.addMethod(
  1769. "_testCopying",
  1770. smalltalk.method({
  1771. selector: "testCopying",
  1772. category: 'tests',
  1773. fn: function (){
  1774. var self=this;
  1775. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(smalltalk.symbolFor("hello"))._copy()).__eq_eq(smalltalk.symbolFor("hello")));
  1776. _st(self)._assert_(_st(_st(smalltalk.symbolFor("hello"))._deepCopy()).__eq_eq(smalltalk.symbolFor("hello")));
  1777. return self}, self, "testCopying", [], smalltalk.SymbolTest)},
  1778. args: [],
  1779. source: "testCopying\x0a\x09self assert: #hello copy == #hello.\x0a\x09self assert: #hello deepCopy == #hello",
  1780. messageSends: ["assert:", "==", "copy", "deepCopy"],
  1781. referencedClasses: []
  1782. }),
  1783. smalltalk.SymbolTest);
  1784. smalltalk.addMethod(
  1785. "_testDetect",
  1786. smalltalk.method({
  1787. selector: "testDetect",
  1788. category: 'tests',
  1789. fn: function (){
  1790. var self=this;
  1791. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(self)._collection())._detect_((function(each){
  1792. return _st(each).__eq("h");
  1793. }))).__eq("h"));
  1794. _st(self)._should_raise_((function(){
  1795. return _st(_st(self)._collection())._detect_((function(each){
  1796. return _st(each).__eq("z");
  1797. }));
  1798. }),(smalltalk.Error || Error));
  1799. return self}, self, "testDetect", [], smalltalk.SymbolTest)},
  1800. args: [],
  1801. source: "testDetect\x0a\x09self assert: (self collection detect: [ :each | each = 'h' ]) = 'h'.\x0a\x09self \x0a\x09\x09should: [ self collection detect: [ :each | each = 'z' ] ]\x0a\x09\x09raise: Error",
  1802. messageSends: ["assert:", "=", "detect:", "collection", "should:raise:"],
  1803. referencedClasses: ["Error"]
  1804. }),
  1805. smalltalk.SymbolTest);
  1806. smalltalk.addMethod(
  1807. "_testEquality",
  1808. smalltalk.method({
  1809. selector: "testEquality",
  1810. category: 'tests',
  1811. fn: function (){
  1812. var self=this;
  1813. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(smalltalk.symbolFor("hello")).__eq(smalltalk.symbolFor("hello")));
  1814. _st(self)._deny_(_st(smalltalk.symbolFor("hello")).__eq(smalltalk.symbolFor("world")));
  1815. _st(self)._assert_(_st(smalltalk.symbolFor("hello")).__eq(_st(smalltalk.symbolFor("hello"))._yourself()));
  1816. _st(self)._assert_(_st(_st(smalltalk.symbolFor("hello"))._yourself()).__eq(smalltalk.symbolFor("hello")));
  1817. _st(self)._deny_(_st(smalltalk.symbolFor("hello")).__eq("hello"));
  1818. _st(self)._deny_(_st("hello").__eq(smalltalk.symbolFor("hello")));
  1819. return self}, self, "testEquality", [], smalltalk.SymbolTest)},
  1820. args: [],
  1821. source: "testEquality\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\x09self deny: #hello = 'hello'.\x0a\x09self deny: 'hello' = #hello.",
  1822. messageSends: ["assert:", "=", "deny:", "yourself"],
  1823. referencedClasses: []
  1824. }),
  1825. smalltalk.SymbolTest);
  1826. smalltalk.addMethod(
  1827. "_testIdentity",
  1828. smalltalk.method({
  1829. selector: "testIdentity",
  1830. category: 'tests',
  1831. fn: function (){
  1832. var self=this;
  1833. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(smalltalk.symbolFor("hello")).__eq_eq(smalltalk.symbolFor("hello")));
  1834. _st(self)._deny_(_st(smalltalk.symbolFor("hello")).__eq_eq(smalltalk.symbolFor("world")));
  1835. _st(self)._assert_(_st(smalltalk.symbolFor("hello")).__eq(_st(smalltalk.symbolFor("hello"))._yourself()));
  1836. _st(self)._assert_(_st(_st(smalltalk.symbolFor("hello"))._yourself()).__eq(_st(_st(smalltalk.symbolFor("hello"))._asString())._asSymbol()));
  1837. return self}, self, "testIdentity", [], smalltalk.SymbolTest)},
  1838. args: [],
  1839. 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 asString asSymbol",
  1840. messageSends: ["assert:", "==", "deny:", "=", "yourself", "asSymbol", "asString"],
  1841. referencedClasses: []
  1842. }),
  1843. smalltalk.SymbolTest);
  1844. smalltalk.addMethod(
  1845. "_testIsEmpty",
  1846. smalltalk.method({
  1847. selector: "testIsEmpty",
  1848. category: 'tests',
  1849. fn: function (){
  1850. var self=this;
  1851. return smalltalk.withContext(function($ctx) { _st(self)._deny_(_st(_st(self)._collection())._isEmpty());
  1852. _st(self)._assert_(_st(_st("")._asSymbol())._isEmpty());
  1853. return self}, self, "testIsEmpty", [], smalltalk.SymbolTest)},
  1854. args: [],
  1855. source: "testIsEmpty\x0a\x09self deny: self collection isEmpty.\x0a\x09self assert: '' asSymbol isEmpty",
  1856. messageSends: ["deny:", "isEmpty", "collection", "assert:", "asSymbol"],
  1857. referencedClasses: []
  1858. }),
  1859. smalltalk.SymbolTest);
  1860. smalltalk.addMethod(
  1861. "_testIsSymbolIsString",
  1862. smalltalk.method({
  1863. selector: "testIsSymbolIsString",
  1864. category: 'tests',
  1865. fn: function (){
  1866. var self=this;
  1867. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(smalltalk.symbolFor("hello"))._isSymbol());
  1868. _st(self)._deny_(_st("hello")._isSymbol());
  1869. _st(self)._deny_(_st(smalltalk.symbolFor("hello"))._isString());
  1870. _st(self)._assert_(_st("hello")._isString());
  1871. return self}, self, "testIsSymbolIsString", [], smalltalk.SymbolTest)},
  1872. args: [],
  1873. source: "testIsSymbolIsString\x0a\x09self assert: #hello isSymbol.\x0a\x09self deny: 'hello' isSymbol.\x0a\x09self deny: #hello isString.\x0a\x09self assert: 'hello' isString",
  1874. messageSends: ["assert:", "isSymbol", "deny:", "isString"],
  1875. referencedClasses: []
  1876. }),
  1877. smalltalk.SymbolTest);
  1878. smalltalk.addMethod(
  1879. "_testSelect",
  1880. smalltalk.method({
  1881. selector: "testSelect",
  1882. category: 'tests',
  1883. fn: function (){
  1884. var self=this;
  1885. return smalltalk.withContext(function($ctx) { var newCollection;
  1886. newCollection="o";
  1887. _st(self)._assertSameContents_as_(_st(_st(self)._collection())._select_((function(each){
  1888. return _st(each).__eq("o");
  1889. })),newCollection);
  1890. return self}, self, "testSelect", [], smalltalk.SymbolTest)},
  1891. args: [],
  1892. 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",
  1893. messageSends: ["assertSameContents:as:", "select:", "=", "collection"],
  1894. referencedClasses: []
  1895. }),
  1896. smalltalk.SymbolTest);
  1897. smalltalk.addMethod(
  1898. "_testSize",
  1899. smalltalk.method({
  1900. selector: "testSize",
  1901. category: 'tests',
  1902. fn: function (){
  1903. var self=this;
  1904. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(smalltalk.symbolFor("a"))._size(),(1));
  1905. _st(self)._assert_equals_(_st(smalltalk.symbolFor("aaaaa"))._size(),(5));
  1906. return self}, self, "testSize", [], smalltalk.SymbolTest)},
  1907. args: [],
  1908. source: "testSize\x0a\x09self assert: #a size equals: 1.\x0a\x09self assert: #aaaaa size equals: 5",
  1909. messageSends: ["assert:equals:", "size"],
  1910. referencedClasses: []
  1911. }),
  1912. smalltalk.SymbolTest);
  1913. smalltalk.addMethod(
  1914. "_collectionClass",
  1915. smalltalk.method({
  1916. selector: "collectionClass",
  1917. category: 'accessing',
  1918. fn: function (){
  1919. var self=this;
  1920. return smalltalk.withContext(function($ctx) { return (smalltalk.Symbol || Symbol);
  1921. }, self, "collectionClass", [], smalltalk.SymbolTest.klass)},
  1922. args: [],
  1923. source: "collectionClass\x0a\x09^ Symbol",
  1924. messageSends: [],
  1925. referencedClasses: ["Symbol"]
  1926. }),
  1927. smalltalk.SymbolTest.klass);
  1928. smalltalk.addClass('JSObjectProxyTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1929. smalltalk.addMethod(
  1930. "_jsObject",
  1931. smalltalk.method({
  1932. selector: "jsObject",
  1933. category: 'accessing',
  1934. fn: function (){
  1935. var self=this;
  1936. return smalltalk.withContext(function($ctx) { return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: ''};
  1937. ;
  1938. return self}, self, "jsObject", [], smalltalk.JSObjectProxyTest)},
  1939. args: [],
  1940. source: "jsObject\x0a\x09<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}, d: ''}>",
  1941. messageSends: [],
  1942. referencedClasses: []
  1943. }),
  1944. smalltalk.JSObjectProxyTest);
  1945. smalltalk.addMethod(
  1946. "_testDNU",
  1947. smalltalk.method({
  1948. selector: "testDNU",
  1949. category: 'tests',
  1950. fn: function (){
  1951. var self=this;
  1952. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  1953. return _st(_st(self)._jsObject())._foo();
  1954. }),(smalltalk.MessageNotUnderstood || MessageNotUnderstood));
  1955. return self}, self, "testDNU", [], smalltalk.JSObjectProxyTest)},
  1956. args: [],
  1957. source: "testDNU\x0a\x09self should: [self jsObject foo] raise: MessageNotUnderstood",
  1958. messageSends: ["should:raise:", "foo", "jsObject"],
  1959. referencedClasses: ["MessageNotUnderstood"]
  1960. }),
  1961. smalltalk.JSObjectProxyTest);
  1962. smalltalk.addMethod(
  1963. "_testMessageSend",
  1964. smalltalk.method({
  1965. selector: "testMessageSend",
  1966. category: 'tests',
  1967. fn: function (){
  1968. var self=this;
  1969. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(_st(self)._jsObject())._a(),(1));
  1970. _st(self)._assert_equals_(_st(_st(self)._jsObject())._b(),(2));
  1971. _st(self)._assert_equals_(_st(_st(self)._jsObject())._c_((3)),(3));
  1972. return self}, self, "testMessageSend", [], smalltalk.JSObjectProxyTest)},
  1973. args: [],
  1974. 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",
  1975. messageSends: ["assert:equals:", "a", "jsObject", "b", "c:"],
  1976. referencedClasses: []
  1977. }),
  1978. smalltalk.JSObjectProxyTest);
  1979. smalltalk.addMethod(
  1980. "_testMethodWithArguments",
  1981. smalltalk.method({
  1982. selector: "testMethodWithArguments",
  1983. category: 'tests',
  1984. fn: function (){
  1985. var self=this;
  1986. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(_st(self)._jsObject())._c_((1)),(1));
  1987. return self}, self, "testMethodWithArguments", [], smalltalk.JSObjectProxyTest)},
  1988. args: [],
  1989. source: "testMethodWithArguments\x0a\x09self assert: (self jsObject c: 1) equals: 1",
  1990. messageSends: ["assert:equals:", "c:", "jsObject"],
  1991. referencedClasses: []
  1992. }),
  1993. smalltalk.JSObjectProxyTest);
  1994. smalltalk.addMethod(
  1995. "_testPrinting",
  1996. smalltalk.method({
  1997. selector: "testPrinting",
  1998. category: 'tests',
  1999. fn: function (){
  2000. var self=this;
  2001. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(_st(self)._jsObject())._printString()).__eq("[object Object]"));
  2002. return self}, self, "testPrinting", [], smalltalk.JSObjectProxyTest)},
  2003. args: [],
  2004. source: "testPrinting\x0a\x09self assert: self jsObject printString = '[object Object]'",
  2005. messageSends: ["assert:", "=", "printString", "jsObject"],
  2006. referencedClasses: []
  2007. }),
  2008. smalltalk.JSObjectProxyTest);
  2009. smalltalk.addMethod(
  2010. "_testPropertyThatReturnsEmptyString",
  2011. smalltalk.method({
  2012. selector: "testPropertyThatReturnsEmptyString",
  2013. category: 'tests',
  2014. fn: function (){
  2015. var self=this;
  2016. return smalltalk.withContext(function($ctx) { var object;
  2017. object=_st(self)._jsObject();
  2018. _st(self)._assert_equals_("",_st(object)._d());
  2019. _st(object)._d_("hello");
  2020. _st(self)._assert_equals_("hello",_st(object)._d());
  2021. return self}, self, "testPropertyThatReturnsEmptyString", [], smalltalk.JSObjectProxyTest)},
  2022. args: [],
  2023. source: "testPropertyThatReturnsEmptyString\x0a\x09| object |\x0a\x0a\x09object := self jsObject.\x0a\x09self assert: '' equals: object d.\x0a\x0a\x09object d: 'hello'.\x0a\x09self assert: 'hello' equals: object d",
  2024. messageSends: ["jsObject", "assert:equals:", "d", "d:"],
  2025. referencedClasses: []
  2026. }),
  2027. smalltalk.JSObjectProxyTest);
  2028. smalltalk.addMethod(
  2029. "_testYourself",
  2030. smalltalk.method({
  2031. selector: "testYourself",
  2032. category: 'tests',
  2033. fn: function (){
  2034. var self=this;
  2035. return smalltalk.withContext(function($ctx) { var $1,$2;
  2036. var object;
  2037. $1=_st(self)._jsObject();
  2038. _st($1)._d_("test");
  2039. $2=_st($1)._yourself();
  2040. object=$2;
  2041. _st(self)._assert_equals_(_st(object)._d(),"test");
  2042. return self}, self, "testYourself", [], smalltalk.JSObjectProxyTest)},
  2043. args: [],
  2044. source: "testYourself\x0a\x09| object |\x0a\x09object := self jsObject\x0a\x09\x09d: 'test';\x0a\x09\x09yourself.\x0a\x0a\x09self assert: object d equals: 'test'",
  2045. messageSends: ["d:", "jsObject", "yourself", "assert:equals:", "d"],
  2046. referencedClasses: []
  2047. }),
  2048. smalltalk.JSObjectProxyTest);
  2049. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2050. smalltalk.addMethod(
  2051. "_testAbs",
  2052. smalltalk.method({
  2053. selector: "testAbs",
  2054. category: 'tests',
  2055. fn: function (){
  2056. var self=this;
  2057. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((4))._abs()).__eq((4)));
  2058. _st(self)._assert_(_st(_st((-4))._abs()).__eq((4)));
  2059. return self}, self, "testAbs", [], smalltalk.NumberTest)},
  2060. args: [],
  2061. source: "testAbs\x0a\x09self assert: 4 abs = 4.\x0a\x09self assert: -4 abs = 4",
  2062. messageSends: ["assert:", "=", "abs"],
  2063. referencedClasses: []
  2064. }),
  2065. smalltalk.NumberTest);
  2066. smalltalk.addMethod(
  2067. "_testArithmetic",
  2068. smalltalk.method({
  2069. selector: "testArithmetic",
  2070. category: 'tests',
  2071. fn: function (){
  2072. var self=this;
  2073. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((1.5)).__plus((1))).__eq((2.5)));
  2074. _st(self)._assert_(_st(_st((2)).__minus((1))).__eq((1)));
  2075. _st(self)._assert_(_st(_st((-2)).__minus((1))).__eq((-3)));
  2076. _st(self)._assert_(_st(_st((12)).__slash((2))).__eq((6)));
  2077. _st(self)._assert_(_st(_st((3)).__star((4))).__eq((12)));
  2078. _st(self)._assert_(_st(_st(_st((1)).__plus((2))).__star((3))).__eq((9)));
  2079. _st(self)._assert_(_st(_st((1)).__plus(_st((2)).__star((3)))).__eq((7)));
  2080. return self}, self, "testArithmetic", [], smalltalk.NumberTest)},
  2081. args: [],
  2082. 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 = 2.5.\x0a\x09self assert: 2 - 1 = 1.\x0a\x09self assert: -2 - 1 = -3.\x0a\x09self assert: 12 / 2 = 6.\x0a\x09self assert: 3 * 4 = 12.\x0a\x0a\x09\x22Simple parenthesis and execution order\x22\x0a\x0a\x09self assert: 1 + 2 * 3 = 9.\x0a\x09self assert: 1 + (2 * 3) = 7",
  2083. messageSends: ["assert:", "=", "+", "-", "/", "*"],
  2084. referencedClasses: []
  2085. }),
  2086. smalltalk.NumberTest);
  2087. smalltalk.addMethod(
  2088. "_testComparison",
  2089. smalltalk.method({
  2090. selector: "testComparison",
  2091. category: 'tests',
  2092. fn: function (){
  2093. var self=this;
  2094. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st((3)).__gt((2)));
  2095. _st(self)._assert_(_st((2)).__lt((3)));
  2096. _st(self)._deny_(_st((3)).__lt((2)));
  2097. _st(self)._deny_(_st((2)).__gt((3)));
  2098. _st(self)._assert_(_st((3)).__gt_eq((3)));
  2099. _st(self)._assert_(_st((3.1)).__gt_eq((3)));
  2100. _st(self)._assert_(_st((3)).__lt_eq((3)));
  2101. _st(self)._assert_(_st((3)).__lt_eq((3.1)));
  2102. return self}, self, "testComparison", [], smalltalk.NumberTest)},
  2103. args: [],
  2104. 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",
  2105. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  2106. referencedClasses: []
  2107. }),
  2108. smalltalk.NumberTest);
  2109. smalltalk.addMethod(
  2110. "_testCopying",
  2111. smalltalk.method({
  2112. selector: "testCopying",
  2113. category: 'tests',
  2114. fn: function (){
  2115. var self=this;
  2116. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((1))._copy()).__eq_eq((1)));
  2117. _st(self)._assert_(_st(_st((1))._deepCopy()).__eq_eq((1)));
  2118. return self}, self, "testCopying", [], smalltalk.NumberTest)},
  2119. args: [],
  2120. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  2121. messageSends: ["assert:", "==", "copy", "deepCopy"],
  2122. referencedClasses: []
  2123. }),
  2124. smalltalk.NumberTest);
  2125. smalltalk.addMethod(
  2126. "_testEquality",
  2127. smalltalk.method({
  2128. selector: "testEquality",
  2129. category: 'tests',
  2130. fn: function (){
  2131. var self=this;
  2132. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st((1)).__eq((1)));
  2133. _st(self)._assert_(_st((0)).__eq((0)));
  2134. _st(self)._deny_(_st((1)).__eq((0)));
  2135. _st(self)._assert_(_st(_st((1))._yourself()).__eq((1)));
  2136. _st(self)._assert_(_st((1)).__eq(_st((1))._yourself()));
  2137. _st(self)._assert_(_st(_st((1))._yourself()).__eq(_st((1))._yourself()));
  2138. _st(self)._deny_(_st((0)).__eq(false));
  2139. _st(self)._deny_(_st(false).__eq((0)));
  2140. _st(self)._deny_(_st("").__eq((0)));
  2141. _st(self)._deny_(_st((0)).__eq(""));
  2142. return self}, self, "testEquality", [], smalltalk.NumberTest)},
  2143. args: [],
  2144. 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 = ''",
  2145. messageSends: ["assert:", "=", "deny:", "yourself"],
  2146. referencedClasses: []
  2147. }),
  2148. smalltalk.NumberTest);
  2149. smalltalk.addMethod(
  2150. "_testIdentity",
  2151. smalltalk.method({
  2152. selector: "testIdentity",
  2153. category: 'tests',
  2154. fn: function (){
  2155. var self=this;
  2156. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st((1)).__eq_eq((1)));
  2157. _st(self)._assert_(_st((0)).__eq_eq((0)));
  2158. _st(self)._deny_(_st((1)).__eq_eq((0)));
  2159. _st(self)._assert_(_st(_st((1))._yourself()).__eq_eq((1)));
  2160. _st(self)._assert_(_st((1)).__eq_eq(_st((1))._yourself()));
  2161. _st(self)._assert_(_st(_st((1))._yourself()).__eq_eq(_st((1))._yourself()));
  2162. _st(self)._deny_(_st((1)).__eq_eq((2)));
  2163. return self}, self, "testIdentity", [], smalltalk.NumberTest)},
  2164. args: [],
  2165. 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",
  2166. messageSends: ["assert:", "==", "deny:", "yourself"],
  2167. referencedClasses: []
  2168. }),
  2169. smalltalk.NumberTest);
  2170. smalltalk.addMethod(
  2171. "_testMinMax",
  2172. smalltalk.method({
  2173. selector: "testMinMax",
  2174. category: 'tests',
  2175. fn: function (){
  2176. var self=this;
  2177. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((2))._max_((5)),(5));
  2178. _st(self)._assert_equals_(_st((2))._min_((5)),(2));
  2179. return self}, self, "testMinMax", [], smalltalk.NumberTest)},
  2180. args: [],
  2181. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  2182. messageSends: ["assert:equals:", "max:", "min:"],
  2183. referencedClasses: []
  2184. }),
  2185. smalltalk.NumberTest);
  2186. smalltalk.addMethod(
  2187. "_testNegated",
  2188. smalltalk.method({
  2189. selector: "testNegated",
  2190. category: 'tests',
  2191. fn: function (){
  2192. var self=this;
  2193. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((3))._negated()).__eq((-3)));
  2194. _st(self)._assert_(_st(_st((-3))._negated()).__eq((3)));
  2195. return self}, self, "testNegated", [], smalltalk.NumberTest)},
  2196. args: [],
  2197. source: "testNegated\x0a\x09self assert: 3 negated = -3.\x0a\x09self assert: -3 negated = 3",
  2198. messageSends: ["assert:", "=", "negated"],
  2199. referencedClasses: []
  2200. }),
  2201. smalltalk.NumberTest);
  2202. smalltalk.addMethod(
  2203. "_testPrintShowingDecimalPlaces",
  2204. smalltalk.method({
  2205. selector: "testPrintShowingDecimalPlaces",
  2206. category: 'tests',
  2207. fn: function (){
  2208. var self=this;
  2209. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("23.00",_st((23))._printShowingDecimalPlaces_((2)));
  2210. _st(self)._assert_equals_("23.57",_st((23.5698))._printShowingDecimalPlaces_((2)));
  2211. _st(self)._assert_equals_("-234.56700",_st(_st((234.567))._negated())._printShowingDecimalPlaces_((5)));
  2212. _st(self)._assert_equals_("23",_st((23.4567))._printShowingDecimalPlaces_((0)));
  2213. _st(self)._assert_equals_("24",_st((23.5567))._printShowingDecimalPlaces_((0)));
  2214. _st(self)._assert_equals_("-23",_st(_st((23.4567))._negated())._printShowingDecimalPlaces_((0)));
  2215. _st(self)._assert_equals_("-24",_st(_st((23.5567))._negated())._printShowingDecimalPlaces_((0)));
  2216. _st(self)._assert_equals_("100000000.0",_st((100000000))._printShowingDecimalPlaces_((1)));
  2217. _st(self)._assert_equals_("0.98000",_st((0.98))._printShowingDecimalPlaces_((5)));
  2218. _st(self)._assert_equals_("-0.98",_st(_st((0.98))._negated())._printShowingDecimalPlaces_((2)));
  2219. _st(self)._assert_equals_("2.57",_st((2.567))._printShowingDecimalPlaces_((2)));
  2220. _st(self)._assert_equals_("-2.57",_st((-2.567))._printShowingDecimalPlaces_((2)));
  2221. _st(self)._assert_equals_("0.00",_st((0))._printShowingDecimalPlaces_((2)));
  2222. return self}, self, "testPrintShowingDecimalPlaces", [], smalltalk.NumberTest)},
  2223. args: [],
  2224. source: "testPrintShowingDecimalPlaces\x0a\x09self assert: '23.00' equals: (23 printShowingDecimalPlaces: 2).\x0a\x09self assert: '23.57' equals: (23.5698 printShowingDecimalPlaces: 2).\x0a\x09self assert: '-234.56700' equals:( 234.567 negated printShowingDecimalPlaces: 5).\x0a\x09self assert: '23' equals: (23.4567 printShowingDecimalPlaces: 0).\x0a\x09self assert: '24' equals: (23.5567 printShowingDecimalPlaces: 0).\x0a\x09self assert: '-23' equals: (23.4567 negated printShowingDecimalPlaces: 0).\x0a\x09self assert: '-24' equals: (23.5567 negated printShowingDecimalPlaces: 0).\x0a\x09self assert: '100000000.0' equals: (100000000 printShowingDecimalPlaces: 1).\x0a\x09self assert: '0.98000' equals: (0.98 printShowingDecimalPlaces: 5).\x0a\x09self assert: '-0.98' equals: (0.98 negated printShowingDecimalPlaces: 2).\x0a\x09self assert: '2.57' equals: (2.567 printShowingDecimalPlaces: 2).\x0a\x09self assert: '-2.57' equals: (-2.567 printShowingDecimalPlaces: 2).\x0a\x09self assert: '0.00' equals: (0 printShowingDecimalPlaces: 2).",
  2225. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  2226. referencedClasses: []
  2227. }),
  2228. smalltalk.NumberTest);
  2229. smalltalk.addMethod(
  2230. "_testRounded",
  2231. smalltalk.method({
  2232. selector: "testRounded",
  2233. category: 'tests',
  2234. fn: function (){
  2235. var self=this;
  2236. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((3))._rounded()).__eq((3)));
  2237. _st(self)._assert_(_st(_st((3.212))._rounded()).__eq((3)));
  2238. _st(self)._assert_(_st(_st((3.51))._rounded()).__eq((4)));
  2239. return self}, self, "testRounded", [], smalltalk.NumberTest)},
  2240. args: [],
  2241. source: "testRounded\x0a\x09\x0a\x09self assert: 3 rounded = 3.\x0a\x09self assert: 3.212 rounded = 3.\x0a\x09self assert: 3.51 rounded = 4",
  2242. messageSends: ["assert:", "=", "rounded"],
  2243. referencedClasses: []
  2244. }),
  2245. smalltalk.NumberTest);
  2246. smalltalk.addMethod(
  2247. "_testSqrt",
  2248. smalltalk.method({
  2249. selector: "testSqrt",
  2250. category: 'tests',
  2251. fn: function (){
  2252. var self=this;
  2253. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((4))._sqrt()).__eq((2)));
  2254. _st(self)._assert_(_st(_st((16))._sqrt()).__eq((4)));
  2255. return self}, self, "testSqrt", [], smalltalk.NumberTest)},
  2256. args: [],
  2257. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt = 2.\x0a\x09self assert: 16 sqrt = 4",
  2258. messageSends: ["assert:", "=", "sqrt"],
  2259. referencedClasses: []
  2260. }),
  2261. smalltalk.NumberTest);
  2262. smalltalk.addMethod(
  2263. "_testSquared",
  2264. smalltalk.method({
  2265. selector: "testSquared",
  2266. category: 'tests',
  2267. fn: function (){
  2268. var self=this;
  2269. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((4))._squared()).__eq((16)));
  2270. return self}, self, "testSquared", [], smalltalk.NumberTest)},
  2271. args: [],
  2272. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared = 16",
  2273. messageSends: ["assert:", "=", "squared"],
  2274. referencedClasses: []
  2275. }),
  2276. smalltalk.NumberTest);
  2277. smalltalk.addMethod(
  2278. "_testTimesRepeat",
  2279. smalltalk.method({
  2280. selector: "testTimesRepeat",
  2281. category: 'tests',
  2282. fn: function (){
  2283. var self=this;
  2284. return smalltalk.withContext(function($ctx) { var i;
  2285. i=(0);
  2286. _st((0))._timesRepeat_((function(){
  2287. i=_st(i).__plus((1));
  2288. return i;
  2289. }));
  2290. _st(self)._assert_equals_(i,(0));
  2291. _st((5))._timesRepeat_((function(){
  2292. i=_st(i).__plus((1));
  2293. return i;
  2294. }));
  2295. _st(self)._assert_equals_(i,(5));
  2296. return self}, self, "testTimesRepeat", [], smalltalk.NumberTest)},
  2297. args: [],
  2298. 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",
  2299. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  2300. referencedClasses: []
  2301. }),
  2302. smalltalk.NumberTest);
  2303. smalltalk.addMethod(
  2304. "_testTo",
  2305. smalltalk.method({
  2306. selector: "testTo",
  2307. category: 'tests',
  2308. fn: function (){
  2309. var self=this;
  2310. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((1))._to_((5)),[(1), (2), (3), (4), (5)]);
  2311. return self}, self, "testTo", [], smalltalk.NumberTest)},
  2312. args: [],
  2313. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  2314. messageSends: ["assert:equals:", "to:"],
  2315. referencedClasses: []
  2316. }),
  2317. smalltalk.NumberTest);
  2318. smalltalk.addMethod(
  2319. "_testToBy",
  2320. smalltalk.method({
  2321. selector: "testToBy",
  2322. category: 'tests',
  2323. fn: function (){
  2324. var self=this;
  2325. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((0))._to_by_((6),(2)),[(0), (2), (4), (6)]);
  2326. _st(self)._should_raise_((function(){
  2327. return _st((1))._to_by_((4),(0));
  2328. }),(smalltalk.Error || Error));
  2329. return self}, self, "testToBy", [], smalltalk.NumberTest)},
  2330. args: [],
  2331. 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",
  2332. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  2333. referencedClasses: ["Error"]
  2334. }),
  2335. smalltalk.NumberTest);
  2336. smalltalk.addMethod(
  2337. "_testTruncated",
  2338. smalltalk.method({
  2339. selector: "testTruncated",
  2340. category: 'tests',
  2341. fn: function (){
  2342. var self=this;
  2343. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((3))._truncated()).__eq((3)));
  2344. _st(self)._assert_(_st(_st((3.212))._truncated()).__eq((3)));
  2345. _st(self)._assert_(_st(_st((3.51))._truncated()).__eq((3)));
  2346. return self}, self, "testTruncated", [], smalltalk.NumberTest)},
  2347. args: [],
  2348. source: "testTruncated\x0a\x09\x0a\x09self assert: 3 truncated = 3.\x0a\x09self assert: 3.212 truncated = 3.\x0a\x09self assert: 3.51 truncated = 3",
  2349. messageSends: ["assert:", "=", "truncated"],
  2350. referencedClasses: []
  2351. }),
  2352. smalltalk.NumberTest);
  2353. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  2354. smalltalk.addMethod(
  2355. "_foo",
  2356. smalltalk.method({
  2357. selector: "foo",
  2358. category: 'not yet classified',
  2359. fn: function (){
  2360. var self=this;
  2361. return smalltalk.withContext(function($ctx) { return self["@foo"];
  2362. }, self, "foo", [], smalltalk.ObjectMock)},
  2363. args: [],
  2364. source: "foo\x0a\x09^foo",
  2365. messageSends: [],
  2366. referencedClasses: []
  2367. }),
  2368. smalltalk.ObjectMock);
  2369. smalltalk.addMethod(
  2370. "_foo_",
  2371. smalltalk.method({
  2372. selector: "foo:",
  2373. category: 'not yet classified',
  2374. fn: function (anObject){
  2375. var self=this;
  2376. return smalltalk.withContext(function($ctx) { self["@foo"]=anObject;
  2377. return self}, self, "foo:", [anObject], smalltalk.ObjectMock)},
  2378. args: ["anObject"],
  2379. source: "foo: anObject\x0a\x09foo := anObject",
  2380. messageSends: [],
  2381. referencedClasses: []
  2382. }),
  2383. smalltalk.ObjectMock);
  2384. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2385. smalltalk.addMethod(
  2386. "_testBasicAccess",
  2387. smalltalk.method({
  2388. selector: "testBasicAccess",
  2389. category: 'tests',
  2390. fn: function (){
  2391. var self=this;
  2392. return smalltalk.withContext(function($ctx) { var o;
  2393. o=_st((smalltalk.Object || Object))._new();
  2394. _st(o)._basicAt_put_("a",(1));
  2395. _st(self)._assert_equals_(_st(o)._basicAt_("a"),(1));
  2396. _st(self)._assert_equals_(_st(o)._basicAt_("b"),nil);
  2397. return self}, self, "testBasicAccess", [], smalltalk.ObjectTest)},
  2398. args: [],
  2399. 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",
  2400. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  2401. referencedClasses: ["Object"]
  2402. }),
  2403. smalltalk.ObjectTest);
  2404. smalltalk.addMethod(
  2405. "_testBasicPerform",
  2406. smalltalk.method({
  2407. selector: "testBasicPerform",
  2408. category: 'tests',
  2409. fn: function (){
  2410. var self=this;
  2411. return smalltalk.withContext(function($ctx) { var o;
  2412. o=_st((smalltalk.Object || Object))._new();
  2413. _st(o)._basicAt_put_("func",(function(){
  2414. return "hello";
  2415. }));
  2416. _st(o)._basicAt_put_("func2",(function(a){
  2417. return _st(a).__plus((1));
  2418. }));
  2419. _st(self)._assert_equals_(_st(o)._basicPerform_("func"),"hello");
  2420. _st(self)._assert_equals_(_st(o)._basicPerform_withArguments_("func2",[(3)]),(4));
  2421. return self}, self, "testBasicPerform", [], smalltalk.ObjectTest)},
  2422. args: [],
  2423. source: "testBasicPerform\x0a\x09| o |\x0a\x09o := Object new.\x0a\x09o basicAt: 'func' put: ['hello'].\x09\x0a\x09o basicAt: 'func2' put: [:a | a + 1].\x0a\x0a\x09self assert: (o basicPerform: 'func')\x09 equals: 'hello'.\x0a\x09self assert: (o basicPerform: 'func2' withArguments: #(3)) equals: 4",
  2424. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  2425. referencedClasses: ["Object"]
  2426. }),
  2427. smalltalk.ObjectTest);
  2428. smalltalk.addMethod(
  2429. "_testDNU",
  2430. smalltalk.method({
  2431. selector: "testDNU",
  2432. category: 'tests',
  2433. fn: function (){
  2434. var self=this;
  2435. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  2436. return _st(_st((smalltalk.Object || Object))._new())._foo();
  2437. }),(smalltalk.MessageNotUnderstood || MessageNotUnderstood));
  2438. return self}, self, "testDNU", [], smalltalk.ObjectTest)},
  2439. args: [],
  2440. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  2441. messageSends: ["should:raise:", "foo", "new"],
  2442. referencedClasses: ["Object", "MessageNotUnderstood"]
  2443. }),
  2444. smalltalk.ObjectTest);
  2445. smalltalk.addMethod(
  2446. "_testEquality",
  2447. smalltalk.method({
  2448. selector: "testEquality",
  2449. category: 'tests',
  2450. fn: function (){
  2451. var self=this;
  2452. return smalltalk.withContext(function($ctx) { var o;
  2453. o=_st((smalltalk.Object || Object))._new();
  2454. _st(self)._deny_(_st(o).__eq(_st((smalltalk.Object || Object))._new()));
  2455. _st(self)._assert_(_st(o).__eq(o));
  2456. _st(self)._assert_(_st(_st(o)._yourself()).__eq(o));
  2457. _st(self)._assert_(_st(o).__eq(_st(o)._yourself()));
  2458. return self}, self, "testEquality", [], smalltalk.ObjectTest)},
  2459. args: [],
  2460. 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",
  2461. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  2462. referencedClasses: ["Object"]
  2463. }),
  2464. smalltalk.ObjectTest);
  2465. smalltalk.addMethod(
  2466. "_testHalt",
  2467. smalltalk.method({
  2468. selector: "testHalt",
  2469. category: 'tests',
  2470. fn: function (){
  2471. var self=this;
  2472. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  2473. return _st(_st((smalltalk.Object || Object))._new())._halt();
  2474. }),(smalltalk.Error || Error));
  2475. return self}, self, "testHalt", [], smalltalk.ObjectTest)},
  2476. args: [],
  2477. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  2478. messageSends: ["should:raise:", "halt", "new"],
  2479. referencedClasses: ["Object", "Error"]
  2480. }),
  2481. smalltalk.ObjectTest);
  2482. smalltalk.addMethod(
  2483. "_testIdentity",
  2484. smalltalk.method({
  2485. selector: "testIdentity",
  2486. category: 'tests',
  2487. fn: function (){
  2488. var self=this;
  2489. return smalltalk.withContext(function($ctx) { var o;
  2490. o=_st((smalltalk.Object || Object))._new();
  2491. _st(self)._deny_(_st(o).__eq_eq(_st((smalltalk.Object || Object))._new()));
  2492. _st(self)._assert_(_st(o).__eq_eq(o));
  2493. _st(self)._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  2494. _st(self)._assert_(_st(o).__eq_eq(_st(o)._yourself()));
  2495. return self}, self, "testIdentity", [], smalltalk.ObjectTest)},
  2496. args: [],
  2497. 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",
  2498. messageSends: ["new", "deny:", "==", "assert:", "yourself"],
  2499. referencedClasses: ["Object"]
  2500. }),
  2501. smalltalk.ObjectTest);
  2502. smalltalk.addMethod(
  2503. "_testIfNil",
  2504. smalltalk.method({
  2505. selector: "testIfNil",
  2506. category: 'tests',
  2507. fn: function (){
  2508. var self=this;
  2509. return smalltalk.withContext(function($ctx) { var $2,$1,$4,$3,$6,$5;
  2510. _st(self)._deny_(_st(_st((smalltalk.Object || Object))._new())._isNil());
  2511. $2=_st((smalltalk.Object || Object))._new();
  2512. if(($receiver = $2) == nil || $receiver == undefined){
  2513. $1=true;
  2514. } else {
  2515. $1=$2;
  2516. };
  2517. _st(self)._deny_(_st($1).__eq(true));
  2518. $4=_st((smalltalk.Object || Object))._new();
  2519. if(($receiver = $4) == nil || $receiver == undefined){
  2520. $3=$4;
  2521. } else {
  2522. $3=true;
  2523. };
  2524. _st(self)._assert_(_st($3).__eq(true));
  2525. $6=_st((smalltalk.Object || Object))._new();
  2526. if(($receiver = $6) == nil || $receiver == undefined){
  2527. $5=false;
  2528. } else {
  2529. $5=true;
  2530. };
  2531. _st(self)._assert_(_st($5).__eq(true));
  2532. _st(self)._assert_(_st(_st(_st((smalltalk.Object || Object))._new())._ifNotNil_ifNil_((function(){
  2533. return true;
  2534. }),(function(){
  2535. return false;
  2536. }))).__eq(true));
  2537. return self}, self, "testIfNil", [], smalltalk.ObjectTest)},
  2538. args: [],
  2539. source: "testIfNil\x0a\x09self deny: Object new isNil.\x0a\x09self deny: (Object new ifNil: [true]) = true.\x0a\x09self assert: (Object new ifNotNil: [true]) = true.\x0a\x0a\x09self assert: (Object new ifNil: [false] ifNotNil: [true]) = true.\x0a\x09self assert: (Object new ifNotNil: [true] ifNil: [false]) = true",
  2540. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  2541. referencedClasses: ["Object"]
  2542. }),
  2543. smalltalk.ObjectTest);
  2544. smalltalk.addMethod(
  2545. "_testInstVars",
  2546. smalltalk.method({
  2547. selector: "testInstVars",
  2548. category: 'tests',
  2549. fn: function (){
  2550. var self=this;
  2551. return smalltalk.withContext(function($ctx) { var o;
  2552. o=_st((smalltalk.ObjectMock || ObjectMock))._new();
  2553. _st(self)._assert_equals_(_st(o)._instVarAt_(smalltalk.symbolFor("foo")),nil);
  2554. _st(o)._instVarAt_put_(smalltalk.symbolFor("foo"),(1));
  2555. _st(self)._assert_equals_(_st(o)._instVarAt_(smalltalk.symbolFor("foo")),(1));
  2556. _st(self)._assert_equals_(_st(o)._instVarAt_("foo"),(1));
  2557. return self}, self, "testInstVars", [], smalltalk.ObjectTest)},
  2558. args: [],
  2559. 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",
  2560. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  2561. referencedClasses: ["ObjectMock"]
  2562. }),
  2563. smalltalk.ObjectTest);
  2564. smalltalk.addMethod(
  2565. "_testNilUndefined",
  2566. smalltalk.method({
  2567. selector: "testNilUndefined",
  2568. category: 'tests',
  2569. fn: function (){
  2570. var self=this;
  2571. return smalltalk.withContext(function($ctx) { var notDefined;
  2572. notDefined=_st(window)._at_("__this_is_undefined");
  2573. _st(self)._assert_(_st(nil).__eq(notDefined));
  2574. return self}, self, "testNilUndefined", [], smalltalk.ObjectTest)},
  2575. args: [],
  2576. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09| notDefined |\x0a \x0a notDefined := window at: '__this_is_undefined'.\x0a\x0a\x09self assert: nil = notDefined",
  2577. messageSends: ["at:", "assert:", "="],
  2578. referencedClasses: []
  2579. }),
  2580. smalltalk.ObjectTest);
  2581. smalltalk.addMethod(
  2582. "_testYourself",
  2583. smalltalk.method({
  2584. selector: "testYourself",
  2585. category: 'tests',
  2586. fn: function (){
  2587. var self=this;
  2588. return smalltalk.withContext(function($ctx) { var o;
  2589. o=_st((smalltalk.ObjectMock || ObjectMock))._new();
  2590. _st(self)._assert_(_st(_st(o)._yourself()).__eq_eq(o));
  2591. return self}, self, "testYourself", [], smalltalk.ObjectTest)},
  2592. args: [],
  2593. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  2594. messageSends: ["new", "assert:", "==", "yourself"],
  2595. referencedClasses: ["ObjectMock"]
  2596. }),
  2597. smalltalk.ObjectTest);
  2598. smalltalk.addMethod(
  2599. "_testidentityHash",
  2600. smalltalk.method({
  2601. selector: "testidentityHash",
  2602. category: 'tests',
  2603. fn: function (){
  2604. var self=this;
  2605. return smalltalk.withContext(function($ctx) { var o1;
  2606. var o2;
  2607. o1=_st((smalltalk.Object || Object))._new();
  2608. o2=_st((smalltalk.Object || Object))._new();
  2609. _st(self)._assert_(_st(_st(o1)._identityHash()).__eq_eq(_st(o1)._identityHash()));
  2610. _st(self)._deny_(_st(_st(o1)._identityHash()).__eq_eq(_st(o2)._identityHash()));
  2611. return self}, self, "testidentityHash", [], smalltalk.ObjectTest)},
  2612. args: [],
  2613. 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",
  2614. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  2615. referencedClasses: ["Object"]
  2616. }),
  2617. smalltalk.ObjectTest);
  2618. smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
  2619. smalltalk.addMethod(
  2620. "_setUp",
  2621. smalltalk.method({
  2622. selector: "setUp",
  2623. category: 'running',
  2624. fn: function (){
  2625. var self=this;
  2626. return smalltalk.withContext(function($ctx) { var $1,$2;
  2627. self["@backUpCommitPathJs"]=_st((smalltalk.Package || Package))._defaultCommitPathJs();
  2628. self["@backUpCommitPathSt"]=_st((smalltalk.Package || Package))._defaultCommitPathSt();
  2629. _st((smalltalk.Package || Package))._resetCommitPaths();
  2630. self["@zorkPackage"]=_st(_st((smalltalk.Package || Package))._new())._name_("Zork");
  2631. $1=_st((smalltalk.Package || Package))._new();
  2632. _st($1)._name_("Grul");
  2633. _st($1)._commitPathJs_("server/grul/js");
  2634. _st($1)._commitPathSt_("grul/st");
  2635. $2=_st($1)._yourself();
  2636. self["@grulPackage"]=$2;
  2637. return self}, self, "setUp", [], smalltalk.PackageTest)},
  2638. args: [],
  2639. 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",
  2640. messageSends: ["defaultCommitPathJs", "defaultCommitPathSt", "resetCommitPaths", "name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
  2641. referencedClasses: ["Package"]
  2642. }),
  2643. smalltalk.PackageTest);
  2644. smalltalk.addMethod(
  2645. "_tearDown",
  2646. smalltalk.method({
  2647. selector: "tearDown",
  2648. category: 'running',
  2649. fn: function (){
  2650. var self=this;
  2651. return smalltalk.withContext(function($ctx) { var $1;
  2652. _st((smalltalk.Package || Package))._defaultCommitPathJs_(self["@backUpCommitPathJs"]);
  2653. $1=_st((smalltalk.Package || Package))._defaultCommitPathSt_(self["@backUpCommitPathSt"]);
  2654. return self}, self, "tearDown", [], smalltalk.PackageTest)},
  2655. args: [],
  2656. source: "tearDown\x0a\x09 Package \x0a\x09\x09defaultCommitPathJs: backUpCommitPathJs;\x0a\x09\x09defaultCommitPathSt: backUpCommitPathSt",
  2657. messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
  2658. referencedClasses: ["Package"]
  2659. }),
  2660. smalltalk.PackageTest);
  2661. smalltalk.addMethod(
  2662. "_testGrulCommitPathJsShouldBeServerGrulJs",
  2663. smalltalk.method({
  2664. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  2665. category: 'tests',
  2666. fn: function (){
  2667. var self=this;
  2668. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("server/grul/js",_st(self["@grulPackage"])._commitPathJs());
  2669. return self}, self, "testGrulCommitPathJsShouldBeServerGrulJs", [], smalltalk.PackageTest)},
  2670. args: [],
  2671. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  2672. messageSends: ["assert:equals:", "commitPathJs"],
  2673. referencedClasses: []
  2674. }),
  2675. smalltalk.PackageTest);
  2676. smalltalk.addMethod(
  2677. "_testGrulCommitPathStShouldBeGrulSt",
  2678. smalltalk.method({
  2679. selector: "testGrulCommitPathStShouldBeGrulSt",
  2680. category: 'tests',
  2681. fn: function (){
  2682. var self=this;
  2683. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("grul/st",_st(self["@grulPackage"])._commitPathSt());
  2684. return self}, self, "testGrulCommitPathStShouldBeGrulSt", [], smalltalk.PackageTest)},
  2685. args: [],
  2686. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  2687. messageSends: ["assert:equals:", "commitPathSt"],
  2688. referencedClasses: []
  2689. }),
  2690. smalltalk.PackageTest);
  2691. smalltalk.addMethod(
  2692. "_testZorkCommitPathJsShouldBeJs",
  2693. smalltalk.method({
  2694. selector: "testZorkCommitPathJsShouldBeJs",
  2695. category: 'tests',
  2696. fn: function (){
  2697. var self=this;
  2698. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("js",_st(self["@zorkPackage"])._commitPathJs());
  2699. return self}, self, "testZorkCommitPathJsShouldBeJs", [], smalltalk.PackageTest)},
  2700. args: [],
  2701. source: "testZorkCommitPathJsShouldBeJs\x0a\x09self assert: 'js' equals: zorkPackage commitPathJs",
  2702. messageSends: ["assert:equals:", "commitPathJs"],
  2703. referencedClasses: []
  2704. }),
  2705. smalltalk.PackageTest);
  2706. smalltalk.addMethod(
  2707. "_testZorkCommitPathStShouldBeSt",
  2708. smalltalk.method({
  2709. selector: "testZorkCommitPathStShouldBeSt",
  2710. category: 'tests',
  2711. fn: function (){
  2712. var self=this;
  2713. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("st",_st(self["@zorkPackage"])._commitPathSt());
  2714. return self}, self, "testZorkCommitPathStShouldBeSt", [], smalltalk.PackageTest)},
  2715. args: [],
  2716. source: "testZorkCommitPathStShouldBeSt\x0a\x09self assert: 'st' equals: zorkPackage commitPathSt",
  2717. messageSends: ["assert:equals:", "commitPathSt"],
  2718. referencedClasses: []
  2719. }),
  2720. smalltalk.PackageTest);
  2721. smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
  2722. smalltalk.addMethod(
  2723. "_setUp",
  2724. smalltalk.method({
  2725. selector: "setUp",
  2726. category: 'running',
  2727. fn: function (){
  2728. var self=this;
  2729. return smalltalk.withContext(function($ctx) { var $1;
  2730. smalltalk.PackageTest.fn.prototype._setUp.apply(_st(self), []);
  2731. _st((smalltalk.Package || Package))._defaultCommitPathJs_("javascripts/");
  2732. $1=_st((smalltalk.Package || Package))._defaultCommitPathSt_("smalltalk/");
  2733. return self}, self, "setUp", [], smalltalk.PackageWithDefaultCommitPathChangedTest)},
  2734. args: [],
  2735. source: "setUp\x0a\x09super setUp.\x0a\x0a\x09Package\x0a\x09\x09defaultCommitPathJs: 'javascripts/';\x0a\x09\x09defaultCommitPathSt: 'smalltalk/'.",
  2736. messageSends: ["setUp", "defaultCommitPathJs:", "defaultCommitPathSt:"],
  2737. referencedClasses: ["Package"]
  2738. }),
  2739. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2740. smalltalk.addMethod(
  2741. "_testGrulCommitPathJsShouldBeServerGrulJs",
  2742. smalltalk.method({
  2743. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  2744. category: 'tests',
  2745. fn: function (){
  2746. var self=this;
  2747. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("server/grul/js",_st(self["@grulPackage"])._commitPathJs());
  2748. return self}, self, "testGrulCommitPathJsShouldBeServerGrulJs", [], smalltalk.PackageWithDefaultCommitPathChangedTest)},
  2749. args: [],
  2750. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  2751. messageSends: ["assert:equals:", "commitPathJs"],
  2752. referencedClasses: []
  2753. }),
  2754. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2755. smalltalk.addMethod(
  2756. "_testGrulCommitPathStShouldBeGrulSt",
  2757. smalltalk.method({
  2758. selector: "testGrulCommitPathStShouldBeGrulSt",
  2759. category: 'tests',
  2760. fn: function (){
  2761. var self=this;
  2762. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("grul/st",_st(self["@grulPackage"])._commitPathSt());
  2763. return self}, self, "testGrulCommitPathStShouldBeGrulSt", [], smalltalk.PackageWithDefaultCommitPathChangedTest)},
  2764. args: [],
  2765. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  2766. messageSends: ["assert:equals:", "commitPathSt"],
  2767. referencedClasses: []
  2768. }),
  2769. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2770. smalltalk.addMethod(
  2771. "_testZorkCommitPathJsShouldBeJavascript",
  2772. smalltalk.method({
  2773. selector: "testZorkCommitPathJsShouldBeJavascript",
  2774. category: 'tests',
  2775. fn: function (){
  2776. var self=this;
  2777. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("javascripts/",_st(self["@zorkPackage"])._commitPathJs());
  2778. return self}, self, "testZorkCommitPathJsShouldBeJavascript", [], smalltalk.PackageWithDefaultCommitPathChangedTest)},
  2779. args: [],
  2780. source: "testZorkCommitPathJsShouldBeJavascript\x0a\x09self assert: 'javascripts/' equals: zorkPackage commitPathJs",
  2781. messageSends: ["assert:equals:", "commitPathJs"],
  2782. referencedClasses: []
  2783. }),
  2784. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2785. smalltalk.addMethod(
  2786. "_testZorkCommitPathStShouldBeSmalltalk",
  2787. smalltalk.method({
  2788. selector: "testZorkCommitPathStShouldBeSmalltalk",
  2789. category: 'tests',
  2790. fn: function (){
  2791. var self=this;
  2792. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_("smalltalk/",_st(self["@zorkPackage"])._commitPathSt());
  2793. return self}, self, "testZorkCommitPathStShouldBeSmalltalk", [], smalltalk.PackageWithDefaultCommitPathChangedTest)},
  2794. args: [],
  2795. source: "testZorkCommitPathStShouldBeSmalltalk\x0a\x09self assert: 'smalltalk/' equals: zorkPackage commitPathSt",
  2796. messageSends: ["assert:equals:", "commitPathSt"],
  2797. referencedClasses: []
  2798. }),
  2799. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2800. smalltalk.addMethod(
  2801. "_shouldInheritSelectors",
  2802. smalltalk.method({
  2803. selector: "shouldInheritSelectors",
  2804. category: 'accessing',
  2805. fn: function (){
  2806. var self=this;
  2807. return smalltalk.withContext(function($ctx) { return false;
  2808. }, self, "shouldInheritSelectors", [], smalltalk.PackageWithDefaultCommitPathChangedTest.klass)},
  2809. args: [],
  2810. source: "shouldInheritSelectors\x0a\x09^ false",
  2811. messageSends: [],
  2812. referencedClasses: []
  2813. }),
  2814. smalltalk.PackageWithDefaultCommitPathChangedTest.klass);
  2815. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2816. smalltalk.addMethod(
  2817. "_testAccessing",
  2818. smalltalk.method({
  2819. selector: "testAccessing",
  2820. category: 'tests',
  2821. fn: function (){
  2822. var self=this;
  2823. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(_st((smalltalk.Point || Point))._x_y_((3),(4)))._x(),(3));
  2824. _st(self)._assert_equals_(_st(_st((smalltalk.Point || Point))._x_y_((3),(4)))._y(),(4));
  2825. _st(self)._assert_equals_(_st(_st(_st((smalltalk.Point || Point))._new())._x_((3)))._x(),(3));
  2826. _st(self)._assert_equals_(_st(_st(_st((smalltalk.Point || Point))._new())._y_((4)))._y(),(4));
  2827. return self}, self, "testAccessing", [], smalltalk.PointTest)},
  2828. args: [],
  2829. 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",
  2830. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  2831. referencedClasses: ["Point"]
  2832. }),
  2833. smalltalk.PointTest);
  2834. smalltalk.addMethod(
  2835. "_testArithmetic",
  2836. smalltalk.method({
  2837. selector: "testArithmetic",
  2838. category: 'tests',
  2839. fn: function (){
  2840. var self=this;
  2841. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(_st((3)).__at((4))).__star(_st((3)).__at((4))),_st((smalltalk.Point || Point))._x_y_((9),(16)));
  2842. _st(self)._assert_equals_(_st(_st((3)).__at((4))).__plus(_st((3)).__at((4))),_st((smalltalk.Point || Point))._x_y_((6),(8)));
  2843. _st(self)._assert_equals_(_st(_st((3)).__at((4))).__minus(_st((3)).__at((4))),_st((smalltalk.Point || Point))._x_y_((0),(0)));
  2844. _st(self)._assert_equals_(_st(_st((6)).__at((8))).__slash(_st((3)).__at((4))),_st((smalltalk.Point || Point))._x_y_((2),(2)));
  2845. return self}, self, "testArithmetic", [], smalltalk.PointTest)},
  2846. args: [],
  2847. 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)",
  2848. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  2849. referencedClasses: ["Point"]
  2850. }),
  2851. smalltalk.PointTest);
  2852. smalltalk.addMethod(
  2853. "_testAt",
  2854. smalltalk.method({
  2855. selector: "testAt",
  2856. category: 'tests',
  2857. fn: function (){
  2858. var self=this;
  2859. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((3)).__at((4)),_st((smalltalk.Point || Point))._x_y_((3),(4)));
  2860. return self}, self, "testAt", [], smalltalk.PointTest)},
  2861. args: [],
  2862. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  2863. messageSends: ["assert:equals:", "@", "x:y:"],
  2864. referencedClasses: ["Point"]
  2865. }),
  2866. smalltalk.PointTest);
  2867. smalltalk.addMethod(
  2868. "_testEgality",
  2869. smalltalk.method({
  2870. selector: "testEgality",
  2871. category: 'tests',
  2872. fn: function (){
  2873. var self=this;
  2874. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st((3)).__at((4))).__eq(_st((3)).__at((4))));
  2875. _st(self)._deny_(_st(_st((3)).__at((5))).__eq(_st((3)).__at((6))));
  2876. return self}, self, "testEgality", [], smalltalk.PointTest)},
  2877. args: [],
  2878. source: "testEgality\x0a\x09self assert: 3@4 = (3@4).\x0a\x09self deny: 3@5 = (3@6)",
  2879. messageSends: ["assert:", "=", "@", "deny:"],
  2880. referencedClasses: []
  2881. }),
  2882. smalltalk.PointTest);
  2883. smalltalk.addMethod(
  2884. "_testTranslateBy",
  2885. smalltalk.method({
  2886. selector: "testTranslateBy",
  2887. category: 'tests',
  2888. fn: function (){
  2889. var self=this;
  2890. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st((3)).__at((4)),_st(_st((3)).__at((3)))._translateBy_(_st((0)).__at((1))));
  2891. _st(self)._assert_equals_(_st((3)).__at((2)),_st(_st((3)).__at((3)))._translateBy_(_st((0)).__at(_st((1))._negated())));
  2892. _st(self)._assert_equals_(_st((5)).__at((6)),_st(_st((3)).__at((3)))._translateBy_(_st((2)).__at((3))));
  2893. _st(self)._assert_equals_(_st((0)).__at((3)),_st(_st((3)).__at((3)))._translateBy_(_st(_st((3))._negated()).__at((0))));
  2894. return self}, self, "testTranslateBy", [], smalltalk.PointTest)},
  2895. args: [],
  2896. source: "testTranslateBy\x0a\x09self assert: 3@4 equals: (3@3 translateBy: 0@1).\x0a\x09self assert: 3@2 equals: (3@3 translateBy: 0@1 negated).\x0a\x09self assert: 5@6 equals: (3@3 translateBy: 2@3).\x0a\x09self assert: 0@3 equals: (3@3 translateBy: 3 negated @0).",
  2897. messageSends: ["assert:equals:", "@", "translateBy:", "negated"],
  2898. referencedClasses: []
  2899. }),
  2900. smalltalk.PointTest);
  2901. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2902. smalltalk.addMethod(
  2903. "_textNext",
  2904. smalltalk.method({
  2905. selector: "textNext",
  2906. category: 'tests',
  2907. fn: function (){
  2908. var self=this;
  2909. return smalltalk.withContext(function($ctx) { _st((10000))._timesRepeat_((function(){
  2910. var current;
  2911. var next;
  2912. next=_st(_st((smalltalk.Random || Random))._new())._next();
  2913. next;
  2914. _st(self)._assert_(_st(next).__gt_eq((0)));
  2915. _st(self)._assert_(_st(next).__lt((1)));
  2916. _st(self)._deny_(_st(current).__eq(next));
  2917. return _st(next).__eq(current);
  2918. }));
  2919. return self}, self, "textNext", [], smalltalk.RandomTest)},
  2920. args: [],
  2921. 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]",
  2922. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  2923. referencedClasses: ["Random"]
  2924. }),
  2925. smalltalk.RandomTest);
  2926. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2927. smalltalk.addMethod(
  2928. "_testAddRemove",
  2929. smalltalk.method({
  2930. selector: "testAddRemove",
  2931. category: 'tests',
  2932. fn: function (){
  2933. var self=this;
  2934. return smalltalk.withContext(function($ctx) { var set;
  2935. set=_st((smalltalk.Set || Set))._new();
  2936. _st(self)._assert_(_st(set)._isEmpty());
  2937. _st(set)._add_((3));
  2938. _st(self)._assert_(_st(set)._includes_((3)));
  2939. _st(set)._add_((5));
  2940. _st(self)._assert_(_st(set)._includes_((5)));
  2941. _st(set)._remove_((3));
  2942. _st(self)._deny_(_st(set)._includes_((3)));
  2943. return self}, self, "testAddRemove", [], smalltalk.SetTest)},
  2944. args: [],
  2945. 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)",
  2946. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  2947. referencedClasses: ["Set"]
  2948. }),
  2949. smalltalk.SetTest);
  2950. smalltalk.addMethod(
  2951. "_testAt",
  2952. smalltalk.method({
  2953. selector: "testAt",
  2954. category: 'tests',
  2955. fn: function (){
  2956. var self=this;
  2957. return smalltalk.withContext(function($ctx) { _st(self)._should_raise_((function(){
  2958. return _st(_st((smalltalk.Set || Set))._new())._at_put_((1),(2));
  2959. }),(smalltalk.Error || Error));
  2960. return self}, self, "testAt", [], smalltalk.SetTest)},
  2961. args: [],
  2962. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  2963. messageSends: ["should:raise:", "at:put:", "new"],
  2964. referencedClasses: ["Set", "Error"]
  2965. }),
  2966. smalltalk.SetTest);
  2967. smalltalk.addMethod(
  2968. "_testPrintString",
  2969. smalltalk.method({
  2970. selector: "testPrintString",
  2971. category: 'tests',
  2972. fn: function (){
  2973. var self=this;
  2974. return smalltalk.withContext(function($ctx) { var $1,$2;
  2975. var set;
  2976. set=_st((smalltalk.Set || Set))._new();
  2977. _st(self)._assert_equals_("a Set ()",_st(set)._printString());
  2978. _st(set)._add_((1));
  2979. $1=_st(set)._add_((3));
  2980. _st(self)._assert_equals_("a Set (1 3)",_st(set)._printString());
  2981. _st(set)._add_("foo");
  2982. _st(self)._assert_equals_("a Set (1 3 'foo')",_st(set)._printString());
  2983. _st(set)._remove_((1));
  2984. $2=_st(set)._remove_((3));
  2985. _st(self)._assert_equals_("a Set ('foo')",_st(set)._printString());
  2986. _st(set)._add_((3));
  2987. _st(self)._assert_equals_("a Set ('foo' 3)",_st(set)._printString());
  2988. _st(set)._add_((3));
  2989. _st(self)._assert_equals_("a Set ('foo' 3)",_st(set)._printString());
  2990. return self}, self, "testPrintString", [], smalltalk.SetTest)},
  2991. args: [],
  2992. source: "testPrintString\x0a\x09| set |\x0a\x09set := Set new.\x0a\x09self assert: 'a Set ()' equals: ( set printString ).\x0a\x09set add: 1; add: 3.\x0a\x09self assert: 'a Set (1 3)' equals: ( set printString ).\x0a\x09set add: 'foo'.\x0a\x09self assert: 'a Set (1 3 ''foo'')' equals: ( set printString ).\x0a\x09set remove: 1; remove: 3.\x0a\x09self assert: 'a Set (''foo'')' equals: ( set printString ).\x0a\x09set add: 3.\x0a\x09self assert: 'a Set (''foo'' 3)' equals: ( set printString ).\x0a\x09set add: 3.\x0a\x09self assert: 'a Set (''foo'' 3)' equals: ( set printString ).",
  2993. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:"],
  2994. referencedClasses: ["Set"]
  2995. }),
  2996. smalltalk.SetTest);
  2997. smalltalk.addMethod(
  2998. "_testSize",
  2999. smalltalk.method({
  3000. selector: "testSize",
  3001. category: 'tests',
  3002. fn: function (){
  3003. var self=this;
  3004. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(_st((smalltalk.Set || Set))._new())._size(),(0));
  3005. _st(self)._assert_equals_(_st(_st((smalltalk.Set || Set))._withAll_([(1), (2), (3), (4)]))._size(),(4));
  3006. _st(self)._assert_equals_(_st(_st((smalltalk.Set || Set))._withAll_([(1), (1), (1), (1)]))._size(),(1));
  3007. return self}, self, "testSize", [], smalltalk.SetTest)},
  3008. args: [],
  3009. 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",
  3010. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  3011. referencedClasses: ["Set"]
  3012. }),
  3013. smalltalk.SetTest);
  3014. smalltalk.addMethod(
  3015. "_testUnicity",
  3016. smalltalk.method({
  3017. selector: "testUnicity",
  3018. category: 'tests',
  3019. fn: function (){
  3020. var self=this;
  3021. return smalltalk.withContext(function($ctx) { var set;
  3022. set=_st((smalltalk.Set || Set))._new();
  3023. _st(set)._add_((21));
  3024. _st(set)._add_("hello");
  3025. _st(set)._add_((21));
  3026. _st(self)._assert_(_st(_st(set)._size()).__eq((2)));
  3027. _st(set)._add_("hello");
  3028. _st(self)._assert_(_st(_st(set)._size()).__eq((2)));
  3029. _st(self)._assert_equals_(_st(set)._asArray(),[(21), "hello"]);
  3030. return self}, self, "testUnicity", [], smalltalk.SetTest)},
  3031. args: [],
  3032. 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 = 2.\x0a\x09\x0a\x09set add: 'hello'.\x0a\x09self assert: set size = 2.\x0a\x0a\x09self assert: set asArray equals: #(21 'hello')",
  3033. messageSends: ["new", "add:", "assert:", "=", "size", "assert:equals:", "asArray"],
  3034. referencedClasses: ["Set"]
  3035. }),
  3036. smalltalk.SetTest);
  3037. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  3038. smalltalk.addMethod(
  3039. "_testCopying",
  3040. smalltalk.method({
  3041. selector: "testCopying",
  3042. category: 'tests',
  3043. fn: function (){
  3044. var self=this;
  3045. return smalltalk.withContext(function($ctx) { _st(self)._assert_equals_(_st(nil)._copy(),nil);
  3046. return self}, self, "testCopying", [], smalltalk.UndefinedTest)},
  3047. args: [],
  3048. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  3049. messageSends: ["assert:equals:", "copy"],
  3050. referencedClasses: []
  3051. }),
  3052. smalltalk.UndefinedTest);
  3053. smalltalk.addMethod(
  3054. "_testDeepCopy",
  3055. smalltalk.method({
  3056. selector: "testDeepCopy",
  3057. category: 'tests',
  3058. fn: function (){
  3059. var self=this;
  3060. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(_st(nil)._deepCopy()).__eq(nil));
  3061. return self}, self, "testDeepCopy", [], smalltalk.UndefinedTest)},
  3062. args: [],
  3063. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  3064. messageSends: ["assert:", "=", "deepCopy"],
  3065. referencedClasses: []
  3066. }),
  3067. smalltalk.UndefinedTest);
  3068. smalltalk.addMethod(
  3069. "_testIfNil",
  3070. smalltalk.method({
  3071. selector: "testIfNil",
  3072. category: 'tests',
  3073. fn: function (){
  3074. var self=this;
  3075. return smalltalk.withContext(function($ctx) { var $1,$2,$3;
  3076. if(($receiver = nil) == nil || $receiver == undefined){
  3077. $1=true;
  3078. } else {
  3079. $1=nil;
  3080. };
  3081. _st(self)._assert_equals_($1,true);
  3082. if(($receiver = nil) == nil || $receiver == undefined){
  3083. $2=nil;
  3084. } else {
  3085. $2=true;
  3086. };
  3087. _st(self)._deny_(_st($2).__eq(true));
  3088. if(($receiver = nil) == nil || $receiver == undefined){
  3089. $3=true;
  3090. } else {
  3091. $3=false;
  3092. };
  3093. _st(self)._assert_equals_($3,true);
  3094. _st(self)._deny_(_st(_st(nil)._ifNotNil_ifNil_((function(){
  3095. return true;
  3096. }),(function(){
  3097. return false;
  3098. }))).__eq(true));
  3099. return self}, self, "testIfNil", [], smalltalk.UndefinedTest)},
  3100. args: [],
  3101. 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",
  3102. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  3103. referencedClasses: []
  3104. }),
  3105. smalltalk.UndefinedTest);
  3106. smalltalk.addMethod(
  3107. "_testIsNil",
  3108. smalltalk.method({
  3109. selector: "testIsNil",
  3110. category: 'tests',
  3111. fn: function (){
  3112. var self=this;
  3113. return smalltalk.withContext(function($ctx) { _st(self)._assert_(_st(nil)._isNil());
  3114. _st(self)._deny_(_st(nil)._notNil());
  3115. return self}, self, "testIsNil", [], smalltalk.UndefinedTest)},
  3116. args: [],
  3117. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  3118. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  3119. referencedClasses: []
  3120. }),
  3121. smalltalk.UndefinedTest);