Kernel-Tests.js 111 KB

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