Kernel-Tests.js 132 KB

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