Kernel-Tests.js 125 KB

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