1
0

Kernel-Tests.js 130 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224
  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 object;
  1926. $1 = smalltalk.send(self, "_jsObject", []);
  1927. smalltalk.send($1, "_d_", ["test"]);
  1928. $2 = smalltalk.send($1, "_yourself", []);
  1929. object = $2;
  1930. smalltalk.send(self, "_assert_equals_", [smalltalk.send(object, "_d", []), "test"]);
  1931. return self;
  1932. },
  1933. args: [],
  1934. source: "testYourself\x0a\x09| object |\x0a\x09object := self jsObject\x0a\x09\x09d: 'test';\x0a\x09\x09yourself.\x0a\x0a\x09self assert: object d equals: 'test'",
  1935. messageSends: ["d:", "jsObject", "yourself", "assert:equals:", "d"],
  1936. referencedClasses: []
  1937. }),
  1938. smalltalk.JSObjectProxyTest);
  1939. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1940. smalltalk.addMethod(
  1941. "_testAbs",
  1942. smalltalk.method({
  1943. selector: "testAbs",
  1944. category: 'tests',
  1945. fn: function () {
  1946. var self = this;
  1947. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(4, "_abs", []), "__eq", [4])]);
  1948. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(-4, "_abs", []), "__eq", [4])]);
  1949. return self;
  1950. },
  1951. args: [],
  1952. source: "testAbs\x0a\x09self assert: 4 abs = 4.\x0a\x09self assert: -4 abs = 4",
  1953. messageSends: ["assert:", "=", "abs"],
  1954. referencedClasses: []
  1955. }),
  1956. smalltalk.NumberTest);
  1957. smalltalk.addMethod(
  1958. "_testArithmetic",
  1959. smalltalk.method({
  1960. selector: "testArithmetic",
  1961. category: 'tests',
  1962. fn: function () {
  1963. var self = this;
  1964. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1.5, "__plus", [1]), "__eq", [2.5])]);
  1965. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(2, "__minus", [1]), "__eq", [1])]);
  1966. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(-2, "__minus", [1]), "__eq", [-3])]);
  1967. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(12, "__slash", [2]), "__eq", [6])]);
  1968. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3, "__star", [4]), "__eq", [12])]);
  1969. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(1, "__plus", [2]), "__star", [3]), "__eq", [9])]);
  1970. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1, "__plus", [smalltalk.send(2, "__star", [3])]), "__eq", [7])]);
  1971. return self;
  1972. },
  1973. args: [],
  1974. 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",
  1975. messageSends: ["assert:", "=", "+", "-", "/", "*"],
  1976. referencedClasses: []
  1977. }),
  1978. smalltalk.NumberTest);
  1979. smalltalk.addMethod(
  1980. "_testComparison",
  1981. smalltalk.method({
  1982. selector: "testComparison",
  1983. category: 'tests',
  1984. fn: function () {
  1985. var self = this;
  1986. smalltalk.send(self, "_assert_", [smalltalk.send(3, "__gt", [2])]);
  1987. smalltalk.send(self, "_assert_", [smalltalk.send(2, "__lt", [3])]);
  1988. smalltalk.send(self, "_deny_", [smalltalk.send(3, "__lt", [2])]);
  1989. smalltalk.send(self, "_deny_", [smalltalk.send(2, "__gt", [3])]);
  1990. smalltalk.send(self, "_assert_", [smalltalk.send(3, "__gt_eq", [3])]);
  1991. smalltalk.send(self, "_assert_", [smalltalk.send(3.1, "__gt_eq", [3])]);
  1992. smalltalk.send(self, "_assert_", [smalltalk.send(3, "__lt_eq", [3])]);
  1993. smalltalk.send(self, "_assert_", [smalltalk.send(3, "__lt_eq", [3.1])]);
  1994. return self;
  1995. },
  1996. args: [],
  1997. 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",
  1998. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  1999. referencedClasses: []
  2000. }),
  2001. smalltalk.NumberTest);
  2002. smalltalk.addMethod(
  2003. "_testCopying",
  2004. smalltalk.method({
  2005. selector: "testCopying",
  2006. category: 'tests',
  2007. fn: function () {
  2008. var self = this;
  2009. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1, "_copy", []), "__eq_eq", [1])]);
  2010. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1, "_deepCopy", []), "__eq_eq", [1])]);
  2011. return self;
  2012. },
  2013. args: [],
  2014. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  2015. messageSends: ["assert:", "==", "copy", "deepCopy"],
  2016. referencedClasses: []
  2017. }),
  2018. smalltalk.NumberTest);
  2019. smalltalk.addMethod(
  2020. "_testEquality",
  2021. smalltalk.method({
  2022. selector: "testEquality",
  2023. category: 'tests',
  2024. fn: function () {
  2025. var self = this;
  2026. smalltalk.send(self, "_assert_", [smalltalk.send(1, "__eq", [1])]);
  2027. smalltalk.send(self, "_assert_", [smalltalk.send(0, "__eq", [0])]);
  2028. smalltalk.send(self, "_deny_", [smalltalk.send(1, "__eq", [0])]);
  2029. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1, "_yourself", []), "__eq", [1])]);
  2030. smalltalk.send(self, "_assert_", [smalltalk.send(1, "__eq", [smalltalk.send(1, "_yourself", [])])]);
  2031. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1, "_yourself", []), "__eq", [smalltalk.send(1, "_yourself", [])])]);
  2032. smalltalk.send(self, "_deny_", [smalltalk.send(0, "__eq", [false])]);
  2033. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [0])]);
  2034. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [0])]);
  2035. smalltalk.send(self, "_deny_", [smalltalk.send(0, "__eq", [""])]);
  2036. return self;
  2037. },
  2038. args: [],
  2039. 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 = ''",
  2040. messageSends: ["assert:", "=", "deny:", "yourself"],
  2041. referencedClasses: []
  2042. }),
  2043. smalltalk.NumberTest);
  2044. smalltalk.addMethod(
  2045. "_testIdentity",
  2046. smalltalk.method({
  2047. selector: "testIdentity",
  2048. category: 'tests',
  2049. fn: function () {
  2050. var self = this;
  2051. smalltalk.send(self, "_assert_", [smalltalk.send(1, "__eq_eq", [1])]);
  2052. smalltalk.send(self, "_assert_", [smalltalk.send(0, "__eq_eq", [0])]);
  2053. smalltalk.send(self, "_deny_", [smalltalk.send(1, "__eq_eq", [0])]);
  2054. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1, "_yourself", []), "__eq_eq", [1])]);
  2055. smalltalk.send(self, "_assert_", [smalltalk.send(1, "__eq_eq", [smalltalk.send(1, "_yourself", [])])]);
  2056. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(1, "_yourself", []), "__eq_eq", [smalltalk.send(1, "_yourself", [])])]);
  2057. smalltalk.send(self, "_deny_", [smalltalk.send(1, "__eq_eq", [2])]);
  2058. return self;
  2059. },
  2060. args: [],
  2061. 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",
  2062. messageSends: ["assert:", "==", "deny:", "yourself"],
  2063. referencedClasses: []
  2064. }),
  2065. smalltalk.NumberTest);
  2066. smalltalk.addMethod(
  2067. "_testMinMax",
  2068. smalltalk.method({
  2069. selector: "testMinMax",
  2070. category: 'tests',
  2071. fn: function () {
  2072. var self = this;
  2073. smalltalk.send(self, "_assert_equals_", [smalltalk.send(2, "_max_", [5]), 5]);
  2074. smalltalk.send(self, "_assert_equals_", [smalltalk.send(2, "_min_", [5]), 2]);
  2075. return self;
  2076. },
  2077. args: [],
  2078. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  2079. messageSends: ["assert:equals:", "max:", "min:"],
  2080. referencedClasses: []
  2081. }),
  2082. smalltalk.NumberTest);
  2083. smalltalk.addMethod(
  2084. "_testNegated",
  2085. smalltalk.method({
  2086. selector: "testNegated",
  2087. category: 'tests',
  2088. fn: function () {
  2089. var self = this;
  2090. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3, "_negated", []), "__eq", [-3])]);
  2091. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(-3, "_negated", []), "__eq", [3])]);
  2092. return self;
  2093. },
  2094. args: [],
  2095. source: "testNegated\x0a\x09self assert: 3 negated = -3.\x0a\x09self assert: -3 negated = 3",
  2096. messageSends: ["assert:", "=", "negated"],
  2097. referencedClasses: []
  2098. }),
  2099. smalltalk.NumberTest);
  2100. smalltalk.addMethod(
  2101. "_testPrintShowingDecimalPlaces",
  2102. smalltalk.method({
  2103. selector: "testPrintShowingDecimalPlaces",
  2104. category: 'tests',
  2105. fn: function () {
  2106. var self = this;
  2107. smalltalk.send(self, "_assert_equals_", ["23.00", smalltalk.send(23, "_printShowingDecimalPlaces_", [2])]);
  2108. smalltalk.send(self, "_assert_equals_", ["23.57", smalltalk.send(23.5698, "_printShowingDecimalPlaces_", [2])]);
  2109. smalltalk.send(self, "_assert_equals_", ["-234.56700", smalltalk.send(smalltalk.send(234.567, "_negated", []), "_printShowingDecimalPlaces_", [5])]);
  2110. smalltalk.send(self, "_assert_equals_", ["23", smalltalk.send(23.4567, "_printShowingDecimalPlaces_", [0])]);
  2111. smalltalk.send(self, "_assert_equals_", ["24", smalltalk.send(23.5567, "_printShowingDecimalPlaces_", [0])]);
  2112. smalltalk.send(self, "_assert_equals_", ["-23", smalltalk.send(smalltalk.send(23.4567, "_negated", []), "_printShowingDecimalPlaces_", [0])]);
  2113. smalltalk.send(self, "_assert_equals_", ["-24", smalltalk.send(smalltalk.send(23.5567, "_negated", []), "_printShowingDecimalPlaces_", [0])]);
  2114. smalltalk.send(self, "_assert_equals_", ["100000000.0", smalltalk.send(100000000, "_printShowingDecimalPlaces_", [1])]);
  2115. smalltalk.send(self, "_assert_equals_", ["0.98000", smalltalk.send(0.98, "_printShowingDecimalPlaces_", [5])]);
  2116. smalltalk.send(self, "_assert_equals_", ["-0.98", smalltalk.send(smalltalk.send(0.98, "_negated", []), "_printShowingDecimalPlaces_", [2])]);
  2117. smalltalk.send(self, "_assert_equals_", ["2.57", smalltalk.send(2.567, "_printShowingDecimalPlaces_", [2])]);
  2118. smalltalk.send(self, "_assert_equals_", ["-2.57", smalltalk.send(-2.567, "_printShowingDecimalPlaces_", [2])]);
  2119. smalltalk.send(self, "_assert_equals_", ["0.00", smalltalk.send(0, "_printShowingDecimalPlaces_", [2])]);
  2120. return self;
  2121. },
  2122. args: [],
  2123. 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).",
  2124. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  2125. referencedClasses: []
  2126. }),
  2127. smalltalk.NumberTest);
  2128. smalltalk.addMethod(
  2129. "_testRounded",
  2130. smalltalk.method({
  2131. selector: "testRounded",
  2132. category: 'tests',
  2133. fn: function () {
  2134. var self = this;
  2135. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3, "_rounded", []), "__eq", [3])]);
  2136. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3.212, "_rounded", []), "__eq", [3])]);
  2137. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3.51, "_rounded", []), "__eq", [4])]);
  2138. return self;
  2139. },
  2140. args: [],
  2141. source: "testRounded\x0a\x09\x0a\x09self assert: 3 rounded = 3.\x0a\x09self assert: 3.212 rounded = 3.\x0a\x09self assert: 3.51 rounded = 4",
  2142. messageSends: ["assert:", "=", "rounded"],
  2143. referencedClasses: []
  2144. }),
  2145. smalltalk.NumberTest);
  2146. smalltalk.addMethod(
  2147. "_testSqrt",
  2148. smalltalk.method({
  2149. selector: "testSqrt",
  2150. category: 'tests',
  2151. fn: function () {
  2152. var self = this;
  2153. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(4, "_sqrt", []), "__eq", [2])]);
  2154. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(16, "_sqrt", []), "__eq", [4])]);
  2155. return self;
  2156. },
  2157. args: [],
  2158. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt = 2.\x0a\x09self assert: 16 sqrt = 4",
  2159. messageSends: ["assert:", "=", "sqrt"],
  2160. referencedClasses: []
  2161. }),
  2162. smalltalk.NumberTest);
  2163. smalltalk.addMethod(
  2164. "_testSquared",
  2165. smalltalk.method({
  2166. selector: "testSquared",
  2167. category: 'tests',
  2168. fn: function () {
  2169. var self = this;
  2170. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(4, "_squared", []), "__eq", [16])]);
  2171. return self;
  2172. },
  2173. args: [],
  2174. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared = 16",
  2175. messageSends: ["assert:", "=", "squared"],
  2176. referencedClasses: []
  2177. }),
  2178. smalltalk.NumberTest);
  2179. smalltalk.addMethod(
  2180. "_testTimesRepeat",
  2181. smalltalk.method({
  2182. selector: "testTimesRepeat",
  2183. category: 'tests',
  2184. fn: function () {
  2185. var self = this;
  2186. var i;
  2187. i = 0;
  2188. smalltalk.send(0, "_timesRepeat_", [function () {i = smalltalk.send(i, "__plus", [1]);return i;}]);
  2189. smalltalk.send(self, "_assert_equals_", [i, 0]);
  2190. smalltalk.send(5, "_timesRepeat_", [function () {i = smalltalk.send(i, "__plus", [1]);return i;}]);
  2191. smalltalk.send(self, "_assert_equals_", [i, 5]);
  2192. return self;
  2193. },
  2194. args: [],
  2195. 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",
  2196. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  2197. referencedClasses: []
  2198. }),
  2199. smalltalk.NumberTest);
  2200. smalltalk.addMethod(
  2201. "_testTo",
  2202. smalltalk.method({
  2203. selector: "testTo",
  2204. category: 'tests',
  2205. fn: function () {
  2206. var self = this;
  2207. smalltalk.send(self, "_assert_equals_", [smalltalk.send(1, "_to_", [5]), [1, 2, 3, 4, 5]]);
  2208. return self;
  2209. },
  2210. args: [],
  2211. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  2212. messageSends: ["assert:equals:", "to:"],
  2213. referencedClasses: []
  2214. }),
  2215. smalltalk.NumberTest);
  2216. smalltalk.addMethod(
  2217. "_testToBy",
  2218. smalltalk.method({
  2219. selector: "testToBy",
  2220. category: 'tests',
  2221. fn: function () {
  2222. var self = this;
  2223. smalltalk.send(self, "_assert_equals_", [smalltalk.send(0, "_to_by_", [6, 2]), [0, 2, 4, 6]]);
  2224. smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(1, "_to_by_", [4, 0]);}, smalltalk.Error || Error]);
  2225. return self;
  2226. },
  2227. args: [],
  2228. 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",
  2229. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  2230. referencedClasses: ["Error"]
  2231. }),
  2232. smalltalk.NumberTest);
  2233. smalltalk.addMethod(
  2234. "_testTruncated",
  2235. smalltalk.method({
  2236. selector: "testTruncated",
  2237. category: 'tests',
  2238. fn: function () {
  2239. var self = this;
  2240. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3, "_truncated", []), "__eq", [3])]);
  2241. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3.212, "_truncated", []), "__eq", [3])]);
  2242. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3.51, "_truncated", []), "__eq", [3])]);
  2243. return self;
  2244. },
  2245. args: [],
  2246. source: "testTruncated\x0a\x09\x0a\x09self assert: 3 truncated = 3.\x0a\x09self assert: 3.212 truncated = 3.\x0a\x09self assert: 3.51 truncated = 3",
  2247. messageSends: ["assert:", "=", "truncated"],
  2248. referencedClasses: []
  2249. }),
  2250. smalltalk.NumberTest);
  2251. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  2252. smalltalk.addMethod(
  2253. "_foo",
  2254. smalltalk.method({
  2255. selector: "foo",
  2256. category: 'not yet classified',
  2257. fn: function () {
  2258. var self = this;
  2259. return self['@foo'];
  2260. },
  2261. args: [],
  2262. source: "foo\x0a\x09^foo",
  2263. messageSends: [],
  2264. referencedClasses: []
  2265. }),
  2266. smalltalk.ObjectMock);
  2267. smalltalk.addMethod(
  2268. "_foo_",
  2269. smalltalk.method({
  2270. selector: "foo:",
  2271. category: 'not yet classified',
  2272. fn: function (anObject) {
  2273. var self = this;
  2274. self['@foo'] = anObject;
  2275. return self;
  2276. },
  2277. args: ["anObject"],
  2278. source: "foo: anObject\x0a\x09foo := anObject",
  2279. messageSends: [],
  2280. referencedClasses: []
  2281. }),
  2282. smalltalk.ObjectMock);
  2283. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2284. smalltalk.addMethod(
  2285. "_testBasicAccess",
  2286. smalltalk.method({
  2287. selector: "testBasicAccess",
  2288. category: 'tests',
  2289. fn: function () {
  2290. var self = this;
  2291. var o;
  2292. o = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2293. smalltalk.send(o, "_basicAt_put_", ["a", 1]);
  2294. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["a"]), 1]);
  2295. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["b"]), nil]);
  2296. return self;
  2297. },
  2298. args: [],
  2299. 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",
  2300. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  2301. referencedClasses: ["Object"]
  2302. }),
  2303. smalltalk.ObjectTest);
  2304. smalltalk.addMethod(
  2305. "_testBasicPerform",
  2306. smalltalk.method({
  2307. selector: "testBasicPerform",
  2308. category: 'tests',
  2309. fn: function () {
  2310. var self = this;
  2311. var o;
  2312. o = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2313. smalltalk.send(o, "_basicAt_put_", ["func", function () {return "hello";}]);
  2314. smalltalk.send(o, "_basicAt_put_", ["func2", function (a) {return smalltalk.send(a, "__plus", [1]);}]);
  2315. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_", ["func"]), "hello"]);
  2316. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_withArguments_", ["func2", [3]]), 4]);
  2317. return self;
  2318. },
  2319. args: [],
  2320. 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",
  2321. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  2322. referencedClasses: ["Object"]
  2323. }),
  2324. smalltalk.ObjectTest);
  2325. smalltalk.addMethod(
  2326. "_testDNU",
  2327. smalltalk.method({
  2328. selector: "testDNU",
  2329. category: 'tests',
  2330. fn: function () {
  2331. var self = this;
  2332. smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(smalltalk.send(smalltalk.Object || Object, "_new", []), "_foo", []);}, smalltalk.MessageNotUnderstood || MessageNotUnderstood]);
  2333. return self;
  2334. },
  2335. args: [],
  2336. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  2337. messageSends: ["should:raise:", "foo", "new"],
  2338. referencedClasses: ["Object", "MessageNotUnderstood"]
  2339. }),
  2340. smalltalk.ObjectTest);
  2341. smalltalk.addMethod(
  2342. "_testEquality",
  2343. smalltalk.method({
  2344. selector: "testEquality",
  2345. category: 'tests',
  2346. fn: function () {
  2347. var self = this;
  2348. var o;
  2349. o = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2350. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq", [smalltalk.send(smalltalk.Object || Object, "_new", [])])]);
  2351. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [o])]);
  2352. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq", [o])]);
  2353. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [smalltalk.send(o, "_yourself", [])])]);
  2354. return self;
  2355. },
  2356. args: [],
  2357. 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",
  2358. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  2359. referencedClasses: ["Object"]
  2360. }),
  2361. smalltalk.ObjectTest);
  2362. smalltalk.addMethod(
  2363. "_testHalt",
  2364. smalltalk.method({
  2365. selector: "testHalt",
  2366. category: 'tests',
  2367. fn: function () {
  2368. var self = this;
  2369. smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(smalltalk.send(smalltalk.Object || Object, "_new", []), "_halt", []);}, smalltalk.Error || Error]);
  2370. return self;
  2371. },
  2372. args: [],
  2373. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  2374. messageSends: ["should:raise:", "halt", "new"],
  2375. referencedClasses: ["Object", "Error"]
  2376. }),
  2377. smalltalk.ObjectTest);
  2378. smalltalk.addMethod(
  2379. "_testIdentity",
  2380. smalltalk.method({
  2381. selector: "testIdentity",
  2382. category: 'tests',
  2383. fn: function () {
  2384. var self = this;
  2385. var o;
  2386. o = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2387. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq_eq", [smalltalk.send(smalltalk.Object || Object, "_new", [])])]);
  2388. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq_eq", [o])]);
  2389. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq_eq", [o])]);
  2390. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq_eq", [smalltalk.send(o, "_yourself", [])])]);
  2391. return self;
  2392. },
  2393. args: [],
  2394. 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",
  2395. messageSends: ["new", "deny:", "==", "assert:", "yourself"],
  2396. referencedClasses: ["Object"]
  2397. }),
  2398. smalltalk.ObjectTest);
  2399. smalltalk.addMethod(
  2400. "_testIfNil",
  2401. smalltalk.method({
  2402. selector: "testIfNil",
  2403. category: 'tests',
  2404. fn: function () {
  2405. var self = this;
  2406. var $2, $1, $4, $3, $6, $5;
  2407. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(smalltalk.Object || Object, "_new", []), "_isNil", [])]);
  2408. $2 = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2409. if (($receiver = $2) == nil || $receiver == undefined) {
  2410. $1 = true;
  2411. } else {
  2412. $1 = $2;
  2413. }
  2414. smalltalk.send(self, "_deny_", [smalltalk.send($1, "__eq", [true])]);
  2415. $4 = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2416. if (($receiver = $4) == nil || $receiver == undefined) {
  2417. $3 = $4;
  2418. } else {
  2419. $3 = true;
  2420. }
  2421. smalltalk.send(self, "_assert_", [smalltalk.send($3, "__eq", [true])]);
  2422. $6 = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2423. if (($receiver = $6) == nil || $receiver == undefined) {
  2424. $5 = false;
  2425. } else {
  2426. $5 = true;
  2427. }
  2428. smalltalk.send(self, "_assert_", [smalltalk.send($5, "__eq", [true])]);
  2429. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Object || Object, "_new", []), "_ifNotNil_ifNil_", [function () {return true;}, function () {return false;}]), "__eq", [true])]);
  2430. return self;
  2431. },
  2432. args: [],
  2433. 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",
  2434. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  2435. referencedClasses: ["Object"]
  2436. }),
  2437. smalltalk.ObjectTest);
  2438. smalltalk.addMethod(
  2439. "_testInstVars",
  2440. smalltalk.method({
  2441. selector: "testInstVars",
  2442. category: 'tests',
  2443. fn: function () {
  2444. var self = this;
  2445. var o;
  2446. o = smalltalk.send(smalltalk.ObjectMock || ObjectMock, "_new", []);
  2447. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), nil]);
  2448. smalltalk.send(o, "_instVarAt_put_", [smalltalk.symbolFor("foo"), 1]);
  2449. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), 1]);
  2450. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", ["foo"]), 1]);
  2451. return self;
  2452. },
  2453. args: [],
  2454. 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",
  2455. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  2456. referencedClasses: ["ObjectMock"]
  2457. }),
  2458. smalltalk.ObjectTest);
  2459. smalltalk.addMethod(
  2460. "_testNilUndefined",
  2461. smalltalk.method({
  2462. selector: "testNilUndefined",
  2463. category: 'tests',
  2464. fn: function () {
  2465. var self = this;
  2466. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "__eq", [undefined])]);
  2467. return self;
  2468. },
  2469. args: [],
  2470. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09self assert: nil = undefined",
  2471. messageSends: ["assert:", "="],
  2472. referencedClasses: []
  2473. }),
  2474. smalltalk.ObjectTest);
  2475. smalltalk.addMethod(
  2476. "_testYourself",
  2477. smalltalk.method({
  2478. selector: "testYourself",
  2479. category: 'tests',
  2480. fn: function () {
  2481. var self = this;
  2482. var o;
  2483. o = smalltalk.send(smalltalk.ObjectMock || ObjectMock, "_new", []);
  2484. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq_eq", [o])]);
  2485. return self;
  2486. },
  2487. args: [],
  2488. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  2489. messageSends: ["new", "assert:", "==", "yourself"],
  2490. referencedClasses: ["ObjectMock"]
  2491. }),
  2492. smalltalk.ObjectTest);
  2493. smalltalk.addMethod(
  2494. "_testidentityHash",
  2495. smalltalk.method({
  2496. selector: "testidentityHash",
  2497. category: 'tests',
  2498. fn: function () {
  2499. var self = this;
  2500. var o1;
  2501. var o2;
  2502. o1 = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2503. o2 = smalltalk.send(smalltalk.Object || Object, "_new", []);
  2504. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o1, "_identityHash", [])])]);
  2505. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o2, "_identityHash", [])])]);
  2506. return self;
  2507. },
  2508. args: [],
  2509. 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",
  2510. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  2511. referencedClasses: ["Object"]
  2512. }),
  2513. smalltalk.ObjectTest);
  2514. smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
  2515. smalltalk.addMethod(
  2516. "_setUp",
  2517. smalltalk.method({
  2518. selector: "setUp",
  2519. category: 'running',
  2520. fn: function () {
  2521. var self = this;
  2522. var $1, $2;
  2523. self['@backUpCommitPathJs'] = smalltalk.send(smalltalk.Package || Package, "_defaultCommitPathJs", []);
  2524. self['@backUpCommitPathSt'] = smalltalk.send(smalltalk.Package || Package, "_defaultCommitPathSt", []);
  2525. smalltalk.send(smalltalk.Package || Package, "_resetCommitPaths", []);
  2526. self['@zorkPackage'] = smalltalk.send(smalltalk.send(smalltalk.Package || Package, "_new", []), "_name_", ["Zork"]);
  2527. $1 = smalltalk.send(smalltalk.Package || Package, "_new", []);
  2528. smalltalk.send($1, "_name_", ["Grul"]);
  2529. smalltalk.send($1, "_commitPathJs_", ["server/grul/js"]);
  2530. smalltalk.send($1, "_commitPathSt_", ["grul/st"]);
  2531. $2 = smalltalk.send($1, "_yourself", []);
  2532. self['@grulPackage'] = $2;
  2533. return self;
  2534. },
  2535. args: [],
  2536. 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",
  2537. messageSends: ["defaultCommitPathJs", "defaultCommitPathSt", "resetCommitPaths", "name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
  2538. referencedClasses: ["Package"]
  2539. }),
  2540. smalltalk.PackageTest);
  2541. smalltalk.addMethod(
  2542. "_tearDown",
  2543. smalltalk.method({
  2544. selector: "tearDown",
  2545. category: 'running',
  2546. fn: function () {
  2547. var self = this;
  2548. var $1;
  2549. smalltalk.send(smalltalk.Package || Package, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);
  2550. $1 = smalltalk.send(smalltalk.Package || Package, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);
  2551. return self;
  2552. },
  2553. args: [],
  2554. source: "tearDown\x0a\x09 Package \x0a\x09\x09defaultCommitPathJs: backUpCommitPathJs;\x0a\x09\x09defaultCommitPathSt: backUpCommitPathSt",
  2555. messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
  2556. referencedClasses: ["Package"]
  2557. }),
  2558. smalltalk.PackageTest);
  2559. smalltalk.addMethod(
  2560. "_testGrulCommitPathJsShouldBeServerGrulJs",
  2561. smalltalk.method({
  2562. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  2563. category: 'tests',
  2564. fn: function () {
  2565. var self = this;
  2566. smalltalk.send(self, "_assert_equals_", ["server/grul/js", smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  2567. return self;
  2568. },
  2569. args: [],
  2570. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  2571. messageSends: ["assert:equals:", "commitPathJs"],
  2572. referencedClasses: []
  2573. }),
  2574. smalltalk.PackageTest);
  2575. smalltalk.addMethod(
  2576. "_testGrulCommitPathStShouldBeGrulSt",
  2577. smalltalk.method({
  2578. selector: "testGrulCommitPathStShouldBeGrulSt",
  2579. category: 'tests',
  2580. fn: function () {
  2581. var self = this;
  2582. smalltalk.send(self, "_assert_equals_", ["grul/st", smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  2583. return self;
  2584. },
  2585. args: [],
  2586. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  2587. messageSends: ["assert:equals:", "commitPathSt"],
  2588. referencedClasses: []
  2589. }),
  2590. smalltalk.PackageTest);
  2591. smalltalk.addMethod(
  2592. "_testZorkCommitPathJsShouldBeJs",
  2593. smalltalk.method({
  2594. selector: "testZorkCommitPathJsShouldBeJs",
  2595. category: 'tests',
  2596. fn: function () {
  2597. var self = this;
  2598. smalltalk.send(self, "_assert_equals_", ["js", smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  2599. return self;
  2600. },
  2601. args: [],
  2602. source: "testZorkCommitPathJsShouldBeJs\x0a\x09self assert: 'js' equals: zorkPackage commitPathJs",
  2603. messageSends: ["assert:equals:", "commitPathJs"],
  2604. referencedClasses: []
  2605. }),
  2606. smalltalk.PackageTest);
  2607. smalltalk.addMethod(
  2608. "_testZorkCommitPathStShouldBeSt",
  2609. smalltalk.method({
  2610. selector: "testZorkCommitPathStShouldBeSt",
  2611. category: 'tests',
  2612. fn: function () {
  2613. var self = this;
  2614. smalltalk.send(self, "_assert_equals_", ["st", smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  2615. return self;
  2616. },
  2617. args: [],
  2618. source: "testZorkCommitPathStShouldBeSt\x0a\x09self assert: 'st' equals: zorkPackage commitPathSt",
  2619. messageSends: ["assert:equals:", "commitPathSt"],
  2620. referencedClasses: []
  2621. }),
  2622. smalltalk.PackageTest);
  2623. smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
  2624. smalltalk.addMethod(
  2625. "_setUp",
  2626. smalltalk.method({
  2627. selector: "setUp",
  2628. category: 'running',
  2629. fn: function () {
  2630. var self = this;
  2631. var $1;
  2632. smalltalk.send(self, "_setUp", [], smalltalk.PackageTest);
  2633. smalltalk.send(smalltalk.Package || Package, "_defaultCommitPathJs_", ["javascripts/"]);
  2634. $1 = smalltalk.send(smalltalk.Package || Package, "_defaultCommitPathSt_", ["smalltalk/"]);
  2635. return self;
  2636. },
  2637. args: [],
  2638. source: "setUp\x0a\x09super setUp.\x0a\x0a\x09Package\x0a\x09\x09defaultCommitPathJs: 'javascripts/';\x0a\x09\x09defaultCommitPathSt: 'smalltalk/'.",
  2639. messageSends: ["setUp", "defaultCommitPathJs:", "defaultCommitPathSt:"],
  2640. referencedClasses: ["Package"]
  2641. }),
  2642. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2643. smalltalk.addMethod(
  2644. "_testGrulCommitPathJsShouldBeServerGrulJs",
  2645. smalltalk.method({
  2646. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  2647. category: 'tests',
  2648. fn: function () {
  2649. var self = this;
  2650. smalltalk.send(self, "_assert_equals_", ["server/grul/js", smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  2651. return self;
  2652. },
  2653. args: [],
  2654. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  2655. messageSends: ["assert:equals:", "commitPathJs"],
  2656. referencedClasses: []
  2657. }),
  2658. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2659. smalltalk.addMethod(
  2660. "_testGrulCommitPathStShouldBeGrulSt",
  2661. smalltalk.method({
  2662. selector: "testGrulCommitPathStShouldBeGrulSt",
  2663. category: 'tests',
  2664. fn: function () {
  2665. var self = this;
  2666. smalltalk.send(self, "_assert_equals_", ["grul/st", smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  2667. return self;
  2668. },
  2669. args: [],
  2670. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  2671. messageSends: ["assert:equals:", "commitPathSt"],
  2672. referencedClasses: []
  2673. }),
  2674. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2675. smalltalk.addMethod(
  2676. "_testZorkCommitPathJsShouldBeJavascript",
  2677. smalltalk.method({
  2678. selector: "testZorkCommitPathJsShouldBeJavascript",
  2679. category: 'tests',
  2680. fn: function () {
  2681. var self = this;
  2682. smalltalk.send(self, "_assert_equals_", ["javascripts/", smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  2683. return self;
  2684. },
  2685. args: [],
  2686. source: "testZorkCommitPathJsShouldBeJavascript\x0a\x09self assert: 'javascripts/' equals: zorkPackage commitPathJs",
  2687. messageSends: ["assert:equals:", "commitPathJs"],
  2688. referencedClasses: []
  2689. }),
  2690. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2691. smalltalk.addMethod(
  2692. "_testZorkCommitPathStShouldBeSmalltalk",
  2693. smalltalk.method({
  2694. selector: "testZorkCommitPathStShouldBeSmalltalk",
  2695. category: 'tests',
  2696. fn: function () {
  2697. var self = this;
  2698. smalltalk.send(self, "_assert_equals_", ["smalltalk/", smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  2699. return self;
  2700. },
  2701. args: [],
  2702. source: "testZorkCommitPathStShouldBeSmalltalk\x0a\x09self assert: 'smalltalk/' equals: zorkPackage commitPathSt",
  2703. messageSends: ["assert:equals:", "commitPathSt"],
  2704. referencedClasses: []
  2705. }),
  2706. smalltalk.PackageWithDefaultCommitPathChangedTest);
  2707. smalltalk.addMethod(
  2708. "_shouldInheritSelectors",
  2709. smalltalk.method({
  2710. selector: "shouldInheritSelectors",
  2711. category: 'accessing',
  2712. fn: function () {
  2713. var self = this;
  2714. return false;
  2715. },
  2716. args: [],
  2717. source: "shouldInheritSelectors\x0a\x09^ false",
  2718. messageSends: [],
  2719. referencedClasses: []
  2720. }),
  2721. smalltalk.PackageWithDefaultCommitPathChangedTest.klass);
  2722. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2723. smalltalk.addMethod(
  2724. "_testAccessing",
  2725. smalltalk.method({
  2726. selector: "testAccessing",
  2727. category: 'tests',
  2728. fn: function () {
  2729. var self = this;
  2730. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.Point || Point, "_x_y_", [3, 4]), "_x", []), 3]);
  2731. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.Point || Point, "_x_y_", [3, 4]), "_y", []), 4]);
  2732. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Point || Point, "_new", []), "_x_", [3]), "_x", []), 3]);
  2733. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Point || Point, "_new", []), "_y_", [4]), "_y", []), 4]);
  2734. return self;
  2735. },
  2736. args: [],
  2737. 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",
  2738. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  2739. referencedClasses: ["Point"]
  2740. }),
  2741. smalltalk.PointTest);
  2742. smalltalk.addMethod(
  2743. "_testArithmetic",
  2744. smalltalk.method({
  2745. selector: "testArithmetic",
  2746. category: 'tests',
  2747. fn: function () {
  2748. var self = this;
  2749. 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])]);
  2750. 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])]);
  2751. 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])]);
  2752. 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])]);
  2753. return self;
  2754. },
  2755. args: [],
  2756. 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)",
  2757. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  2758. referencedClasses: ["Point"]
  2759. }),
  2760. smalltalk.PointTest);
  2761. smalltalk.addMethod(
  2762. "_testAt",
  2763. smalltalk.method({
  2764. selector: "testAt",
  2765. category: 'tests',
  2766. fn: function () {
  2767. var self = this;
  2768. smalltalk.send(self, "_assert_equals_", [smalltalk.send(3, "__at", [4]), smalltalk.send(smalltalk.Point || Point, "_x_y_", [3, 4])]);
  2769. return self;
  2770. },
  2771. args: [],
  2772. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  2773. messageSends: ["assert:equals:", "@", "x:y:"],
  2774. referencedClasses: ["Point"]
  2775. }),
  2776. smalltalk.PointTest);
  2777. smalltalk.addMethod(
  2778. "_testEgality",
  2779. smalltalk.method({
  2780. selector: "testEgality",
  2781. category: 'tests',
  2782. fn: function () {
  2783. var self = this;
  2784. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(3, "__at", [4]), "__eq", [smalltalk.send(3, "__at", [4])])]);
  2785. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(3, "__at", [5]), "__eq", [smalltalk.send(3, "__at", [6])])]);
  2786. return self;
  2787. },
  2788. args: [],
  2789. source: "testEgality\x0a\x09self assert: 3@4 = (3@4).\x0a\x09self deny: 3@5 = (3@6)",
  2790. messageSends: ["assert:", "=", "@", "deny:"],
  2791. referencedClasses: []
  2792. }),
  2793. smalltalk.PointTest);
  2794. smalltalk.addMethod(
  2795. "_testTranslateBy",
  2796. smalltalk.method({
  2797. selector: "testTranslateBy",
  2798. category: 'tests',
  2799. fn: function () {
  2800. var self = this;
  2801. smalltalk.send(self, "_assert_equals_", [smalltalk.send(3, "__at", [4]), smalltalk.send(smalltalk.send(3, "__at", [3]), "_translateBy_", [smalltalk.send(0, "__at", [1])])]);
  2802. 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", [])])])]);
  2803. smalltalk.send(self, "_assert_equals_", [smalltalk.send(5, "__at", [6]), smalltalk.send(smalltalk.send(3, "__at", [3]), "_translateBy_", [smalltalk.send(2, "__at", [3])])]);
  2804. 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])])]);
  2805. return self;
  2806. },
  2807. args: [],
  2808. 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).",
  2809. messageSends: ["assert:equals:", "@", "translateBy:", "negated"],
  2810. referencedClasses: []
  2811. }),
  2812. smalltalk.PointTest);
  2813. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2814. smalltalk.addMethod(
  2815. "_textNext",
  2816. smalltalk.method({
  2817. selector: "textNext",
  2818. category: 'tests',
  2819. fn: function () {
  2820. var self = this;
  2821. 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]);}]);
  2822. return self;
  2823. },
  2824. args: [],
  2825. 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]",
  2826. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  2827. referencedClasses: ["Random"]
  2828. }),
  2829. smalltalk.RandomTest);
  2830. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2831. smalltalk.addMethod(
  2832. "_testAddRemove",
  2833. smalltalk.method({
  2834. selector: "testAddRemove",
  2835. category: 'tests',
  2836. fn: function () {
  2837. var self = this;
  2838. var set;
  2839. set = smalltalk.send(smalltalk.Set || Set, "_new", []);
  2840. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_isEmpty", [])]);
  2841. smalltalk.send(set, "_add_", [3]);
  2842. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [3])]);
  2843. smalltalk.send(set, "_add_", [5]);
  2844. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [5])]);
  2845. smalltalk.send(set, "_remove_", [3]);
  2846. smalltalk.send(self, "_deny_", [smalltalk.send(set, "_includes_", [3])]);
  2847. return self;
  2848. },
  2849. args: [],
  2850. 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)",
  2851. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  2852. referencedClasses: ["Set"]
  2853. }),
  2854. smalltalk.SetTest);
  2855. smalltalk.addMethod(
  2856. "_testAt",
  2857. smalltalk.method({
  2858. selector: "testAt",
  2859. category: 'tests',
  2860. fn: function () {
  2861. var self = this;
  2862. smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(smalltalk.send(smalltalk.Set || Set, "_new", []), "_at_put_", [1, 2]);}, smalltalk.Error || Error]);
  2863. return self;
  2864. },
  2865. args: [],
  2866. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  2867. messageSends: ["should:raise:", "at:put:", "new"],
  2868. referencedClasses: ["Set", "Error"]
  2869. }),
  2870. smalltalk.SetTest);
  2871. smalltalk.addMethod(
  2872. "_testPrintString",
  2873. smalltalk.method({
  2874. selector: "testPrintString",
  2875. category: 'tests',
  2876. fn: function () {
  2877. var self = this;
  2878. var $1, $2;
  2879. var set;
  2880. set = smalltalk.send(smalltalk.Set || Set, "_new", []);
  2881. smalltalk.send(self, "_assert_equals_", ["a Set ()", smalltalk.send(set, "_printString", [])]);
  2882. smalltalk.send(set, "_add_", [1]);
  2883. $1 = smalltalk.send(set, "_add_", [3]);
  2884. smalltalk.send(self, "_assert_equals_", ["a Set (1 3)", smalltalk.send(set, "_printString", [])]);
  2885. smalltalk.send(set, "_add_", ["foo"]);
  2886. smalltalk.send(self, "_assert_equals_", ["a Set (1 3 'foo')", smalltalk.send(set, "_printString", [])]);
  2887. smalltalk.send(set, "_remove_", [1]);
  2888. $2 = smalltalk.send(set, "_remove_", [3]);
  2889. smalltalk.send(self, "_assert_equals_", ["a Set ('foo')", smalltalk.send(set, "_printString", [])]);
  2890. smalltalk.send(set, "_add_", [3]);
  2891. smalltalk.send(self, "_assert_equals_", ["a Set ('foo' 3)", 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. return self;
  2895. },
  2896. args: [],
  2897. 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 ).",
  2898. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:"],
  2899. referencedClasses: ["Set"]
  2900. }),
  2901. smalltalk.SetTest);
  2902. smalltalk.addMethod(
  2903. "_testSize",
  2904. smalltalk.method({
  2905. selector: "testSize",
  2906. category: 'tests',
  2907. fn: function () {
  2908. var self = this;
  2909. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.Set || Set, "_new", []), "_size", []), 0]);
  2910. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.Set || Set, "_withAll_", [[1, 2, 3, 4]]), "_size", []), 4]);
  2911. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.Set || Set, "_withAll_", [[1, 1, 1, 1]]), "_size", []), 1]);
  2912. return self;
  2913. },
  2914. args: [],
  2915. 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",
  2916. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  2917. referencedClasses: ["Set"]
  2918. }),
  2919. smalltalk.SetTest);
  2920. smalltalk.addMethod(
  2921. "_testUnicity",
  2922. smalltalk.method({
  2923. selector: "testUnicity",
  2924. category: 'tests',
  2925. fn: function () {
  2926. var self = this;
  2927. var set;
  2928. set = smalltalk.send(smalltalk.Set || Set, "_new", []);
  2929. smalltalk.send(set, "_add_", [21]);
  2930. smalltalk.send(set, "_add_", ["hello"]);
  2931. smalltalk.send(set, "_add_", [21]);
  2932. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [2])]);
  2933. smalltalk.send(set, "_add_", ["hello"]);
  2934. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [2])]);
  2935. smalltalk.send(self, "_assert_equals_", [smalltalk.send(set, "_asArray", []), [21, "hello"]]);
  2936. return self;
  2937. },
  2938. args: [],
  2939. 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')",
  2940. messageSends: ["new", "add:", "assert:", "=", "size", "assert:equals:", "asArray"],
  2941. referencedClasses: ["Set"]
  2942. }),
  2943. smalltalk.SetTest);
  2944. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2945. smalltalk.addMethod(
  2946. "_testCopying",
  2947. smalltalk.method({
  2948. selector: "testCopying",
  2949. category: 'tests',
  2950. fn: function () {
  2951. var self = this;
  2952. smalltalk.send(self, "_assert_equals_", [smalltalk.send(nil, "_copy", []), nil]);
  2953. return self;
  2954. },
  2955. args: [],
  2956. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  2957. messageSends: ["assert:equals:", "copy"],
  2958. referencedClasses: []
  2959. }),
  2960. smalltalk.UndefinedTest);
  2961. smalltalk.addMethod(
  2962. "_testDeepCopy",
  2963. smalltalk.method({
  2964. selector: "testDeepCopy",
  2965. category: 'tests',
  2966. fn: function () {
  2967. var self = this;
  2968. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(nil, "_deepCopy", []), "__eq", [nil])]);
  2969. return self;
  2970. },
  2971. args: [],
  2972. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  2973. messageSends: ["assert:", "=", "deepCopy"],
  2974. referencedClasses: []
  2975. }),
  2976. smalltalk.UndefinedTest);
  2977. smalltalk.addMethod(
  2978. "_testIfNil",
  2979. smalltalk.method({
  2980. selector: "testIfNil",
  2981. category: 'tests',
  2982. fn: function () {
  2983. var self = this;
  2984. var $1, $2, $3;
  2985. if (($receiver = nil) == nil || $receiver == undefined) {
  2986. $1 = true;
  2987. } else {
  2988. $1 = nil;
  2989. }
  2990. smalltalk.send(self, "_assert_equals_", [$1, true]);
  2991. if (($receiver = nil) == nil || $receiver == undefined) {
  2992. $2 = nil;
  2993. } else {
  2994. $2 = true;
  2995. }
  2996. smalltalk.send(self, "_deny_", [smalltalk.send($2, "__eq", [true])]);
  2997. if (($receiver = nil) == nil || $receiver == undefined) {
  2998. $3 = true;
  2999. } else {
  3000. $3 = false;
  3001. }
  3002. smalltalk.send(self, "_assert_equals_", [$3, true]);
  3003. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(nil, "_ifNotNil_ifNil_", [function () {return true;}, function () {return false;}]), "__eq", [true])]);
  3004. return self;
  3005. },
  3006. args: [],
  3007. 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",
  3008. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  3009. referencedClasses: []
  3010. }),
  3011. smalltalk.UndefinedTest);
  3012. smalltalk.addMethod(
  3013. "_testIsNil",
  3014. smalltalk.method({
  3015. selector: "testIsNil",
  3016. category: 'tests',
  3017. fn: function () {
  3018. var self = this;
  3019. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "_isNil", [])]);
  3020. smalltalk.send(self, "_deny_", [smalltalk.send(nil, "_notNil", [])]);
  3021. return self;
  3022. },
  3023. args: [],
  3024. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  3025. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  3026. referencedClasses: []
  3027. }),
  3028. smalltalk.UndefinedTest);