Kernel-Tests.js 126 KB

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