Kernel-Tests.js 105 KB

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