1
0

Kernel-Tests.js 108 KB

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