Kernel-Tests.js 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414
  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('DictionaryTest', smalltalk.TestCase, [], 'Kernel-Tests');
  535. smalltalk.addMethod(
  536. "_testAccessing",
  537. smalltalk.method({
  538. selector: "testAccessing",
  539. category: 'tests',
  540. fn: function (){
  541. var self=this;
  542. var d=nil;
  543. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  544. smalltalk.send(d, "_at_put_", ["hello", "world"]);
  545. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", ["hello"]), "__eq", ["world"])]);
  546. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_ifAbsent_", ["hello", (function(){return nil;})]), "__eq", ["world"])]);
  547. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(d, "_at_ifAbsent_", ["foo", (function(){return nil;})]), "__eq", ["world"])]);
  548. smalltalk.send(d, "_at_put_", [(1), (2)]);
  549. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", [(1)]), "__eq", [(2)])]);
  550. smalltalk.send(d, "_at_put_", [smalltalk.send((1), "__at", [(3)]), (3)]);
  551. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_at_", [smalltalk.send((1), "__at", [(3)])]), "__eq", [(3)])]);
  552. return self;},
  553. args: [],
  554. 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",
  555. messageSends: ["new", "at:put:", "assert:", "=", "at:", "at:ifAbsent:", "deny:", "@"],
  556. referencedClasses: ["Dictionary"]
  557. }),
  558. smalltalk.DictionaryTest);
  559. smalltalk.addMethod(
  560. "_testDynamicDictionaries",
  561. smalltalk.method({
  562. selector: "testDynamicDictionaries",
  563. category: 'tests',
  564. fn: function (){
  565. var self=this;
  566. 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)])])])]);
  567. return self;},
  568. args: [],
  569. source: "testDynamicDictionaries\x0a\x09self assert: #{'hello' -> 1} asDictionary = (Dictionary with: 'hello' -> 1)",
  570. messageSends: ["assert:", "=", "asDictionary", "->", "with:"],
  571. referencedClasses: ["Dictionary"]
  572. }),
  573. smalltalk.DictionaryTest);
  574. smalltalk.addMethod(
  575. "_testEquality",
  576. smalltalk.method({
  577. selector: "testEquality",
  578. category: 'tests',
  579. fn: function (){
  580. var self=this;
  581. var d1=nil;
  582. var d2=nil;
  583. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []), "__eq", [smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])])]);
  584. (d1=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  585. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  586. smalltalk.send(self, "_assert_", [smalltalk.send(d1, "__eq", [d2])]);
  587. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(1), (3)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  588. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  589. (d2=(function($rec){smalltalk.send($rec, "_at_put_", [(2), (2)]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", [])));
  590. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  591. (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", [])));
  592. smalltalk.send(self, "_deny_", [smalltalk.send(d1, "__eq", [d2])]);
  593. return self;},
  594. args: [],
  595. 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.",
  596. messageSends: ["assert:", "=", "new", "at:put:", "yourself", "deny:"],
  597. referencedClasses: ["Dictionary"]
  598. }),
  599. smalltalk.DictionaryTest);
  600. smalltalk.addMethod(
  601. "_testIfAbsent",
  602. smalltalk.method({
  603. selector: "testIfAbsent",
  604. category: 'tests',
  605. fn: function (){
  606. var self=this;
  607. var d=nil;
  608. var visited=nil;
  609. (visited=false);
  610. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  611. smalltalk.send(d, "_at_ifAbsent_", ["hello", (function(){return (visited=true);})]);
  612. smalltalk.send(self, "_assert_", [visited]);
  613. return self;},
  614. args: [],
  615. 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.",
  616. messageSends: ["new", "at:ifAbsent:", "assert:"],
  617. referencedClasses: ["Dictionary"]
  618. }),
  619. smalltalk.DictionaryTest);
  620. smalltalk.addMethod(
  621. "_testIfPresent",
  622. smalltalk.method({
  623. selector: "testIfPresent",
  624. category: 'tests',
  625. fn: function (){
  626. var self=this;
  627. var d=nil;
  628. var visited=nil;
  629. var absent=nil;
  630. (visited=false);
  631. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  632. smalltalk.send(d, "_at_put_", ["hello", "world"]);
  633. smalltalk.send(d, "_at_ifPresent_", ["hello", (function(value){return (visited=value);})]);
  634. smalltalk.send(self, "_assert_", [smalltalk.send(visited, "__eq", ["world"])]);
  635. (absent=smalltalk.send(d, "_at_ifPresent_", ["bye", (function(value){return (visited=value);})]));
  636. smalltalk.send(self, "_assert_", [smalltalk.send(absent, "_isNil", [])]);
  637. return self;},
  638. args: [],
  639. 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",
  640. messageSends: ["new", "at:put:", "at:ifPresent:", "assert:", "=", "isNil"],
  641. referencedClasses: ["Dictionary"]
  642. }),
  643. smalltalk.DictionaryTest);
  644. smalltalk.addMethod(
  645. "_testIfPresentIfAbsent",
  646. smalltalk.method({
  647. selector: "testIfPresentIfAbsent",
  648. category: 'tests',
  649. fn: function (){
  650. var self=this;
  651. var d=nil;
  652. var visited=nil;
  653. (visited=false);
  654. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  655. smalltalk.send(d, "_at_put_", ["hello", "world"]);
  656. smalltalk.send(d, "_at_ifPresent_ifAbsent_", ["hello", (function(value){return (visited=value);}), (function(){return (visited=true);})]);
  657. smalltalk.send(self, "_assert_", [smalltalk.send(visited, "__eq", ["world"])]);
  658. smalltalk.send(d, "_at_ifPresent_ifAbsent_", ["buy", (function(value){return (visited=value);}), (function(){return (visited=true);})]);
  659. smalltalk.send(self, "_assert_", [visited]);
  660. return self;},
  661. args: [],
  662. 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.",
  663. messageSends: ["new", "at:put:", "at:ifPresent:ifAbsent:", "assert:", "="],
  664. referencedClasses: ["Dictionary"]
  665. }),
  666. smalltalk.DictionaryTest);
  667. smalltalk.addMethod(
  668. "_testKeys",
  669. smalltalk.method({
  670. selector: "testKeys",
  671. category: 'tests',
  672. fn: function (){
  673. var self=this;
  674. var d=nil;
  675. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  676. smalltalk.send(d, "_at_put_", [(1), (2)]);
  677. smalltalk.send(d, "_at_put_", [(2), (3)]);
  678. smalltalk.send(d, "_at_put_", [(3), (4)]);
  679. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (2), (3)]])]);
  680. return self;},
  681. args: [],
  682. 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)",
  683. messageSends: ["new", "at:put:", "assert:", "=", "keys"],
  684. referencedClasses: ["Dictionary"]
  685. }),
  686. smalltalk.DictionaryTest);
  687. smalltalk.addMethod(
  688. "_testPrintString",
  689. smalltalk.method({
  690. selector: "testPrintString",
  691. category: 'tests',
  692. fn: function (){
  693. var self=this;
  694. 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", []))]);
  695. return self;},
  696. args: [],
  697. 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)",
  698. messageSends: ["assert:equals:", "at:put:", "printString", "new"],
  699. referencedClasses: ["Dictionary"]
  700. }),
  701. smalltalk.DictionaryTest);
  702. smalltalk.addMethod(
  703. "_testRemoveKey",
  704. smalltalk.method({
  705. selector: "testRemoveKey",
  706. category: 'tests',
  707. fn: function (){
  708. var self=this;
  709. var d=nil;
  710. var key=nil;
  711. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  712. smalltalk.send(d, "_at_put_", [(1), (2)]);
  713. smalltalk.send(d, "_at_put_", [(2), (3)]);
  714. smalltalk.send(d, "_at_put_", [(3), (4)]);
  715. (key=(2));
  716. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (2), (3)]])]);
  717. smalltalk.send(d, "_removeKey_", [key]);
  718. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_keys", []), "__eq", [[(1), (3)]])]);
  719. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_values", []), "__eq", [[(2), (4)]])]);
  720. smalltalk.send(self, "_deny_", [smalltalk.send(d, "_includesKey_", [(2)])]);
  721. return self;},
  722. args: [],
  723. 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)",
  724. messageSends: ["new", "at:put:", "assert:", "=", "keys", "removeKey:", "values", "deny:", "includesKey:"],
  725. referencedClasses: ["Dictionary"]
  726. }),
  727. smalltalk.DictionaryTest);
  728. smalltalk.addMethod(
  729. "_testRemoveKeyIfAbsent",
  730. smalltalk.method({
  731. selector: "testRemoveKeyIfAbsent",
  732. category: 'tests',
  733. fn: function (){
  734. var self=this;
  735. var d=nil;
  736. var key=nil;
  737. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  738. smalltalk.send(d, "_at_put_", [(1), (2)]);
  739. smalltalk.send(d, "_at_put_", [(2), (3)]);
  740. smalltalk.send(d, "_at_put_", [(3), (4)]);
  741. (key=(2));
  742. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_", [key]), "__eq", [(3)])]);
  743. (key=(3));
  744. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_ifAbsent_", [key, (function(){return (42);})]), "__eq", [(4)])]);
  745. (key="why");
  746. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_removeKey_ifAbsent_", [key, (function(){return (42);})]), "__eq", [(42)])]);
  747. return self;},
  748. args: [],
  749. 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.",
  750. messageSends: ["new", "at:put:", "assert:", "=", "removeKey:", "removeKey:ifAbsent:"],
  751. referencedClasses: ["Dictionary"]
  752. }),
  753. smalltalk.DictionaryTest);
  754. smalltalk.addMethod(
  755. "_testSize",
  756. smalltalk.method({
  757. selector: "testSize",
  758. category: 'tests',
  759. fn: function (){
  760. var self=this;
  761. var d=nil;
  762. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  763. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(0)])]);
  764. smalltalk.send(d, "_at_put_", [(1), (2)]);
  765. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(1)])]);
  766. smalltalk.send(d, "_at_put_", [(2), (3)]);
  767. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_size", []), "__eq", [(2)])]);
  768. return self;},
  769. args: [],
  770. 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.",
  771. messageSends: ["new", "assert:", "=", "size", "at:put:"],
  772. referencedClasses: ["Dictionary"]
  773. }),
  774. smalltalk.DictionaryTest);
  775. smalltalk.addMethod(
  776. "_testValues",
  777. smalltalk.method({
  778. selector: "testValues",
  779. category: 'tests',
  780. fn: function (){
  781. var self=this;
  782. var d=nil;
  783. (d=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
  784. smalltalk.send(d, "_at_put_", [(1), (2)]);
  785. smalltalk.send(d, "_at_put_", [(2), (3)]);
  786. smalltalk.send(d, "_at_put_", [(3), (4)]);
  787. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(d, "_values", []), "__eq", [[(2), (3), (4)]])]);
  788. return self;},
  789. args: [],
  790. 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)",
  791. messageSends: ["new", "at:put:", "assert:", "=", "values"],
  792. referencedClasses: ["Dictionary"]
  793. }),
  794. smalltalk.DictionaryTest);
  795. smalltalk.addClass('JSObjectProxyTest', smalltalk.TestCase, [], 'Kernel-Tests');
  796. smalltalk.addMethod(
  797. "_jsObject",
  798. smalltalk.method({
  799. selector: "jsObject",
  800. category: 'accessing',
  801. fn: function (){
  802. var self=this;
  803. return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}};
  804. return self;},
  805. args: [],
  806. source: "jsObject\x0a\x09<return jsObject = {a: 1, b: function() {return 2;}, c: function(object) {return object;}}>",
  807. messageSends: [],
  808. referencedClasses: []
  809. }),
  810. smalltalk.JSObjectProxyTest);
  811. smalltalk.addMethod(
  812. "_testDNU",
  813. smalltalk.method({
  814. selector: "testDNU",
  815. category: 'tests',
  816. fn: function (){
  817. var self=this;
  818. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send(self, "_jsObject", []), "_foo", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  819. return self;},
  820. args: [],
  821. source: "testDNU\x0a\x09self should: [self jsObject foo] raise: MessageNotUnderstood",
  822. messageSends: ["should:raise:", "foo", "jsObject"],
  823. referencedClasses: ["MessageNotUnderstood"]
  824. }),
  825. smalltalk.JSObjectProxyTest);
  826. smalltalk.addMethod(
  827. "_testMessageSend",
  828. smalltalk.method({
  829. selector: "testMessageSend",
  830. category: 'tests',
  831. fn: function (){
  832. var self=this;
  833. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_a", []), (1)]);
  834. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_b", []), (2)]);
  835. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(self, "_jsObject", []), "_c_", [(3)]), (3)]);
  836. return self;},
  837. args: [],
  838. 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",
  839. messageSends: ["assert:equals:", "a", "jsObject", "b", "c:"],
  840. referencedClasses: []
  841. }),
  842. smalltalk.JSObjectProxyTest);
  843. smalltalk.addMethod(
  844. "_testMethodWithArguments",
  845. smalltalk.method({
  846. selector: "testMethodWithArguments",
  847. category: 'tests',
  848. fn: function (){
  849. var self=this;
  850. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_hasClass_", ["amber"])]);
  851. smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_addClass_", ["amber"]);
  852. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_hasClass_", ["amber"])]);
  853. smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_removeClass_", ["amber"]);
  854. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send("body", "_asJQuery", []), "_hasClass_", ["amber"])]);
  855. return self;},
  856. args: [],
  857. 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').",
  858. messageSends: ["deny:", "hasClass:", "asJQuery", "addClass:", "assert:", "removeClass:"],
  859. referencedClasses: []
  860. }),
  861. smalltalk.JSObjectProxyTest);
  862. smalltalk.addMethod(
  863. "_testPrinting",
  864. smalltalk.method({
  865. selector: "testPrinting",
  866. category: 'tests',
  867. fn: function (){
  868. var self=this;
  869. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_jsObject", []), "_printString", []), "__eq", ["[object Object]"])]);
  870. return self;},
  871. args: [],
  872. source: "testPrinting\x0a\x09self assert: self jsObject printString = '[object Object]'",
  873. messageSends: ["assert:", "=", "printString", "jsObject"],
  874. referencedClasses: []
  875. }),
  876. smalltalk.JSObjectProxyTest);
  877. smalltalk.addMethod(
  878. "_testPropertyThatReturnsEmptyString",
  879. smalltalk.method({
  880. selector: "testPropertyThatReturnsEmptyString",
  881. category: 'tests',
  882. fn: function (){
  883. var self=this;
  884. document.location.hash = '';
  885. smalltalk.send(self, "_assert_equals_", ["", smalltalk.send(smalltalk.send((typeof document == 'undefined' ? nil : document), "_location", []), "_hash", [])]);
  886. smalltalk.send(smalltalk.send((typeof document == 'undefined' ? nil : document), "_location", []), "_hash_", ["test"]);
  887. smalltalk.send(self, "_assert_equals_", ["#test", smalltalk.send(smalltalk.send((typeof document == 'undefined' ? nil : document), "_location", []), "_hash", [])]);
  888. return self;},
  889. args: [],
  890. 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.",
  891. messageSends: ["assert:equals:", "hash", "location", "hash:"],
  892. referencedClasses: []
  893. }),
  894. smalltalk.JSObjectProxyTest);
  895. smalltalk.addMethod(
  896. "_testYourself",
  897. smalltalk.method({
  898. selector: "testYourself",
  899. category: 'tests',
  900. fn: function (){
  901. var self=this;
  902. var body=nil;
  903. (body=(function($rec){smalltalk.send($rec, "_addClass_", ["amber"]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send("body", "_asJQuery", [])));
  904. smalltalk.send(self, "_assert_", [smalltalk.send(body, "_hasClass_", ["amber"])]);
  905. smalltalk.send(body, "_removeClass_", ["amber"]);
  906. smalltalk.send(self, "_deny_", [smalltalk.send(body, "_hasClass_", ["amber"])]);
  907. return self;},
  908. args: [],
  909. 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').",
  910. messageSends: ["addClass:", "yourself", "asJQuery", "assert:", "hasClass:", "removeClass:", "deny:"],
  911. referencedClasses: []
  912. }),
  913. smalltalk.JSObjectProxyTest);
  914. smalltalk.addClass('NumberTest', smalltalk.TestCase, [], 'Kernel-Tests');
  915. smalltalk.addMethod(
  916. "_testArithmetic",
  917. smalltalk.method({
  918. selector: "testArithmetic",
  919. category: 'tests',
  920. fn: function (){
  921. var self=this;
  922. smalltalk.send(self, "_assert_", [smalltalk.send((1.5) + (1), "__eq", [(2.5)])]);
  923. smalltalk.send(self, "_assert_", [smalltalk.send((2) - (1), "__eq", [(1)])]);
  924. smalltalk.send(self, "_assert_", [smalltalk.send((-2) - (1), "__eq", [(-3)])]);
  925. smalltalk.send(self, "_assert_", [smalltalk.send((12) / (2), "__eq", [(6)])]);
  926. smalltalk.send(self, "_assert_", [smalltalk.send((3) * (4), "__eq", [(12)])]);
  927. smalltalk.send(self, "_assert_", [smalltalk.send(((($receiver = (1) + (2)).klass === smalltalk.Number) ? $receiver *(3) : smalltalk.send($receiver, "__star", [(3)])), "__eq", [(9)])]);
  928. smalltalk.send(self, "_assert_", [smalltalk.send((1) + (2) * (3), "__eq", [(7)])]);
  929. return self;},
  930. args: [],
  931. 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",
  932. messageSends: ["assert:", "=", "+", "-", "/", "*"],
  933. referencedClasses: []
  934. }),
  935. smalltalk.NumberTest);
  936. smalltalk.addMethod(
  937. "_testComparison",
  938. smalltalk.method({
  939. selector: "testComparison",
  940. category: 'tests',
  941. fn: function (){
  942. var self=this;
  943. smalltalk.send(self, "_assert_", [(3) > (2)]);
  944. smalltalk.send(self, "_assert_", [(2) < (3)]);
  945. smalltalk.send(self, "_deny_", [(3) < (2)]);
  946. smalltalk.send(self, "_deny_", [(2) > (3)]);
  947. smalltalk.send(self, "_assert_", [(3) >= (3)]);
  948. smalltalk.send(self, "_assert_", [(3.1) >= (3)]);
  949. smalltalk.send(self, "_assert_", [(3) <= (3)]);
  950. smalltalk.send(self, "_assert_", [(3) <= (3.1)]);
  951. return self;},
  952. args: [],
  953. 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",
  954. messageSends: ["assert:", ">", "<", "deny:", ">=", "<="],
  955. referencedClasses: []
  956. }),
  957. smalltalk.NumberTest);
  958. smalltalk.addMethod(
  959. "_testCopying",
  960. smalltalk.method({
  961. selector: "testCopying",
  962. category: 'tests',
  963. fn: function (){
  964. var self=this;
  965. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_copy", []), "__eq_eq", [(1)])]);
  966. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_deepCopy", []), "__eq_eq", [(1)])]);
  967. return self;},
  968. args: [],
  969. source: "testCopying\x0a\x09self assert: 1 copy == 1.\x0a\x09self assert: 1 deepCopy == 1",
  970. messageSends: ["assert:", "==", "copy", "deepCopy"],
  971. referencedClasses: []
  972. }),
  973. smalltalk.NumberTest);
  974. smalltalk.addMethod(
  975. "_testEquality",
  976. smalltalk.method({
  977. selector: "testEquality",
  978. category: 'tests',
  979. fn: function (){
  980. var self=this;
  981. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [(1)])]);
  982. smalltalk.send(self, "_assert_", [smalltalk.send((0), "__eq", [(0)])]);
  983. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq", [(0)])]);
  984. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [(1)])]);
  985. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  986. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq", [smalltalk.send((1), "_yourself", [])])]);
  987. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [false])]);
  988. smalltalk.send(self, "_deny_", [smalltalk.send(false, "__eq", [(0)])]);
  989. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  990. smalltalk.send(self, "_deny_", [smalltalk.send((0), "__eq", [""])]);
  991. return self;},
  992. args: [],
  993. 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 = ''",
  994. messageSends: ["assert:", "=", "deny:", "yourself"],
  995. referencedClasses: []
  996. }),
  997. smalltalk.NumberTest);
  998. smalltalk.addMethod(
  999. "_testIdentity",
  1000. smalltalk.method({
  1001. selector: "testIdentity",
  1002. category: 'tests',
  1003. fn: function (){
  1004. var self=this;
  1005. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq_eq", [(1)])]);
  1006. smalltalk.send(self, "_assert_", [smalltalk.send((0), "__eq_eq", [(0)])]);
  1007. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq_eq", [(0)])]);
  1008. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq_eq", [(1)])]);
  1009. smalltalk.send(self, "_assert_", [smalltalk.send((1), "__eq_eq", [smalltalk.send((1), "_yourself", [])])]);
  1010. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((1), "_yourself", []), "__eq_eq", [smalltalk.send((1), "_yourself", [])])]);
  1011. smalltalk.send(self, "_deny_", [smalltalk.send((1), "__eq_eq", [(2)])]);
  1012. return self;},
  1013. args: [],
  1014. 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",
  1015. messageSends: ["assert:", "==", "deny:", "yourself"],
  1016. referencedClasses: []
  1017. }),
  1018. smalltalk.NumberTest);
  1019. smalltalk.addMethod(
  1020. "_testMinMax",
  1021. smalltalk.method({
  1022. selector: "testMinMax",
  1023. category: 'tests',
  1024. fn: function (){
  1025. var self=this;
  1026. smalltalk.send(self, "_assert_equals_", [smalltalk.send((2), "_max_", [(5)]), (5)]);
  1027. smalltalk.send(self, "_assert_equals_", [smalltalk.send((2), "_min_", [(5)]), (2)]);
  1028. return self;},
  1029. args: [],
  1030. source: "testMinMax\x0a\x09\x0a\x09self assert: (2 max: 5) equals: 5.\x0a\x09self assert: (2 min: 5) equals: 2",
  1031. messageSends: ["assert:equals:", "max:", "min:"],
  1032. referencedClasses: []
  1033. }),
  1034. smalltalk.NumberTest);
  1035. smalltalk.addMethod(
  1036. "_testNegated",
  1037. smalltalk.method({
  1038. selector: "testNegated",
  1039. category: 'tests',
  1040. fn: function (){
  1041. var self=this;
  1042. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_negated", []), "__eq", [(-3)])]);
  1043. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((-3), "_negated", []), "__eq", [(3)])]);
  1044. return self;},
  1045. args: [],
  1046. source: "testNegated\x0a\x09self assert: 3 negated = -3.\x0a\x09self assert: -3 negated = 3",
  1047. messageSends: ["assert:", "=", "negated"],
  1048. referencedClasses: []
  1049. }),
  1050. smalltalk.NumberTest);
  1051. smalltalk.addMethod(
  1052. "_testPrintShowingDecimalPlaces",
  1053. smalltalk.method({
  1054. selector: "testPrintShowingDecimalPlaces",
  1055. category: 'tests',
  1056. fn: function (){
  1057. var self=this;
  1058. smalltalk.send(self, "_assert_equals_", ["23.00", smalltalk.send((23), "_printShowingDecimalPlaces_", [(2)])]);
  1059. smalltalk.send(self, "_assert_equals_", ["23.57", smalltalk.send((23.5698), "_printShowingDecimalPlaces_", [(2)])]);
  1060. smalltalk.send(self, "_assert_equals_", ["-234.56700", smalltalk.send(smalltalk.send((234.567), "_negated", []), "_printShowingDecimalPlaces_", [(5)])]);
  1061. smalltalk.send(self, "_assert_equals_", ["23", smalltalk.send((23.4567), "_printShowingDecimalPlaces_", [(0)])]);
  1062. smalltalk.send(self, "_assert_equals_", ["24", smalltalk.send((23.5567), "_printShowingDecimalPlaces_", [(0)])]);
  1063. smalltalk.send(self, "_assert_equals_", ["-23", smalltalk.send(smalltalk.send((23.4567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  1064. smalltalk.send(self, "_assert_equals_", ["-24", smalltalk.send(smalltalk.send((23.5567), "_negated", []), "_printShowingDecimalPlaces_", [(0)])]);
  1065. smalltalk.send(self, "_assert_equals_", ["100000000.0", smalltalk.send((100000000), "_printShowingDecimalPlaces_", [(1)])]);
  1066. smalltalk.send(self, "_assert_equals_", ["0.98000", smalltalk.send((0.98), "_printShowingDecimalPlaces_", [(5)])]);
  1067. smalltalk.send(self, "_assert_equals_", ["-0.98", smalltalk.send(smalltalk.send((0.98), "_negated", []), "_printShowingDecimalPlaces_", [(2)])]);
  1068. smalltalk.send(self, "_assert_equals_", ["2.57", smalltalk.send((2.567), "_printShowingDecimalPlaces_", [(2)])]);
  1069. smalltalk.send(self, "_assert_equals_", ["-2.57", smalltalk.send((-2.567), "_printShowingDecimalPlaces_", [(2)])]);
  1070. smalltalk.send(self, "_assert_equals_", ["0.00", smalltalk.send((0), "_printShowingDecimalPlaces_", [(2)])]);
  1071. return self;},
  1072. args: [],
  1073. 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).",
  1074. messageSends: ["assert:equals:", "printShowingDecimalPlaces:", "negated"],
  1075. referencedClasses: []
  1076. }),
  1077. smalltalk.NumberTest);
  1078. smalltalk.addMethod(
  1079. "_testRounded",
  1080. smalltalk.method({
  1081. selector: "testRounded",
  1082. category: 'tests',
  1083. fn: function (){
  1084. var self=this;
  1085. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_rounded", []), "__eq", [(3)])]);
  1086. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_rounded", []), "__eq", [(3)])]);
  1087. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_rounded", []), "__eq", [(4)])]);
  1088. return self;},
  1089. args: [],
  1090. source: "testRounded\x0a\x09\x0a\x09self assert: 3 rounded = 3.\x0a\x09self assert: 3.212 rounded = 3.\x0a\x09self assert: 3.51 rounded = 4",
  1091. messageSends: ["assert:", "=", "rounded"],
  1092. referencedClasses: []
  1093. }),
  1094. smalltalk.NumberTest);
  1095. smalltalk.addMethod(
  1096. "_testSqrt",
  1097. smalltalk.method({
  1098. selector: "testSqrt",
  1099. category: 'tests',
  1100. fn: function (){
  1101. var self=this;
  1102. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((4), "_sqrt", []), "__eq", [(2)])]);
  1103. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((16), "_sqrt", []), "__eq", [(4)])]);
  1104. return self;},
  1105. args: [],
  1106. source: "testSqrt\x0a\x09\x0a\x09self assert: 4 sqrt = 2.\x0a\x09self assert: 16 sqrt = 4",
  1107. messageSends: ["assert:", "=", "sqrt"],
  1108. referencedClasses: []
  1109. }),
  1110. smalltalk.NumberTest);
  1111. smalltalk.addMethod(
  1112. "_testSquared",
  1113. smalltalk.method({
  1114. selector: "testSquared",
  1115. category: 'tests',
  1116. fn: function (){
  1117. var self=this;
  1118. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((4), "_squared", []), "__eq", [(16)])]);
  1119. return self;},
  1120. args: [],
  1121. source: "testSquared\x0a\x09\x0a\x09self assert: 4 squared = 16",
  1122. messageSends: ["assert:", "=", "squared"],
  1123. referencedClasses: []
  1124. }),
  1125. smalltalk.NumberTest);
  1126. smalltalk.addMethod(
  1127. "_testTimesRepeat",
  1128. smalltalk.method({
  1129. selector: "testTimesRepeat",
  1130. category: 'tests',
  1131. fn: function (){
  1132. var self=this;
  1133. var i=nil;
  1134. (i=(0));
  1135. smalltalk.send((0), "_timesRepeat_", [(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})]);
  1136. smalltalk.send(self, "_assert_equals_", [i, (0)]);
  1137. smalltalk.send((5), "_timesRepeat_", [(function(){return (i=((($receiver = i).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)])));})]);
  1138. smalltalk.send(self, "_assert_equals_", [i, (5)]);
  1139. return self;},
  1140. args: [],
  1141. 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",
  1142. messageSends: ["timesRepeat:", "+", "assert:equals:"],
  1143. referencedClasses: []
  1144. }),
  1145. smalltalk.NumberTest);
  1146. smalltalk.addMethod(
  1147. "_testTo",
  1148. smalltalk.method({
  1149. selector: "testTo",
  1150. category: 'tests',
  1151. fn: function (){
  1152. var self=this;
  1153. smalltalk.send(self, "_assert_equals_", [smalltalk.send((1), "_to_", [(5)]), [(1), (2), (3), (4), (5)]]);
  1154. return self;},
  1155. args: [],
  1156. source: "testTo\x0a\x09self assert: (1 to: 5) equals: #(1 2 3 4 5)",
  1157. messageSends: ["assert:equals:", "to:"],
  1158. referencedClasses: []
  1159. }),
  1160. smalltalk.NumberTest);
  1161. smalltalk.addMethod(
  1162. "_testToBy",
  1163. smalltalk.method({
  1164. selector: "testToBy",
  1165. category: 'tests',
  1166. fn: function (){
  1167. var self=this;
  1168. smalltalk.send(self, "_assert_equals_", [smalltalk.send((0), "_to_by_", [(6), (2)]), [(0), (2), (4), (6)]]);
  1169. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send((1), "_to_by_", [(4), (0)]);}), (smalltalk.Error || Error)]);
  1170. return self;},
  1171. args: [],
  1172. 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",
  1173. messageSends: ["assert:equals:", "to:by:", "should:raise:"],
  1174. referencedClasses: ["Error"]
  1175. }),
  1176. smalltalk.NumberTest);
  1177. smalltalk.addMethod(
  1178. "_testTruncated",
  1179. smalltalk.method({
  1180. selector: "testTruncated",
  1181. category: 'tests',
  1182. fn: function (){
  1183. var self=this;
  1184. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "_truncated", []), "__eq", [(3)])]);
  1185. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.212), "_truncated", []), "__eq", [(3)])]);
  1186. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3.51), "_truncated", []), "__eq", [(3)])]);
  1187. return self;},
  1188. args: [],
  1189. source: "testTruncated\x0a\x09\x0a\x09self assert: 3 truncated = 3.\x0a\x09self assert: 3.212 truncated = 3.\x0a\x09self assert: 3.51 truncated = 3",
  1190. messageSends: ["assert:", "=", "truncated"],
  1191. referencedClasses: []
  1192. }),
  1193. smalltalk.NumberTest);
  1194. smalltalk.addClass('ObjectMock', smalltalk.Object, ['foo', 'bar'], 'Kernel-Tests');
  1195. smalltalk.addMethod(
  1196. "_foo",
  1197. smalltalk.method({
  1198. selector: "foo",
  1199. category: 'not yet classified',
  1200. fn: function (){
  1201. var self=this;
  1202. return self['@foo'];
  1203. return self;},
  1204. args: [],
  1205. source: "foo\x0a\x09^foo",
  1206. messageSends: [],
  1207. referencedClasses: []
  1208. }),
  1209. smalltalk.ObjectMock);
  1210. smalltalk.addMethod(
  1211. "_foo_",
  1212. smalltalk.method({
  1213. selector: "foo:",
  1214. category: 'not yet classified',
  1215. fn: function (anObject){
  1216. var self=this;
  1217. (self['@foo']=anObject);
  1218. return self;},
  1219. args: ["anObject"],
  1220. source: "foo: anObject\x0a\x09foo := anObject",
  1221. messageSends: [],
  1222. referencedClasses: []
  1223. }),
  1224. smalltalk.ObjectMock);
  1225. smalltalk.addClass('ObjectTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1226. smalltalk.addMethod(
  1227. "_testBasicAccess",
  1228. smalltalk.method({
  1229. selector: "testBasicAccess",
  1230. category: 'tests',
  1231. fn: function (){
  1232. var self=this;
  1233. var o=nil;
  1234. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1235. smalltalk.send(o, "_basicAt_put_", ["a", (1)]);
  1236. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["a"]), (1)]);
  1237. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicAt_", ["b"]), nil]);
  1238. return self;},
  1239. args: [],
  1240. 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",
  1241. messageSends: ["new", "basicAt:put:", "assert:equals:", "basicAt:"],
  1242. referencedClasses: ["Object"]
  1243. }),
  1244. smalltalk.ObjectTest);
  1245. smalltalk.addMethod(
  1246. "_testBasicPerform",
  1247. smalltalk.method({
  1248. selector: "testBasicPerform",
  1249. category: 'tests',
  1250. fn: function (){
  1251. var self=this;
  1252. var o=nil;
  1253. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1254. smalltalk.send(o, "_basicAt_put_", ["func", (function(){return "hello";})]);
  1255. smalltalk.send(o, "_basicAt_put_", ["func2", (function(a){return ((($receiver = a).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]));})]);
  1256. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_", ["func"]), "hello"]);
  1257. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_basicPerform_withArguments_", ["func2", [(3)]]), (4)]);
  1258. return self;},
  1259. args: [],
  1260. 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",
  1261. messageSends: ["new", "basicAt:put:", "+", "assert:equals:", "basicPerform:", "basicPerform:withArguments:"],
  1262. referencedClasses: ["Object"]
  1263. }),
  1264. smalltalk.ObjectTest);
  1265. smalltalk.addMethod(
  1266. "_testDNU",
  1267. smalltalk.method({
  1268. selector: "testDNU",
  1269. category: 'tests',
  1270. fn: function (){
  1271. var self=this;
  1272. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_foo", []);}), (smalltalk.MessageNotUnderstood || MessageNotUnderstood)]);
  1273. return self;},
  1274. args: [],
  1275. source: "testDNU\x0a\x09self should: [Object new foo] raise: MessageNotUnderstood",
  1276. messageSends: ["should:raise:", "foo", "new"],
  1277. referencedClasses: ["Object", "MessageNotUnderstood"]
  1278. }),
  1279. smalltalk.ObjectTest);
  1280. smalltalk.addMethod(
  1281. "_testEquality",
  1282. smalltalk.method({
  1283. selector: "testEquality",
  1284. category: 'tests',
  1285. fn: function (){
  1286. var self=this;
  1287. var o=nil;
  1288. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1289. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq", [smalltalk.send((smalltalk.Object || Object), "_new", [])])]);
  1290. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [o])]);
  1291. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq", [o])]);
  1292. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq", [smalltalk.send(o, "_yourself", [])])]);
  1293. return self;},
  1294. args: [],
  1295. 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",
  1296. messageSends: ["new", "deny:", "=", "assert:", "yourself"],
  1297. referencedClasses: ["Object"]
  1298. }),
  1299. smalltalk.ObjectTest);
  1300. smalltalk.addMethod(
  1301. "_testHalt",
  1302. smalltalk.method({
  1303. selector: "testHalt",
  1304. category: 'tests',
  1305. fn: function (){
  1306. var self=this;
  1307. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_halt", []);}), (smalltalk.Error || Error)]);
  1308. return self;},
  1309. args: [],
  1310. source: "testHalt\x0a\x09self should: [Object new halt] raise: Error",
  1311. messageSends: ["should:raise:", "halt", "new"],
  1312. referencedClasses: ["Object", "Error"]
  1313. }),
  1314. smalltalk.ObjectTest);
  1315. smalltalk.addMethod(
  1316. "_testIdentity",
  1317. smalltalk.method({
  1318. selector: "testIdentity",
  1319. category: 'tests',
  1320. fn: function (){
  1321. var self=this;
  1322. var o=nil;
  1323. (o=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1324. smalltalk.send(self, "_deny_", [smalltalk.send(o, "__eq_eq", [smalltalk.send((smalltalk.Object || Object), "_new", [])])]);
  1325. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq_eq", [o])]);
  1326. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq_eq", [o])]);
  1327. smalltalk.send(self, "_assert_", [smalltalk.send(o, "__eq_eq", [smalltalk.send(o, "_yourself", [])])]);
  1328. return self;},
  1329. args: [],
  1330. 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",
  1331. messageSends: ["new", "deny:", "==", "assert:", "yourself"],
  1332. referencedClasses: ["Object"]
  1333. }),
  1334. smalltalk.ObjectTest);
  1335. smalltalk.addMethod(
  1336. "_testIfNil",
  1337. smalltalk.method({
  1338. selector: "testIfNil",
  1339. category: 'tests',
  1340. fn: function (){
  1341. var self=this;
  1342. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_isNil", [])]);
  1343. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return true;})() : $receiver, "__eq", [true])]);
  1344. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) != nil && $receiver != undefined) ? (function(){return true;})() : nil, "__eq", [true])]);
  1345. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  1346. smalltalk.send(self, "_assert_", [smalltalk.send((($receiver = smalltalk.send((smalltalk.Object || Object), "_new", [])) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  1347. return self;},
  1348. args: [],
  1349. 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",
  1350. messageSends: ["deny:", "isNil", "new", "=", "ifNil:", "assert:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  1351. referencedClasses: ["Object"]
  1352. }),
  1353. smalltalk.ObjectTest);
  1354. smalltalk.addMethod(
  1355. "_testInstVars",
  1356. smalltalk.method({
  1357. selector: "testInstVars",
  1358. category: 'tests',
  1359. fn: function (){
  1360. var self=this;
  1361. var o=nil;
  1362. (o=smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_new", []));
  1363. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), nil]);
  1364. smalltalk.send(o, "_instVarAt_put_", [smalltalk.symbolFor("foo"), (1)]);
  1365. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", [smalltalk.symbolFor("foo")]), (1)]);
  1366. smalltalk.send(self, "_assert_equals_", [smalltalk.send(o, "_instVarAt_", ["foo"]), (1)]);
  1367. return self;},
  1368. args: [],
  1369. 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",
  1370. messageSends: ["new", "assert:equals:", "instVarAt:", "instVarAt:put:"],
  1371. referencedClasses: ["ObjectMock"]
  1372. }),
  1373. smalltalk.ObjectTest);
  1374. smalltalk.addMethod(
  1375. "_testNilUndefined",
  1376. smalltalk.method({
  1377. selector: "testNilUndefined",
  1378. category: 'tests',
  1379. fn: function (){
  1380. var self=this;
  1381. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "__eq", [(typeof undefined == 'undefined' ? nil : undefined)])]);
  1382. return self;},
  1383. args: [],
  1384. source: "testNilUndefined\x0a\x09\x22nil in Smalltalk is the undefined object in JS\x22\x0a\x0a\x09self assert: nil = undefined",
  1385. messageSends: ["assert:", "="],
  1386. referencedClasses: []
  1387. }),
  1388. smalltalk.ObjectTest);
  1389. smalltalk.addMethod(
  1390. "_testYourself",
  1391. smalltalk.method({
  1392. selector: "testYourself",
  1393. category: 'tests',
  1394. fn: function (){
  1395. var self=this;
  1396. var o=nil;
  1397. (o=smalltalk.send((smalltalk.ObjectMock || ObjectMock), "_new", []));
  1398. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o, "_yourself", []), "__eq_eq", [o])]);
  1399. return self;},
  1400. args: [],
  1401. source: "testYourself\x0a\x09| o |\x0a\x09o := ObjectMock new.\x0a\x09self assert: o yourself == o",
  1402. messageSends: ["new", "assert:", "==", "yourself"],
  1403. referencedClasses: ["ObjectMock"]
  1404. }),
  1405. smalltalk.ObjectTest);
  1406. smalltalk.addMethod(
  1407. "_testidentityHash",
  1408. smalltalk.method({
  1409. selector: "testidentityHash",
  1410. category: 'tests',
  1411. fn: function (){
  1412. var self=this;
  1413. var o1=nil;
  1414. var o2=nil;
  1415. (o1=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1416. (o2=smalltalk.send((smalltalk.Object || Object), "_new", []));
  1417. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o1, "_identityHash", [])])]);
  1418. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(o1, "_identityHash", []), "__eq_eq", [smalltalk.send(o2, "_identityHash", [])])]);
  1419. return self;},
  1420. args: [],
  1421. 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",
  1422. messageSends: ["new", "assert:", "==", "identityHash", "deny:"],
  1423. referencedClasses: ["Object"]
  1424. }),
  1425. smalltalk.ObjectTest);
  1426. smalltalk.addClass('PackageTest', smalltalk.TestCase, ['zorkPackage', 'grulPackage', 'backUpCommitPathJs', 'backUpCommitPathSt'], 'Kernel-Tests');
  1427. smalltalk.addMethod(
  1428. "_setUp",
  1429. smalltalk.method({
  1430. selector: "setUp",
  1431. category: 'running',
  1432. fn: function (){
  1433. var self=this;
  1434. (self['@backUpCommitPathJs']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathJs", []));
  1435. (self['@backUpCommitPathSt']=smalltalk.send((smalltalk.Package || Package), "_defaultCommitPathSt", []));
  1436. smalltalk.send((smalltalk.Package || Package), "_resetCommitPaths", []);
  1437. (self['@zorkPackage']=smalltalk.send(smalltalk.send((smalltalk.Package || Package), "_new", []), "_name_", ["Zork"]));
  1438. (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", [])));
  1439. return self;},
  1440. args: [],
  1441. 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",
  1442. messageSends: ["defaultCommitPathJs", "defaultCommitPathSt", "resetCommitPaths", "name:", "new", "commitPathJs:", "commitPathSt:", "yourself"],
  1443. referencedClasses: ["Package"]
  1444. }),
  1445. smalltalk.PackageTest);
  1446. smalltalk.addMethod(
  1447. "_tearDown",
  1448. smalltalk.method({
  1449. selector: "tearDown",
  1450. category: 'running',
  1451. fn: function (){
  1452. var self=this;
  1453. (function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", [self['@backUpCommitPathJs']]);return smalltalk.send($rec, "_defaultCommitPathSt_", [self['@backUpCommitPathSt']]);})((smalltalk.Package || Package));
  1454. return self;},
  1455. args: [],
  1456. source: "tearDown\x0a\x09 Package \x0a\x09\x09defaultCommitPathJs: backUpCommitPathJs;\x0a\x09\x09defaultCommitPathSt: backUpCommitPathSt",
  1457. messageSends: ["defaultCommitPathJs:", "defaultCommitPathSt:"],
  1458. referencedClasses: ["Package"]
  1459. }),
  1460. smalltalk.PackageTest);
  1461. smalltalk.addMethod(
  1462. "_testGrulCommitPathJsShouldBeServerGrulJs",
  1463. smalltalk.method({
  1464. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  1465. category: 'tests',
  1466. fn: function (){
  1467. var self=this;
  1468. smalltalk.send(self, "_assert_equals_", ["server/grul/js", smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  1469. return self;},
  1470. args: [],
  1471. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  1472. messageSends: ["assert:equals:", "commitPathJs"],
  1473. referencedClasses: []
  1474. }),
  1475. smalltalk.PackageTest);
  1476. smalltalk.addMethod(
  1477. "_testGrulCommitPathStShouldBeGrulSt",
  1478. smalltalk.method({
  1479. selector: "testGrulCommitPathStShouldBeGrulSt",
  1480. category: 'tests',
  1481. fn: function (){
  1482. var self=this;
  1483. smalltalk.send(self, "_assert_equals_", ["grul/st", smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  1484. return self;},
  1485. args: [],
  1486. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  1487. messageSends: ["assert:equals:", "commitPathSt"],
  1488. referencedClasses: []
  1489. }),
  1490. smalltalk.PackageTest);
  1491. smalltalk.addMethod(
  1492. "_testZorkCommitPathJsShouldBeJs",
  1493. smalltalk.method({
  1494. selector: "testZorkCommitPathJsShouldBeJs",
  1495. category: 'tests',
  1496. fn: function (){
  1497. var self=this;
  1498. smalltalk.send(self, "_assert_equals_", ["js", smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  1499. return self;},
  1500. args: [],
  1501. source: "testZorkCommitPathJsShouldBeJs\x0a\x09self assert: 'js' equals: zorkPackage commitPathJs",
  1502. messageSends: ["assert:equals:", "commitPathJs"],
  1503. referencedClasses: []
  1504. }),
  1505. smalltalk.PackageTest);
  1506. smalltalk.addMethod(
  1507. "_testZorkCommitPathStShouldBeSt",
  1508. smalltalk.method({
  1509. selector: "testZorkCommitPathStShouldBeSt",
  1510. category: 'tests',
  1511. fn: function (){
  1512. var self=this;
  1513. smalltalk.send(self, "_assert_equals_", ["st", smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  1514. return self;},
  1515. args: [],
  1516. source: "testZorkCommitPathStShouldBeSt\x0a\x09self assert: 'st' equals: zorkPackage commitPathSt",
  1517. messageSends: ["assert:equals:", "commitPathSt"],
  1518. referencedClasses: []
  1519. }),
  1520. smalltalk.PackageTest);
  1521. smalltalk.addClass('PackageWithDefaultCommitPathChangedTest', smalltalk.PackageTest, [], 'Kernel-Tests');
  1522. smalltalk.addMethod(
  1523. "_setUp",
  1524. smalltalk.method({
  1525. selector: "setUp",
  1526. category: 'running',
  1527. fn: function (){
  1528. var self=this;
  1529. smalltalk.send(self, "_setUp", [], smalltalk.PackageWithDefaultCommitPathChangedTest.superclass || nil);
  1530. (function($rec){smalltalk.send($rec, "_defaultCommitPathJs_", ["javascripts/"]);return smalltalk.send($rec, "_defaultCommitPathSt_", ["smalltalk/"]);})((smalltalk.Package || Package));
  1531. return self;},
  1532. args: [],
  1533. source: "setUp\x0a\x09super setUp.\x0a\x0a\x09Package\x0a\x09\x09defaultCommitPathJs: 'javascripts/';\x0a\x09\x09defaultCommitPathSt: 'smalltalk/'.",
  1534. messageSends: ["setUp", "defaultCommitPathJs:", "defaultCommitPathSt:"],
  1535. referencedClasses: ["Package"]
  1536. }),
  1537. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1538. smalltalk.addMethod(
  1539. "_testGrulCommitPathJsShouldBeServerGrulJs",
  1540. smalltalk.method({
  1541. selector: "testGrulCommitPathJsShouldBeServerGrulJs",
  1542. category: 'tests',
  1543. fn: function (){
  1544. var self=this;
  1545. smalltalk.send(self, "_assert_equals_", ["server/grul/js", smalltalk.send(self['@grulPackage'], "_commitPathJs", [])]);
  1546. return self;},
  1547. args: [],
  1548. source: "testGrulCommitPathJsShouldBeServerGrulJs\x0a\x09self assert: 'server/grul/js' equals: grulPackage commitPathJs",
  1549. messageSends: ["assert:equals:", "commitPathJs"],
  1550. referencedClasses: []
  1551. }),
  1552. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1553. smalltalk.addMethod(
  1554. "_testGrulCommitPathStShouldBeGrulSt",
  1555. smalltalk.method({
  1556. selector: "testGrulCommitPathStShouldBeGrulSt",
  1557. category: 'tests',
  1558. fn: function (){
  1559. var self=this;
  1560. smalltalk.send(self, "_assert_equals_", ["grul/st", smalltalk.send(self['@grulPackage'], "_commitPathSt", [])]);
  1561. return self;},
  1562. args: [],
  1563. source: "testGrulCommitPathStShouldBeGrulSt\x0a\x09self assert: 'grul/st' equals: grulPackage commitPathSt",
  1564. messageSends: ["assert:equals:", "commitPathSt"],
  1565. referencedClasses: []
  1566. }),
  1567. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1568. smalltalk.addMethod(
  1569. "_testZorkCommitPathJsShouldBeJavascript",
  1570. smalltalk.method({
  1571. selector: "testZorkCommitPathJsShouldBeJavascript",
  1572. category: 'tests',
  1573. fn: function (){
  1574. var self=this;
  1575. smalltalk.send(self, "_assert_equals_", ["javascripts/", smalltalk.send(self['@zorkPackage'], "_commitPathJs", [])]);
  1576. return self;},
  1577. args: [],
  1578. source: "testZorkCommitPathJsShouldBeJavascript\x0a\x09self assert: 'javascripts/' equals: zorkPackage commitPathJs",
  1579. messageSends: ["assert:equals:", "commitPathJs"],
  1580. referencedClasses: []
  1581. }),
  1582. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1583. smalltalk.addMethod(
  1584. "_testZorkCommitPathStShouldBeSmalltalk",
  1585. smalltalk.method({
  1586. selector: "testZorkCommitPathStShouldBeSmalltalk",
  1587. category: 'tests',
  1588. fn: function (){
  1589. var self=this;
  1590. smalltalk.send(self, "_assert_equals_", ["smalltalk/", smalltalk.send(self['@zorkPackage'], "_commitPathSt", [])]);
  1591. return self;},
  1592. args: [],
  1593. source: "testZorkCommitPathStShouldBeSmalltalk\x0a\x09self assert: 'smalltalk/' equals: zorkPackage commitPathSt",
  1594. messageSends: ["assert:equals:", "commitPathSt"],
  1595. referencedClasses: []
  1596. }),
  1597. smalltalk.PackageWithDefaultCommitPathChangedTest);
  1598. smalltalk.addMethod(
  1599. "_shouldInheritSelectors",
  1600. smalltalk.method({
  1601. selector: "shouldInheritSelectors",
  1602. category: 'accessing',
  1603. fn: function (){
  1604. var self=this;
  1605. return false;
  1606. return self;},
  1607. args: [],
  1608. source: "shouldInheritSelectors\x0a\x09^ false",
  1609. messageSends: [],
  1610. referencedClasses: []
  1611. }),
  1612. smalltalk.PackageWithDefaultCommitPathChangedTest.klass);
  1613. smalltalk.addClass('PointTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1614. smalltalk.addMethod(
  1615. "_testAccessing",
  1616. smalltalk.method({
  1617. selector: "testAccessing",
  1618. category: 'tests',
  1619. fn: function (){
  1620. var self=this;
  1621. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)]), "_x", []), (3)]);
  1622. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)]), "_y", []), (4)]);
  1623. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_new", []), "_x_", [(3)]), "_x", []), (3)]);
  1624. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Point || Point), "_new", []), "_y_", [(4)]), "_y", []), (4)]);
  1625. return self;},
  1626. args: [],
  1627. 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",
  1628. messageSends: ["assert:equals:", "x", "x:y:", "y", "x:", "new", "y:"],
  1629. referencedClasses: ["Point"]
  1630. }),
  1631. smalltalk.PointTest);
  1632. smalltalk.addMethod(
  1633. "_testArithmetic",
  1634. smalltalk.method({
  1635. selector: "testArithmetic",
  1636. category: 'tests',
  1637. fn: function (){
  1638. var self=this;
  1639. 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)])]);
  1640. 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)])]);
  1641. 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)])]);
  1642. 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)])]);
  1643. return self;},
  1644. args: [],
  1645. 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)",
  1646. messageSends: ["assert:equals:", "*", "@", "x:y:", "+", "-", "/"],
  1647. referencedClasses: ["Point"]
  1648. }),
  1649. smalltalk.PointTest);
  1650. smalltalk.addMethod(
  1651. "_testAt",
  1652. smalltalk.method({
  1653. selector: "testAt",
  1654. category: 'tests',
  1655. fn: function (){
  1656. var self=this;
  1657. smalltalk.send(self, "_assert_equals_", [smalltalk.send((3), "__at", [(4)]), smalltalk.send((smalltalk.Point || Point), "_x_y_", [(3), (4)])]);
  1658. return self;},
  1659. args: [],
  1660. source: "testAt\x0a\x09self assert: 3@4 equals: (Point x: 3 y: 4)",
  1661. messageSends: ["assert:equals:", "@", "x:y:"],
  1662. referencedClasses: ["Point"]
  1663. }),
  1664. smalltalk.PointTest);
  1665. smalltalk.addMethod(
  1666. "_testEgality",
  1667. smalltalk.method({
  1668. selector: "testEgality",
  1669. category: 'tests',
  1670. fn: function (){
  1671. var self=this;
  1672. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((3), "__at", [(4)]), "__eq", [smalltalk.send((3), "__at", [(4)])])]);
  1673. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send((3), "__at", [(5)]), "__eq", [smalltalk.send((3), "__at", [(6)])])]);
  1674. return self;},
  1675. args: [],
  1676. source: "testEgality\x0a\x09self assert: 3@4 = (3@4).\x0a\x09self deny: 3@5 = (3@6)",
  1677. messageSends: ["assert:", "=", "@", "deny:"],
  1678. referencedClasses: []
  1679. }),
  1680. smalltalk.PointTest);
  1681. smalltalk.addMethod(
  1682. "_testTranslateBy",
  1683. smalltalk.method({
  1684. selector: "testTranslateBy",
  1685. category: 'tests',
  1686. fn: function (){
  1687. var self=this;
  1688. smalltalk.send(self, "_assert_equals_", [smalltalk.send((3), "__at", [(4)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send((0), "__at", [(1)])])]);
  1689. 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", [])])])]);
  1690. smalltalk.send(self, "_assert_equals_", [smalltalk.send((5), "__at", [(6)]), smalltalk.send(smalltalk.send((3), "__at", [(3)]), "_translateBy_", [smalltalk.send((2), "__at", [(3)])])]);
  1691. 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)])])]);
  1692. return self;},
  1693. args: [],
  1694. 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).",
  1695. messageSends: ["assert:equals:", "@", "translateBy:", "negated"],
  1696. referencedClasses: []
  1697. }),
  1698. smalltalk.PointTest);
  1699. smalltalk.addClass('RandomTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1700. smalltalk.addMethod(
  1701. "_textNext",
  1702. smalltalk.method({
  1703. selector: "textNext",
  1704. category: 'tests',
  1705. fn: function (){
  1706. var self=this;
  1707. smalltalk.send((10000), "_timesRepeat_", [(function(){var current=nil;
  1708. var next=nil;
  1709. (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]);})]);
  1710. return self;},
  1711. args: [],
  1712. 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]",
  1713. messageSends: ["timesRepeat:", "next", "new", "assert:", ">=", "<", "deny:", "="],
  1714. referencedClasses: ["Random"]
  1715. }),
  1716. smalltalk.RandomTest);
  1717. smalltalk.addClass('SetTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1718. smalltalk.addMethod(
  1719. "_testAddRemove",
  1720. smalltalk.method({
  1721. selector: "testAddRemove",
  1722. category: 'tests',
  1723. fn: function (){
  1724. var self=this;
  1725. var set=nil;
  1726. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  1727. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_isEmpty", [])]);
  1728. smalltalk.send(set, "_add_", [(3)]);
  1729. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [(3)])]);
  1730. smalltalk.send(set, "_add_", [(5)]);
  1731. smalltalk.send(self, "_assert_", [smalltalk.send(set, "_includes_", [(5)])]);
  1732. smalltalk.send(set, "_remove_", [(3)]);
  1733. smalltalk.send(self, "_deny_", [smalltalk.send(set, "_includes_", [(3)])]);
  1734. return self;},
  1735. args: [],
  1736. 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)",
  1737. messageSends: ["new", "assert:", "isEmpty", "add:", "includes:", "remove:", "deny:"],
  1738. referencedClasses: ["Set"]
  1739. }),
  1740. smalltalk.SetTest);
  1741. smalltalk.addMethod(
  1742. "_testAt",
  1743. smalltalk.method({
  1744. selector: "testAt",
  1745. category: 'tests',
  1746. fn: function (){
  1747. var self=this;
  1748. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_new", []), "_at_put_", [(1), (2)]);}), (smalltalk.Error || Error)]);
  1749. return self;},
  1750. args: [],
  1751. source: "testAt\x0a\x09self should: [Set new at: 1 put: 2] raise: Error",
  1752. messageSends: ["should:raise:", "at:put:", "new"],
  1753. referencedClasses: ["Set", "Error"]
  1754. }),
  1755. smalltalk.SetTest);
  1756. smalltalk.addMethod(
  1757. "_testPrintString",
  1758. smalltalk.method({
  1759. selector: "testPrintString",
  1760. category: 'tests',
  1761. fn: function (){
  1762. var self=this;
  1763. var set=nil;
  1764. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  1765. smalltalk.send(self, "_assert_equals_", ["a Set ()", smalltalk.send(set, "_printString", [])]);
  1766. (function($rec){smalltalk.send($rec, "_add_", [(1)]);return smalltalk.send($rec, "_add_", [(3)]);})(set);
  1767. smalltalk.send(self, "_assert_equals_", ["a Set (1 3)", smalltalk.send(set, "_printString", [])]);
  1768. smalltalk.send(set, "_add_", ["foo"]);
  1769. smalltalk.send(self, "_assert_equals_", ["a Set (1 3 'foo')", smalltalk.send(set, "_printString", [])]);
  1770. (function($rec){smalltalk.send($rec, "_remove_", [(1)]);return smalltalk.send($rec, "_remove_", [(3)]);})(set);
  1771. smalltalk.send(self, "_assert_equals_", ["a Set ('foo')", smalltalk.send(set, "_printString", [])]);
  1772. smalltalk.send(set, "_add_", [(3)]);
  1773. smalltalk.send(self, "_assert_equals_", ["a Set ('foo' 3)", smalltalk.send(set, "_printString", [])]);
  1774. smalltalk.send(set, "_add_", [(3)]);
  1775. smalltalk.send(self, "_assert_equals_", ["a Set ('foo' 3)", smalltalk.send(set, "_printString", [])]);
  1776. return self;},
  1777. args: [],
  1778. 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 ).",
  1779. messageSends: ["new", "assert:equals:", "printString", "add:", "remove:"],
  1780. referencedClasses: ["Set"]
  1781. }),
  1782. smalltalk.SetTest);
  1783. smalltalk.addMethod(
  1784. "_testSize",
  1785. smalltalk.method({
  1786. selector: "testSize",
  1787. category: 'tests',
  1788. fn: function (){
  1789. var self=this;
  1790. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_new", []), "_size", []), (0)]);
  1791. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_withAll_", [[(1), (2), (3), (4)]]), "_size", []), (4)]);
  1792. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send((smalltalk.Set || Set), "_withAll_", [[(1), (1), (1), (1)]]), "_size", []), (1)]);
  1793. return self;},
  1794. args: [],
  1795. 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",
  1796. messageSends: ["assert:equals:", "size", "new", "withAll:"],
  1797. referencedClasses: ["Set"]
  1798. }),
  1799. smalltalk.SetTest);
  1800. smalltalk.addMethod(
  1801. "_testUnicity",
  1802. smalltalk.method({
  1803. selector: "testUnicity",
  1804. category: 'tests',
  1805. fn: function (){
  1806. var self=this;
  1807. var set=nil;
  1808. (set=smalltalk.send((smalltalk.Set || Set), "_new", []));
  1809. smalltalk.send(set, "_add_", [(21)]);
  1810. smalltalk.send(set, "_add_", ["hello"]);
  1811. smalltalk.send(set, "_add_", [(21)]);
  1812. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [(2)])]);
  1813. smalltalk.send(set, "_add_", ["hello"]);
  1814. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(set, "_size", []), "__eq", [(2)])]);
  1815. smalltalk.send(self, "_assert_equals_", [smalltalk.send(set, "_asArray", []), [(21), "hello"]]);
  1816. return self;},
  1817. args: [],
  1818. 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')",
  1819. messageSends: ["new", "add:", "assert:", "=", "size", "assert:equals:", "asArray"],
  1820. referencedClasses: ["Set"]
  1821. }),
  1822. smalltalk.SetTest);
  1823. smalltalk.addClass('StringTest', smalltalk.TestCase, [], 'Kernel-Tests');
  1824. smalltalk.addMethod(
  1825. "_testAddRemove",
  1826. smalltalk.method({
  1827. selector: "testAddRemove",
  1828. category: 'tests',
  1829. fn: function (){
  1830. var self=this;
  1831. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_add_", ["a"]);}), (smalltalk.Error || Error)]);
  1832. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_remove_", ["h"]);}), (smalltalk.Error || Error)]);
  1833. return self;},
  1834. args: [],
  1835. source: "testAddRemove\x0a\x09self should: ['hello' add: 'a'] raise: Error.\x0a\x09self should: ['hello' remove: 'h'] raise: Error",
  1836. messageSends: ["should:raise:", "add:", "remove:"],
  1837. referencedClasses: ["Error"]
  1838. }),
  1839. smalltalk.StringTest);
  1840. smalltalk.addMethod(
  1841. "_testAsArray",
  1842. smalltalk.method({
  1843. selector: "testAsArray",
  1844. category: 'tests',
  1845. fn: function (){
  1846. var self=this;
  1847. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_asArray", []), "__eq", [["h", "e", "l", "l", "o"]])]);
  1848. return self;},
  1849. args: [],
  1850. source: "testAsArray\x0a\x09self assert: 'hello' asArray = #('h' 'e' 'l' 'l' 'o').",
  1851. messageSends: ["assert:", "=", "asArray"],
  1852. referencedClasses: []
  1853. }),
  1854. smalltalk.StringTest);
  1855. smalltalk.addMethod(
  1856. "_testAt",
  1857. smalltalk.method({
  1858. selector: "testAt",
  1859. category: 'tests',
  1860. fn: function (){
  1861. var self=this;
  1862. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_", [(1)]), "__eq", ["h"])]);
  1863. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_", [(5)]), "__eq", ["o"])]);
  1864. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_at_ifAbsent_", [(6), (function(){return nil;})]), "__eq", [nil])]);
  1865. return self;},
  1866. args: [],
  1867. 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",
  1868. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  1869. referencedClasses: []
  1870. }),
  1871. smalltalk.StringTest);
  1872. smalltalk.addMethod(
  1873. "_testAtPut",
  1874. smalltalk.method({
  1875. selector: "testAtPut",
  1876. category: 'tests',
  1877. fn: function (){
  1878. var self=this;
  1879. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_at_put_", [(1), "a"]);}), (smalltalk.Error || Error)]);
  1880. return self;},
  1881. args: [],
  1882. source: "testAtPut\x0a\x09\x22String instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  1883. messageSends: ["should:raise:", "at:put:"],
  1884. referencedClasses: ["Error"]
  1885. }),
  1886. smalltalk.StringTest);
  1887. smalltalk.addMethod(
  1888. "_testCopyWithoutAll",
  1889. smalltalk.method({
  1890. selector: "testCopyWithoutAll",
  1891. category: 'tests',
  1892. fn: function (){
  1893. var self=this;
  1894. smalltalk.send(self, "_assert_equals_", ["hello world", smalltalk.send("*hello* *world*", "_copyWithoutAll_", ["*"])]);
  1895. return self;},
  1896. args: [],
  1897. source: "testCopyWithoutAll\x0a\x09self \x0a\x09\x09assert: 'hello world' \x0a\x09\x09equals: ('*hello* *world*' copyWithoutAll: '*')",
  1898. messageSends: ["assert:equals:", "copyWithoutAll:"],
  1899. referencedClasses: []
  1900. }),
  1901. smalltalk.StringTest);
  1902. smalltalk.addMethod(
  1903. "_testEquality",
  1904. smalltalk.method({
  1905. selector: "testEquality",
  1906. category: 'tests',
  1907. fn: function (){
  1908. var self=this;
  1909. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", ["hello"])]);
  1910. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq", ["world"])]);
  1911. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq", [smalltalk.send("hello", "_yourself", [])])]);
  1912. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_yourself", []), "__eq", ["hello"])]);
  1913. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq", [(0)])]);
  1914. return self;},
  1915. args: [],
  1916. 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",
  1917. messageSends: ["assert:", "=", "deny:", "yourself"],
  1918. referencedClasses: []
  1919. }),
  1920. smalltalk.StringTest);
  1921. smalltalk.addMethod(
  1922. "_testIdentity",
  1923. smalltalk.method({
  1924. selector: "testIdentity",
  1925. category: 'tests',
  1926. fn: function (){
  1927. var self=this;
  1928. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq_eq", ["hello"])]);
  1929. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq_eq", ["world"])]);
  1930. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "__eq_eq", [smalltalk.send("hello", "_yourself", [])])]);
  1931. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send("hello", "_yourself", []), "__eq_eq", ["hello"])]);
  1932. smalltalk.send(self, "_deny_", [smalltalk.send("", "__eq_eq", [(0)])]);
  1933. return self;},
  1934. args: [],
  1935. 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",
  1936. messageSends: ["assert:", "==", "deny:", "yourself"],
  1937. referencedClasses: []
  1938. }),
  1939. smalltalk.StringTest);
  1940. smalltalk.addMethod(
  1941. "_testIncludesSubString",
  1942. smalltalk.method({
  1943. selector: "testIncludesSubString",
  1944. category: 'tests',
  1945. fn: function (){
  1946. var self=this;
  1947. smalltalk.send(self, "_assert_", [smalltalk.send("amber", "_includesSubString_", ["ber"])]);
  1948. smalltalk.send(self, "_deny_", [smalltalk.send("amber", "_includesSubString_", ["zork"])]);
  1949. return self;},
  1950. args: [],
  1951. source: "testIncludesSubString\x0a\x09self assert: ('amber' includesSubString: 'ber').\x0a\x09self deny: ('amber' includesSubString: 'zork').",
  1952. messageSends: ["assert:", "includesSubString:", "deny:"],
  1953. referencedClasses: []
  1954. }),
  1955. smalltalk.StringTest);
  1956. smalltalk.addMethod(
  1957. "_testJoin",
  1958. smalltalk.method({
  1959. selector: "testJoin",
  1960. category: 'tests',
  1961. fn: function (){
  1962. var self=this;
  1963. smalltalk.send(self, "_assert_equals_", ["hello,world", smalltalk.send(",", "_join_", [["hello", "world"]])]);
  1964. return self;},
  1965. args: [],
  1966. source: "testJoin\x0a\x09self assert: 'hello,world' equals: (',' join: #('hello' 'world'))",
  1967. messageSends: ["assert:equals:", "join:"],
  1968. referencedClasses: []
  1969. }),
  1970. smalltalk.StringTest);
  1971. smalltalk.addMethod(
  1972. "_testPrintString",
  1973. smalltalk.method({
  1974. selector: "testPrintString",
  1975. category: 'tests',
  1976. fn: function (){
  1977. var self=this;
  1978. smalltalk.send(self, "_assert_equals_", ["'test_string'", smalltalk.send("test_string", "_printString", [])]);
  1979. return self;},
  1980. args: [],
  1981. source: "testPrintString\x0a\x0a\x09self assert: '''test_string''' equals: 'test_string' printString.",
  1982. messageSends: ["assert:equals:", "printString"],
  1983. referencedClasses: []
  1984. }),
  1985. smalltalk.StringTest);
  1986. smalltalk.addMethod(
  1987. "_testSize",
  1988. smalltalk.method({
  1989. selector: "testSize",
  1990. category: 'tests',
  1991. fn: function (){
  1992. var self=this;
  1993. smalltalk.send(self, "_assert_equals_", [smalltalk.send("smalltalk", "_size", []), (9)]);
  1994. smalltalk.send(self, "_assert_equals_", [smalltalk.send("", "_size", []), (0)]);
  1995. return self;},
  1996. args: [],
  1997. source: "testSize\x0a\x09self assert: 'smalltalk' size equals: 9.\x0a\x09self assert: '' size equals: 0",
  1998. messageSends: ["assert:equals:", "size"],
  1999. referencedClasses: []
  2000. }),
  2001. smalltalk.StringTest);
  2002. smalltalk.addMethod(
  2003. "_testStreamContents",
  2004. smalltalk.method({
  2005. selector: "testStreamContents",
  2006. category: 'tests',
  2007. fn: function (){
  2008. var self=this;
  2009. 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);})])]);
  2010. return self;},
  2011. args: [],
  2012. 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'])",
  2013. messageSends: ["assert:equals:", "streamContents:", "nextPutAll:", "space"],
  2014. referencedClasses: ["String"]
  2015. }),
  2016. smalltalk.StringTest);
  2017. smalltalk.addClass('SymbolTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2018. smalltalk.addMethod(
  2019. "_testAsString",
  2020. smalltalk.method({
  2021. selector: "testAsString",
  2022. category: 'tests',
  2023. fn: function (){
  2024. var self=this;
  2025. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("hello"), "_asString", []), "hello"]);
  2026. return self;},
  2027. args: [],
  2028. source: "testAsString\x0a\x09self assert: #hello asString equals: 'hello'",
  2029. messageSends: ["assert:equals:", "asString"],
  2030. referencedClasses: []
  2031. }),
  2032. smalltalk.SymbolTest);
  2033. smalltalk.addMethod(
  2034. "_testAsSymbol",
  2035. smalltalk.method({
  2036. selector: "testAsSymbol",
  2037. category: 'tests',
  2038. fn: function (){
  2039. var self=this;
  2040. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_asSymbol", [])])]);
  2041. return self;},
  2042. args: [],
  2043. source: "testAsSymbol\x0a\x09self assert: #hello == #hello asSymbol",
  2044. messageSends: ["assert:", "==", "asSymbol"],
  2045. referencedClasses: []
  2046. }),
  2047. smalltalk.SymbolTest);
  2048. smalltalk.addMethod(
  2049. "_testAt",
  2050. smalltalk.method({
  2051. selector: "testAt",
  2052. category: 'tests',
  2053. fn: function (){
  2054. var self=this;
  2055. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_", [(1)]), "__eq", ["h"])]);
  2056. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_", [(5)]), "__eq", ["o"])]);
  2057. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_at_ifAbsent_", [(6), (function(){return nil;})]), "__eq", [nil])]);
  2058. return self;},
  2059. args: [],
  2060. 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",
  2061. messageSends: ["assert:", "=", "at:", "at:ifAbsent:"],
  2062. referencedClasses: []
  2063. }),
  2064. smalltalk.SymbolTest);
  2065. smalltalk.addMethod(
  2066. "_testAtPut",
  2067. smalltalk.method({
  2068. selector: "testAtPut",
  2069. category: 'tests',
  2070. fn: function (){
  2071. var self=this;
  2072. smalltalk.send(self, "_should_raise_", [(function(){return smalltalk.send("hello", "_at_put_", [(1), "a"]);}), (smalltalk.Error || Error)]);
  2073. return self;},
  2074. args: [],
  2075. source: "testAtPut\x0a\x09\x22Symbol instances are read-only\x22\x0a\x09self should: ['hello' at: 1 put: 'a'] raise: Error",
  2076. messageSends: ["should:raise:", "at:put:"],
  2077. referencedClasses: ["Error"]
  2078. }),
  2079. smalltalk.SymbolTest);
  2080. smalltalk.addMethod(
  2081. "_testComparing",
  2082. smalltalk.method({
  2083. selector: "testComparing",
  2084. category: 'tests',
  2085. fn: function (){
  2086. var self=this;
  2087. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >smalltalk.symbolFor("aa") : smalltalk.send($receiver, "__gt", [smalltalk.symbolFor("aa")]))]);
  2088. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__gt", [smalltalk.symbolFor("ba")]))]);
  2089. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver <smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt", [smalltalk.symbolFor("ba")]))]);
  2090. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("bb")).klass === smalltalk.Number) ? $receiver <smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt", [smalltalk.symbolFor("ba")]))]);
  2091. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >=smalltalk.symbolFor("aa") : smalltalk.send($receiver, "__gt_eq", [smalltalk.symbolFor("aa")]))]);
  2092. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver >=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__gt_eq", [smalltalk.symbolFor("ba")]))]);
  2093. smalltalk.send(self, "_assert_", [((($receiver = smalltalk.symbolFor("ab")).klass === smalltalk.Number) ? $receiver <=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt_eq", [smalltalk.symbolFor("ba")]))]);
  2094. smalltalk.send(self, "_deny_", [((($receiver = smalltalk.symbolFor("bb")).klass === smalltalk.Number) ? $receiver <=smalltalk.symbolFor("ba") : smalltalk.send($receiver, "__lt_eq", [smalltalk.symbolFor("ba")]))]);
  2095. return self;},
  2096. args: [],
  2097. 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",
  2098. messageSends: ["assert:", ">", "deny:", "<", ">=", "<="],
  2099. referencedClasses: []
  2100. }),
  2101. smalltalk.SymbolTest);
  2102. smalltalk.addMethod(
  2103. "_testCopying",
  2104. smalltalk.method({
  2105. selector: "testCopying",
  2106. category: 'tests',
  2107. fn: function (){
  2108. var self=this;
  2109. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_copy", []), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  2110. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_deepCopy", []), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  2111. return self;},
  2112. args: [],
  2113. source: "testCopying\x0a\x09self assert: #hello copy == #hello.\x0a\x09self assert: #hello deepCopy == #hello",
  2114. messageSends: ["assert:", "==", "copy", "deepCopy"],
  2115. referencedClasses: []
  2116. }),
  2117. smalltalk.SymbolTest);
  2118. smalltalk.addMethod(
  2119. "_testEquality",
  2120. smalltalk.method({
  2121. selector: "testEquality",
  2122. category: 'tests',
  2123. fn: function (){
  2124. var self=this;
  2125. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.symbolFor("hello")])]);
  2126. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.symbolFor("world")])]);
  2127. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", [])])]);
  2128. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", []), "__eq", [smalltalk.symbolFor("hello")])]);
  2129. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", ["hello"])]);
  2130. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "__eq", [smalltalk.symbolFor("hello")])]);
  2131. return self;},
  2132. args: [],
  2133. 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.",
  2134. messageSends: ["assert:", "=", "deny:", "yourself"],
  2135. referencedClasses: []
  2136. }),
  2137. smalltalk.SymbolTest);
  2138. smalltalk.addMethod(
  2139. "_testIdentity",
  2140. smalltalk.method({
  2141. selector: "testIdentity",
  2142. category: 'tests',
  2143. fn: function (){
  2144. var self=this;
  2145. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.symbolFor("hello")])]);
  2146. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq_eq", [smalltalk.symbolFor("world")])]);
  2147. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "__eq", [smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", [])])]);
  2148. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_yourself", []), "__eq", [smalltalk.send(smalltalk.send(smalltalk.symbolFor("hello"), "_asString", []), "_asSymbol", [])])]);
  2149. return self;},
  2150. args: [],
  2151. 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",
  2152. messageSends: ["assert:", "==", "deny:", "=", "yourself", "asSymbol", "asString"],
  2153. referencedClasses: []
  2154. }),
  2155. smalltalk.SymbolTest);
  2156. smalltalk.addMethod(
  2157. "_testIsSymbolIsString",
  2158. smalltalk.method({
  2159. selector: "testIsSymbolIsString",
  2160. category: 'tests',
  2161. fn: function (){
  2162. var self=this;
  2163. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.symbolFor("hello"), "_isSymbol", [])]);
  2164. smalltalk.send(self, "_deny_", [smalltalk.send("hello", "_isSymbol", [])]);
  2165. smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.symbolFor("hello"), "_isString", [])]);
  2166. smalltalk.send(self, "_assert_", [smalltalk.send("hello", "_isString", [])]);
  2167. return self;},
  2168. args: [],
  2169. source: "testIsSymbolIsString\x0a\x09self assert: #hello isSymbol.\x0a\x09self deny: 'hello' isSymbol.\x0a\x09self deny: #hello isString.\x0a\x09self assert: 'hello' isString",
  2170. messageSends: ["assert:", "isSymbol", "deny:", "isString"],
  2171. referencedClasses: []
  2172. }),
  2173. smalltalk.SymbolTest);
  2174. smalltalk.addMethod(
  2175. "_testSize",
  2176. smalltalk.method({
  2177. selector: "testSize",
  2178. category: 'tests',
  2179. fn: function (){
  2180. var self=this;
  2181. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("a"), "_size", []), (1)]);
  2182. smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.symbolFor("aaaaa"), "_size", []), (5)]);
  2183. return self;},
  2184. args: [],
  2185. source: "testSize\x0a\x09self assert: #a size equals: 1.\x0a\x09self assert: #aaaaa size equals: 5",
  2186. messageSends: ["assert:equals:", "size"],
  2187. referencedClasses: []
  2188. }),
  2189. smalltalk.SymbolTest);
  2190. smalltalk.addClass('UndefinedTest', smalltalk.TestCase, [], 'Kernel-Tests');
  2191. smalltalk.addMethod(
  2192. "_testCopying",
  2193. smalltalk.method({
  2194. selector: "testCopying",
  2195. category: 'tests',
  2196. fn: function (){
  2197. var self=this;
  2198. smalltalk.send(self, "_assert_equals_", [smalltalk.send(nil, "_copy", []), nil]);
  2199. return self;},
  2200. args: [],
  2201. source: "testCopying\x0a\x09self assert: nil copy equals: nil",
  2202. messageSends: ["assert:equals:", "copy"],
  2203. referencedClasses: []
  2204. }),
  2205. smalltalk.UndefinedTest);
  2206. smalltalk.addMethod(
  2207. "_testDeepCopy",
  2208. smalltalk.method({
  2209. selector: "testDeepCopy",
  2210. category: 'tests',
  2211. fn: function (){
  2212. var self=this;
  2213. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(nil, "_deepCopy", []), "__eq", [nil])]);
  2214. return self;},
  2215. args: [],
  2216. source: "testDeepCopy\x0a\x09self assert: nil deepCopy = nil",
  2217. messageSends: ["assert:", "=", "deepCopy"],
  2218. referencedClasses: []
  2219. }),
  2220. smalltalk.UndefinedTest);
  2221. smalltalk.addMethod(
  2222. "_testIfNil",
  2223. smalltalk.method({
  2224. selector: "testIfNil",
  2225. category: 'tests',
  2226. fn: function (){
  2227. var self=this;
  2228. smalltalk.send(self, "_assert_equals_", [(($receiver = nil) == nil || $receiver == undefined) ? (function(){return true;})() : $receiver, true]);
  2229. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = nil) != nil && $receiver != undefined) ? (function(){return true;})() : nil, "__eq", [true])]);
  2230. smalltalk.send(self, "_assert_equals_", [(($receiver = nil) == nil || $receiver == undefined) ? (function(){return true;})() : (function(){return false;})(), true]);
  2231. smalltalk.send(self, "_deny_", [smalltalk.send((($receiver = nil) == nil || $receiver == undefined) ? (function(){return false;})() : (function(){return true;})(), "__eq", [true])]);
  2232. return self;},
  2233. args: [],
  2234. 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",
  2235. messageSends: ["assert:equals:", "ifNil:", "deny:", "=", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"],
  2236. referencedClasses: []
  2237. }),
  2238. smalltalk.UndefinedTest);
  2239. smalltalk.addMethod(
  2240. "_testIsNil",
  2241. smalltalk.method({
  2242. selector: "testIsNil",
  2243. category: 'tests',
  2244. fn: function (){
  2245. var self=this;
  2246. smalltalk.send(self, "_assert_", [smalltalk.send(nil, "_isNil", [])]);
  2247. smalltalk.send(self, "_deny_", [smalltalk.send(nil, "_notNil", [])]);
  2248. return self;},
  2249. args: [],
  2250. source: "testIsNil\x0a\x09self assert: nil isNil.\x0a\x09self deny: nil notNil.",
  2251. messageSends: ["assert:", "isNil", "deny:", "notNil"],
  2252. referencedClasses: []
  2253. }),
  2254. smalltalk.UndefinedTest);