Kernel-Tests.js 130 KB

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