Kernel-Tests.js 124 KB

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