1
0

Kernel-Tests.js 124 KB

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