Compiler-Tests.js 136 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510
  1. define(["amber/boot", "require", "amber/core/SUnit"], function($boot,requirejs){"use strict";
  2. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  3. var $pkg = $core.addPackage("Compiler-Tests");
  4. $pkg.innerEval = function (expr) { return eval(expr); };
  5. $pkg.transport = {"type":"amd","amdNamespace":"amber/core"};
  6. $core.addClass("ASTParsingTest", $globals.TestCase, [], "Compiler-Tests");
  7. $core.addMethod(
  8. $core.method({
  9. selector: "parse:forClass:",
  10. protocol: "parsing",
  11. //>>excludeStart("ide", pragmas.excludeIdeData);
  12. args: ["aString", "aClass"],
  13. source: "parse: aString forClass: aClass\x0a\x09^ Compiler new\x0a\x09\x09ast: aString\x0a\x09\x09forClass: aClass\x0a\x09\x09protocol: 'test'",
  14. referencedClasses: ["Compiler"],
  15. //>>excludeEnd("ide");
  16. pragmas: [],
  17. messageSends: ["ast:forClass:protocol:", "new"]
  18. }, function ($methodClass){ return function (aString,aClass){
  19. var self=this,$self=this;
  20. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  21. return $core.withContext(function($ctx1) {
  22. //>>excludeEnd("ctx");
  23. return $recv($recv($globals.Compiler)._new())._ast_forClass_protocol_(aString,aClass,"test");
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass})});
  26. //>>excludeEnd("ctx");
  27. }; }),
  28. $globals.ASTParsingTest);
  29. $core.addClass("ASTCompilingTest", $globals.ASTParsingTest, ["receiver"], "Compiler-Tests");
  30. $core.addMethod(
  31. $core.method({
  32. selector: "codeGeneratorClass",
  33. protocol: "accessing",
  34. //>>excludeStart("ide", pragmas.excludeIdeData);
  35. args: [],
  36. source: "codeGeneratorClass\x0a\x09self subclassResponsibility",
  37. referencedClasses: [],
  38. //>>excludeEnd("ide");
  39. pragmas: [],
  40. messageSends: ["subclassResponsibility"]
  41. }, function ($methodClass){ return function (){
  42. var self=this,$self=this;
  43. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  44. return $core.withContext(function($ctx1) {
  45. //>>excludeEnd("ctx");
  46. $self._subclassResponsibility();
  47. return self;
  48. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  49. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{})});
  50. //>>excludeEnd("ctx");
  51. }; }),
  52. $globals.ASTCompilingTest);
  53. $core.addMethod(
  54. $core.method({
  55. selector: "compiler",
  56. protocol: "factory",
  57. //>>excludeStart("ide", pragmas.excludeIdeData);
  58. args: [],
  59. source: "compiler\x0a\x09^ Compiler new\x0a\x09\x09codeGeneratorClass: self codeGeneratorClass;\x0a\x09\x09yourself",
  60. referencedClasses: ["Compiler"],
  61. //>>excludeEnd("ide");
  62. pragmas: [],
  63. messageSends: ["codeGeneratorClass:", "new", "codeGeneratorClass", "yourself"]
  64. }, function ($methodClass){ return function (){
  65. var self=this,$self=this;
  66. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  67. return $core.withContext(function($ctx1) {
  68. //>>excludeEnd("ctx");
  69. var $1;
  70. $1=$recv($globals.Compiler)._new();
  71. $recv($1)._codeGeneratorClass_($self._codeGeneratorClass());
  72. return $recv($1)._yourself();
  73. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  74. }, function($ctx1) {$ctx1.fill(self,"compiler",{})});
  75. //>>excludeEnd("ctx");
  76. }; }),
  77. $globals.ASTCompilingTest);
  78. $core.addMethod(
  79. $core.method({
  80. selector: "install:forClass:",
  81. protocol: "compiling",
  82. //>>excludeStart("ide", pragmas.excludeIdeData);
  83. args: ["aString", "aClass"],
  84. source: "install: aString forClass: aClass\x0a\x09^ self compiler\x0a\x09\x09install: aString\x0a\x09\x09forClass: aClass\x0a\x09\x09protocol: 'tests'",
  85. referencedClasses: [],
  86. //>>excludeEnd("ide");
  87. pragmas: [],
  88. messageSends: ["install:forClass:protocol:", "compiler"]
  89. }, function ($methodClass){ return function (aString,aClass){
  90. var self=this,$self=this;
  91. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  92. return $core.withContext(function($ctx1) {
  93. //>>excludeEnd("ctx");
  94. return $recv($self._compiler())._install_forClass_protocol_(aString,aClass,"tests");
  95. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  96. }, function($ctx1) {$ctx1.fill(self,"install:forClass:",{aString:aString,aClass:aClass})});
  97. //>>excludeEnd("ctx");
  98. }; }),
  99. $globals.ASTCompilingTest);
  100. $core.addMethod(
  101. $core.method({
  102. selector: "setUp",
  103. protocol: "initialization",
  104. //>>excludeStart("ide", pragmas.excludeIdeData);
  105. args: [],
  106. source: "setUp\x0a\x09receiver := DoIt new",
  107. referencedClasses: ["DoIt"],
  108. //>>excludeEnd("ide");
  109. pragmas: [],
  110. messageSends: ["new"]
  111. }, function ($methodClass){ return function (){
  112. var self=this,$self=this;
  113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  114. return $core.withContext(function($ctx1) {
  115. //>>excludeEnd("ctx");
  116. $self.receiver=$recv($globals.DoIt)._new();
  117. return self;
  118. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  119. }, function($ctx1) {$ctx1.fill(self,"setUp",{})});
  120. //>>excludeEnd("ctx");
  121. }; }),
  122. $globals.ASTCompilingTest);
  123. $core.addMethod(
  124. $core.method({
  125. selector: "tearDown",
  126. protocol: "initialization",
  127. //>>excludeStart("ide", pragmas.excludeIdeData);
  128. args: [],
  129. source: "tearDown\x0a\x09\x22receiver := nil\x22",
  130. referencedClasses: [],
  131. //>>excludeEnd("ide");
  132. pragmas: [],
  133. messageSends: []
  134. }, function ($methodClass){ return function (){
  135. var self=this,$self=this;
  136. return self;
  137. }; }),
  138. $globals.ASTCompilingTest);
  139. $core.addMethod(
  140. $core.method({
  141. selector: "while:inClass:should:",
  142. protocol: "testing",
  143. //>>excludeStart("ide", pragmas.excludeIdeData);
  144. args: ["aString", "aClass", "aBlock"],
  145. source: "while: aString inClass: aClass should: aBlock\x0a\x09| method |\x0a\x0a\x09[\x0a\x09\x09method := self install: aString forClass: aClass.\x0a\x09\x09aBlock value: method ]\x0a\x09ensure: [ method ifNotNil: [ aClass removeCompiledMethod: method ] ]",
  146. referencedClasses: [],
  147. //>>excludeEnd("ide");
  148. pragmas: [],
  149. messageSends: ["ensure:", "install:forClass:", "value:", "ifNotNil:", "removeCompiledMethod:"]
  150. }, function ($methodClass){ return function (aString,aClass,aBlock){
  151. var self=this,$self=this;
  152. var method;
  153. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  154. return $core.withContext(function($ctx1) {
  155. //>>excludeEnd("ctx");
  156. var $1,$receiver;
  157. $recv((function(){
  158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  159. return $core.withContext(function($ctx2) {
  160. //>>excludeEnd("ctx");
  161. method=$self._install_forClass_(aString,aClass);
  162. return $recv(aBlock)._value_(method);
  163. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  164. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  165. //>>excludeEnd("ctx");
  166. }))._ensure_((function(){
  167. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  168. return $core.withContext(function($ctx2) {
  169. //>>excludeEnd("ctx");
  170. $1=method;
  171. if(($receiver = $1) == null || $receiver.a$nil){
  172. return $1;
  173. } else {
  174. return $recv(aClass)._removeCompiledMethod_(method);
  175. }
  176. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  177. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  178. //>>excludeEnd("ctx");
  179. }));
  180. return self;
  181. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  182. }, function($ctx1) {$ctx1.fill(self,"while:inClass:should:",{aString:aString,aClass:aClass,aBlock:aBlock,method:method})});
  183. //>>excludeEnd("ctx");
  184. }; }),
  185. $globals.ASTCompilingTest);
  186. $core.addMethod(
  187. $core.method({
  188. selector: "while:should:",
  189. protocol: "testing",
  190. //>>excludeStart("ide", pragmas.excludeIdeData);
  191. args: ["aString", "aBlock"],
  192. source: "while: aString should: aBlock\x0a\x09self while: aString inClass: receiver class should: aBlock",
  193. referencedClasses: [],
  194. //>>excludeEnd("ide");
  195. pragmas: [],
  196. messageSends: ["while:inClass:should:", "class"]
  197. }, function ($methodClass){ return function (aString,aBlock){
  198. var self=this,$self=this;
  199. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  200. return $core.withContext(function($ctx1) {
  201. //>>excludeEnd("ctx");
  202. $self._while_inClass_should_(aString,$recv($self.receiver)._class(),aBlock);
  203. return self;
  204. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  205. }, function($ctx1) {$ctx1.fill(self,"while:should:",{aString:aString,aBlock:aBlock})});
  206. //>>excludeEnd("ctx");
  207. }; }),
  208. $globals.ASTCompilingTest);
  209. $core.addClass("ASTMethodRunningTest", $globals.ASTCompilingTest, [], "Compiler-Tests");
  210. $core.addMethod(
  211. $core.method({
  212. selector: "actOn:in:",
  213. protocol: "running",
  214. //>>excludeStart("ide", pragmas.excludeIdeData);
  215. args: ["aMethod", "aClass"],
  216. source: "actOn: aMethod in: aClass\x0a\x09self subclassResponsibility",
  217. referencedClasses: [],
  218. //>>excludeEnd("ide");
  219. pragmas: [],
  220. messageSends: ["subclassResponsibility"]
  221. }, function ($methodClass){ return function (aMethod,aClass){
  222. var self=this,$self=this;
  223. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  224. return $core.withContext(function($ctx1) {
  225. //>>excludeEnd("ctx");
  226. $self._subclassResponsibility();
  227. return self;
  228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  229. }, function($ctx1) {$ctx1.fill(self,"actOn:in:",{aMethod:aMethod,aClass:aClass})});
  230. //>>excludeEnd("ctx");
  231. }; }),
  232. $globals.ASTMethodRunningTest);
  233. $core.addMethod(
  234. $core.method({
  235. selector: "should:class:receiver:return:",
  236. protocol: "testing",
  237. //>>excludeStart("ide", pragmas.excludeIdeData);
  238. args: ["aString", "aClass", "anObject", "aResult"],
  239. source: "should: aString class: aClass receiver: anObject return: aResult\x0a\x09receiver := anObject.\x0a\x09self while: aString inClass: aClass should: [ :runBlock |\x0a\x09\x09self assert: runBlock value equals: aResult ]",
  240. referencedClasses: [],
  241. //>>excludeEnd("ide");
  242. pragmas: [],
  243. messageSends: ["while:inClass:should:", "assert:equals:", "value"]
  244. }, function ($methodClass){ return function (aString,aClass,anObject,aResult){
  245. var self=this,$self=this;
  246. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  247. return $core.withContext(function($ctx1) {
  248. //>>excludeEnd("ctx");
  249. $self.receiver=anObject;
  250. $self._while_inClass_should_(aString,aClass,(function(runBlock){
  251. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  252. return $core.withContext(function($ctx2) {
  253. //>>excludeEnd("ctx");
  254. return $self._assert_equals_($recv(runBlock)._value(),aResult);
  255. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  256. }, function($ctx2) {$ctx2.fillBlock({runBlock:runBlock},$ctx1,1)});
  257. //>>excludeEnd("ctx");
  258. }));
  259. return self;
  260. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  261. }, function($ctx1) {$ctx1.fill(self,"should:class:receiver:return:",{aString:aString,aClass:aClass,anObject:anObject,aResult:aResult})});
  262. //>>excludeEnd("ctx");
  263. }; }),
  264. $globals.ASTMethodRunningTest);
  265. $core.addMethod(
  266. $core.method({
  267. selector: "should:receiver:raise:",
  268. protocol: "testing",
  269. //>>excludeStart("ide", pragmas.excludeIdeData);
  270. args: ["aString", "anObject", "anErrorClass"],
  271. source: "should: aString receiver: anObject raise: anErrorClass\x0a\x09receiver := anObject.\x0a\x09self while: aString should: [ :runBlock |\x0a\x09\x09self should: runBlock raise: anErrorClass ]",
  272. referencedClasses: [],
  273. //>>excludeEnd("ide");
  274. pragmas: [],
  275. messageSends: ["while:should:", "should:raise:"]
  276. }, function ($methodClass){ return function (aString,anObject,anErrorClass){
  277. var self=this,$self=this;
  278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  279. return $core.withContext(function($ctx1) {
  280. //>>excludeEnd("ctx");
  281. $self.receiver=anObject;
  282. $self._while_should_(aString,(function(runBlock){
  283. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  284. return $core.withContext(function($ctx2) {
  285. //>>excludeEnd("ctx");
  286. return $self._should_raise_(runBlock,anErrorClass);
  287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  288. }, function($ctx2) {$ctx2.fillBlock({runBlock:runBlock},$ctx1,1)});
  289. //>>excludeEnd("ctx");
  290. }));
  291. return self;
  292. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  293. }, function($ctx1) {$ctx1.fill(self,"should:receiver:raise:",{aString:aString,anObject:anObject,anErrorClass:anErrorClass})});
  294. //>>excludeEnd("ctx");
  295. }; }),
  296. $globals.ASTMethodRunningTest);
  297. $core.addMethod(
  298. $core.method({
  299. selector: "should:receiver:return:",
  300. protocol: "testing",
  301. //>>excludeStart("ide", pragmas.excludeIdeData);
  302. args: ["aString", "anObject", "aResult"],
  303. source: "should: aString receiver: anObject return: aResult\x0a\x09receiver := anObject.\x0a\x09self should: aString return: aResult",
  304. referencedClasses: [],
  305. //>>excludeEnd("ide");
  306. pragmas: [],
  307. messageSends: ["should:return:"]
  308. }, function ($methodClass){ return function (aString,anObject,aResult){
  309. var self=this,$self=this;
  310. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  311. return $core.withContext(function($ctx1) {
  312. //>>excludeEnd("ctx");
  313. $self.receiver=anObject;
  314. $self._should_return_(aString,aResult);
  315. return self;
  316. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  317. }, function($ctx1) {$ctx1.fill(self,"should:receiver:return:",{aString:aString,anObject:anObject,aResult:aResult})});
  318. //>>excludeEnd("ctx");
  319. }; }),
  320. $globals.ASTMethodRunningTest);
  321. $core.addMethod(
  322. $core.method({
  323. selector: "should:return:",
  324. protocol: "testing",
  325. //>>excludeStart("ide", pragmas.excludeIdeData);
  326. args: ["aString", "anObject"],
  327. source: "should: aString return: anObject\x0a\x09self while: aString should: [ :runBlock |\x0a\x09\x09self assert: runBlock value equals: anObject ]",
  328. referencedClasses: [],
  329. //>>excludeEnd("ide");
  330. pragmas: [],
  331. messageSends: ["while:should:", "assert:equals:", "value"]
  332. }, function ($methodClass){ return function (aString,anObject){
  333. var self=this,$self=this;
  334. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  335. return $core.withContext(function($ctx1) {
  336. //>>excludeEnd("ctx");
  337. $self._while_should_(aString,(function(runBlock){
  338. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  339. return $core.withContext(function($ctx2) {
  340. //>>excludeEnd("ctx");
  341. return $self._assert_equals_($recv(runBlock)._value(),anObject);
  342. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  343. }, function($ctx2) {$ctx2.fillBlock({runBlock:runBlock},$ctx1,1)});
  344. //>>excludeEnd("ctx");
  345. }));
  346. return self;
  347. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  348. }, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject})});
  349. //>>excludeEnd("ctx");
  350. }; }),
  351. $globals.ASTMethodRunningTest);
  352. $core.addMethod(
  353. $core.method({
  354. selector: "while:inClass:should:",
  355. protocol: "testing",
  356. //>>excludeStart("ide", pragmas.excludeIdeData);
  357. args: ["aString", "aClass", "aBlock"],
  358. source: "while: aString inClass: aClass should: aBlock\x0a\x09super\x0a\x09\x09while: aString\x0a\x09\x09inClass: aClass\x0a\x09\x09should: [ :method | aBlock value: [ self actOn: method in: aClass ] ]",
  359. referencedClasses: [],
  360. //>>excludeEnd("ide");
  361. pragmas: [],
  362. messageSends: ["while:inClass:should:", "value:", "actOn:in:"]
  363. }, function ($methodClass){ return function (aString,aClass,aBlock){
  364. var self=this,$self=this;
  365. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  366. return $core.withContext(function($ctx1) {
  367. //>>excludeEnd("ctx");
  368. (
  369. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  370. $ctx1.supercall = true,
  371. //>>excludeEnd("ctx");
  372. ($methodClass.superclass||$boot.nilAsClass).fn.prototype._while_inClass_should_.call($self,aString,aClass,(function(method){
  373. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  374. return $core.withContext(function($ctx2) {
  375. //>>excludeEnd("ctx");
  376. return $recv(aBlock)._value_((function(){
  377. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  378. return $core.withContext(function($ctx3) {
  379. //>>excludeEnd("ctx");
  380. return $self._actOn_in_(method,aClass);
  381. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  382. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  383. //>>excludeEnd("ctx");
  384. }));
  385. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  386. }, function($ctx2) {$ctx2.fillBlock({method:method},$ctx1,1)});
  387. //>>excludeEnd("ctx");
  388. })));
  389. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  390. $ctx1.supercall = false;
  391. //>>excludeEnd("ctx");;
  392. return self;
  393. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  394. }, function($ctx1) {$ctx1.fill(self,"while:inClass:should:",{aString:aString,aClass:aClass,aBlock:aBlock})});
  395. //>>excludeEnd("ctx");
  396. }; }),
  397. $globals.ASTMethodRunningTest);
  398. $core.addClass("CodeGeneratorTest", $globals.ASTMethodRunningTest, [], "Compiler-Tests");
  399. $core.addMethod(
  400. $core.method({
  401. selector: "actOn:in:",
  402. protocol: "running",
  403. //>>excludeStart("ide", pragmas.excludeIdeData);
  404. args: ["aMethod", "aClass"],
  405. source: "actOn: aMethod in: aClass\x0a\x09^ receiver perform: aMethod selector",
  406. referencedClasses: [],
  407. //>>excludeEnd("ide");
  408. pragmas: [],
  409. messageSends: ["perform:", "selector"]
  410. }, function ($methodClass){ return function (aMethod,aClass){
  411. var self=this,$self=this;
  412. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  413. return $core.withContext(function($ctx1) {
  414. //>>excludeEnd("ctx");
  415. return $recv($self.receiver)._perform_($recv(aMethod)._selector());
  416. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  417. }, function($ctx1) {$ctx1.fill(self,"actOn:in:",{aMethod:aMethod,aClass:aClass})});
  418. //>>excludeEnd("ctx");
  419. }; }),
  420. $globals.CodeGeneratorTest);
  421. $core.addMethod(
  422. $core.method({
  423. selector: "codeGeneratorClass",
  424. protocol: "accessing",
  425. //>>excludeStart("ide", pragmas.excludeIdeData);
  426. args: [],
  427. source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
  428. referencedClasses: ["CodeGenerator"],
  429. //>>excludeEnd("ide");
  430. pragmas: [],
  431. messageSends: []
  432. }, function ($methodClass){ return function (){
  433. var self=this,$self=this;
  434. return $globals.CodeGenerator;
  435. }; }),
  436. $globals.CodeGeneratorTest);
  437. $core.addMethod(
  438. $core.method({
  439. selector: "testAssignment",
  440. protocol: "tests",
  441. //>>excludeStart("ide", pragmas.excludeIdeData);
  442. args: [],
  443. source: "testAssignment\x0a\x09self should: 'foo | a | a := true ifTrue: [ 1 ]. ^ a' return: 1.\x0a\x09self should: 'foo | a | a := false ifTrue: [ 1 ]. ^ a' return: nil.\x0a\x0a\x09self should: 'foo | a | ^ a := true ifTrue: [ 1 ]' return: 1",
  444. referencedClasses: [],
  445. //>>excludeEnd("ide");
  446. pragmas: [],
  447. messageSends: ["should:return:"]
  448. }, function ($methodClass){ return function (){
  449. var self=this,$self=this;
  450. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  451. return $core.withContext(function($ctx1) {
  452. //>>excludeEnd("ctx");
  453. $self._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  454. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  455. $ctx1.sendIdx["should:return:"]=1;
  456. //>>excludeEnd("ctx");
  457. $self._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  458. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  459. $ctx1.sendIdx["should:return:"]=2;
  460. //>>excludeEnd("ctx");
  461. $self._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  462. return self;
  463. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  464. }, function($ctx1) {$ctx1.fill(self,"testAssignment",{})});
  465. //>>excludeEnd("ctx");
  466. }; }),
  467. $globals.CodeGeneratorTest);
  468. $core.addMethod(
  469. $core.method({
  470. selector: "testBackslashSelectors",
  471. protocol: "tests",
  472. //>>excludeStart("ide", pragmas.excludeIdeData);
  473. args: [],
  474. source: "testBackslashSelectors\x0a\x09\x0a\x09self should: '\x5c arg ^ 4' return: 4.\x0a\x09self should: '\x5c\x5c arg ^ 42' return: 42",
  475. referencedClasses: [],
  476. //>>excludeEnd("ide");
  477. pragmas: [],
  478. messageSends: ["should:return:"]
  479. }, function ($methodClass){ return function (){
  480. var self=this,$self=this;
  481. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  482. return $core.withContext(function($ctx1) {
  483. //>>excludeEnd("ctx");
  484. $self._should_return_("\x5c arg ^ 4",(4));
  485. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  486. $ctx1.sendIdx["should:return:"]=1;
  487. //>>excludeEnd("ctx");
  488. $self._should_return_("\x5c\x5c arg ^ 42",(42));
  489. return self;
  490. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  491. }, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{})});
  492. //>>excludeEnd("ctx");
  493. }; }),
  494. $globals.CodeGeneratorTest);
  495. $core.addMethod(
  496. $core.method({
  497. selector: "testBlockReturn",
  498. protocol: "tests",
  499. //>>excludeStart("ide", pragmas.excludeIdeData);
  500. args: [],
  501. source: "testBlockReturn\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]' return: #(2 3 4).\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]' return: #(2 3 4).\x0a\x09self should: 'foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]' return: #(2 1 4).",
  502. referencedClasses: [],
  503. //>>excludeEnd("ide");
  504. pragmas: [],
  505. messageSends: ["should:return:"]
  506. }, function ($methodClass){ return function (){
  507. var self=this,$self=this;
  508. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  509. return $core.withContext(function($ctx1) {
  510. //>>excludeEnd("ctx");
  511. $self._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  512. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  513. $ctx1.sendIdx["should:return:"]=1;
  514. //>>excludeEnd("ctx");
  515. $self._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  516. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  517. $ctx1.sendIdx["should:return:"]=2;
  518. //>>excludeEnd("ctx");
  519. $self._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  520. return self;
  521. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  522. }, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{})});
  523. //>>excludeEnd("ctx");
  524. }; }),
  525. $globals.CodeGeneratorTest);
  526. $core.addMethod(
  527. $core.method({
  528. selector: "testCascades",
  529. protocol: "tests",
  530. //>>excludeStart("ide", pragmas.excludeIdeData);
  531. args: [],
  532. source: "testCascades\x0a\x09\x0a\x09self should: 'foo ^ Array new add: 3; add: 4; yourself' return: #(3 4)",
  533. referencedClasses: [],
  534. //>>excludeEnd("ide");
  535. pragmas: [],
  536. messageSends: ["should:return:"]
  537. }, function ($methodClass){ return function (){
  538. var self=this,$self=this;
  539. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  540. return $core.withContext(function($ctx1) {
  541. //>>excludeEnd("ctx");
  542. $self._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  543. return self;
  544. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  545. }, function($ctx1) {$ctx1.fill(self,"testCascades",{})});
  546. //>>excludeEnd("ctx");
  547. }; }),
  548. $globals.CodeGeneratorTest);
  549. $core.addMethod(
  550. $core.method({
  551. selector: "testCascadesInDynamicArray",
  552. protocol: "tests",
  553. //>>excludeStart("ide", pragmas.excludeIdeData);
  554. args: [],
  555. source: "testCascadesInDynamicArray\x0a\x09self should: 'foo | x | x := 1. ^ {x. [x:=2] value; in: [x]}' return: #(1 2)",
  556. referencedClasses: [],
  557. //>>excludeEnd("ide");
  558. pragmas: [],
  559. messageSends: ["should:return:"]
  560. }, function ($methodClass){ return function (){
  561. var self=this,$self=this;
  562. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  563. return $core.withContext(function($ctx1) {
  564. //>>excludeEnd("ctx");
  565. $self._should_return_("foo | x | x := 1. ^ {x. [x:=2] value; in: [x]}",[(1), (2)]);
  566. return self;
  567. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  568. }, function($ctx1) {$ctx1.fill(self,"testCascadesInDynamicArray",{})});
  569. //>>excludeEnd("ctx");
  570. }; }),
  571. $globals.CodeGeneratorTest);
  572. $core.addMethod(
  573. $core.method({
  574. selector: "testCascadesInDynamicDictioary",
  575. protocol: "tests",
  576. //>>excludeStart("ide", pragmas.excludeIdeData);
  577. args: [],
  578. source: "testCascadesInDynamicDictioary\x0a\x09self should: 'foo | x | x := 1. ^ #{''one'' -> x. ''two'' -> ([x:=2] value; in: [x])}' return: #{'one' -> 1. 'two' -> 2}",
  579. referencedClasses: [],
  580. //>>excludeEnd("ide");
  581. pragmas: [],
  582. messageSends: ["should:return:"]
  583. }, function ($methodClass){ return function (){
  584. var self=this,$self=this;
  585. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  586. return $core.withContext(function($ctx1) {
  587. //>>excludeEnd("ctx");
  588. $self._should_return_("foo | x | x := 1. ^ #{'one' -> x. 'two' -> ([x:=2] value; in: [x])}",$globals.HashedCollection._newFromPairs_(["one",(1),"two",(2)]));
  589. return self;
  590. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  591. }, function($ctx1) {$ctx1.fill(self,"testCascadesInDynamicDictioary",{})});
  592. //>>excludeEnd("ctx");
  593. }; }),
  594. $globals.CodeGeneratorTest);
  595. $core.addMethod(
  596. $core.method({
  597. selector: "testCascadesInSend",
  598. protocol: "tests",
  599. //>>excludeStart("ide", pragmas.excludeIdeData);
  600. args: [],
  601. source: "testCascadesInSend\x0a\x09self should: 'foo | x | x := 1. ^ Array with: x with: ([x:=2] value; in: [x])' return: #(1 2)",
  602. referencedClasses: [],
  603. //>>excludeEnd("ide");
  604. pragmas: [],
  605. messageSends: ["should:return:"]
  606. }, function ($methodClass){ return function (){
  607. var self=this,$self=this;
  608. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  609. return $core.withContext(function($ctx1) {
  610. //>>excludeEnd("ctx");
  611. $self._should_return_("foo | x | x := 1. ^ Array with: x with: ([x:=2] value; in: [x])",[(1), (2)]);
  612. return self;
  613. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  614. }, function($ctx1) {$ctx1.fill(self,"testCascadesInSend",{})});
  615. //>>excludeEnd("ctx");
  616. }; }),
  617. $globals.CodeGeneratorTest);
  618. $core.addMethod(
  619. $core.method({
  620. selector: "testCascadesWithInlining",
  621. protocol: "tests",
  622. //>>excludeStart("ide", pragmas.excludeIdeData);
  623. args: [],
  624. source: "testCascadesWithInlining\x0a\x09\x0a\x09self should: 'foo ^ true class; ifTrue: [ 1 ] ifFalse: [ 2 ]' return: 1.\x0a\x09self should: 'foo ^ false class; ifTrue: [ 1 ] ifFalse: [ 2 ]' return: 2",
  625. referencedClasses: [],
  626. //>>excludeEnd("ide");
  627. pragmas: [],
  628. messageSends: ["should:return:"]
  629. }, function ($methodClass){ return function (){
  630. var self=this,$self=this;
  631. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  632. return $core.withContext(function($ctx1) {
  633. //>>excludeEnd("ctx");
  634. $self._should_return_("foo ^ true class; ifTrue: [ 1 ] ifFalse: [ 2 ]",(1));
  635. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  636. $ctx1.sendIdx["should:return:"]=1;
  637. //>>excludeEnd("ctx");
  638. $self._should_return_("foo ^ false class; ifTrue: [ 1 ] ifFalse: [ 2 ]",(2));
  639. return self;
  640. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  641. }, function($ctx1) {$ctx1.fill(self,"testCascadesWithInlining",{})});
  642. //>>excludeEnd("ctx");
  643. }; }),
  644. $globals.CodeGeneratorTest);
  645. $core.addMethod(
  646. $core.method({
  647. selector: "testDynamicArrayElementsOrdered",
  648. protocol: "tests",
  649. //>>excludeStart("ide", pragmas.excludeIdeData);
  650. args: [],
  651. source: "testDynamicArrayElementsOrdered\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. x := 2 }\x0a' return: #(1 2).\x0a\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a' return: #(1 2).",
  652. referencedClasses: [],
  653. //>>excludeEnd("ide");
  654. pragmas: [],
  655. messageSends: ["should:return:"]
  656. }, function ($methodClass){ return function (){
  657. var self=this,$self=this;
  658. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  659. return $core.withContext(function($ctx1) {
  660. //>>excludeEnd("ctx");
  661. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. x := 2 }\x0a",[(1), (2)]);
  662. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  663. $ctx1.sendIdx["should:return:"]=1;
  664. //>>excludeEnd("ctx");
  665. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  666. return self;
  667. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  668. }, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{})});
  669. //>>excludeEnd("ctx");
  670. }; }),
  671. $globals.CodeGeneratorTest);
  672. $core.addMethod(
  673. $core.method({
  674. selector: "testDynamicDictionaryElementsOrdered",
  675. protocol: "tests",
  676. //>>excludeStart("ide", pragmas.excludeIdeData);
  677. args: [],
  678. source: "testDynamicDictionaryElementsOrdered\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := ''foo''.\x0a\x09^ #{ x->1. ''bar''->(true ifTrue: [ 2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.",
  679. referencedClasses: [],
  680. //>>excludeEnd("ide");
  681. pragmas: [],
  682. messageSends: ["should:return:"]
  683. }, function ($methodClass){ return function (){
  684. var self=this,$self=this;
  685. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  686. return $core.withContext(function($ctx1) {
  687. //>>excludeEnd("ctx");
  688. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := 'foo'.\x0a\x09^ #{ x->1. 'bar'->(true ifTrue: [ 2 ]) }\x0a",$globals.HashedCollection._newFromPairs_(["foo",(1),"bar",(2)]));
  689. return self;
  690. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  691. }, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{})});
  692. //>>excludeEnd("ctx");
  693. }; }),
  694. $globals.CodeGeneratorTest);
  695. $core.addMethod(
  696. $core.method({
  697. selector: "testDynamicDictionaryWithMoreArrows",
  698. protocol: "tests",
  699. //>>excludeStart("ide", pragmas.excludeIdeData);
  700. args: [],
  701. source: "testDynamicDictionaryWithMoreArrows\x0a\x09self should: 'foo ^ #{1->2->3}' return: (HashedCollection with: 1->2->3)",
  702. referencedClasses: ["HashedCollection"],
  703. //>>excludeEnd("ide");
  704. pragmas: [],
  705. messageSends: ["should:return:", "with:", "->"]
  706. }, function ($methodClass){ return function (){
  707. var self=this,$self=this;
  708. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  709. return $core.withContext(function($ctx1) {
  710. //>>excludeEnd("ctx");
  711. var $2,$1;
  712. $2=$recv((1).__minus_gt((2))).__minus_gt((3));
  713. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  714. $ctx1.sendIdx["->"]=1;
  715. //>>excludeEnd("ctx");
  716. $1=$recv($globals.HashedCollection)._with_($2);
  717. $self._should_return_("foo ^ #{1->2->3}",$1);
  718. return self;
  719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  720. }, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryWithMoreArrows",{})});
  721. //>>excludeEnd("ctx");
  722. }; }),
  723. $globals.CodeGeneratorTest);
  724. $core.addMethod(
  725. $core.method({
  726. selector: "testGlobalVar",
  727. protocol: "tests",
  728. //>>excludeStart("ide", pragmas.excludeIdeData);
  729. args: [],
  730. source: "testGlobalVar\x0a\x09self should: 'foo ^ eval class' return: BlockClosure.\x0a\x09self should: 'foo ^ Math cos: 0' return: 1.\x0a\x09self should: 'foo ^ NonExistingVar' return: nil",
  731. referencedClasses: ["BlockClosure"],
  732. //>>excludeEnd("ide");
  733. pragmas: [],
  734. messageSends: ["should:return:"]
  735. }, function ($methodClass){ return function (){
  736. var self=this,$self=this;
  737. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  738. return $core.withContext(function($ctx1) {
  739. //>>excludeEnd("ctx");
  740. $self._should_return_("foo ^ eval class",$globals.BlockClosure);
  741. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  742. $ctx1.sendIdx["should:return:"]=1;
  743. //>>excludeEnd("ctx");
  744. $self._should_return_("foo ^ Math cos: 0",(1));
  745. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  746. $ctx1.sendIdx["should:return:"]=2;
  747. //>>excludeEnd("ctx");
  748. $self._should_return_("foo ^ NonExistingVar",nil);
  749. return self;
  750. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  751. }, function($ctx1) {$ctx1.fill(self,"testGlobalVar",{})});
  752. //>>excludeEnd("ctx");
  753. }; }),
  754. $globals.CodeGeneratorTest);
  755. $core.addMethod(
  756. $core.method({
  757. selector: "testInnerTemporalDependentElementsOrdered",
  758. protocol: "tests",
  759. //>>excludeStart("ide", pragmas.excludeIdeData);
  760. args: [],
  761. source: "testInnerTemporalDependentElementsOrdered\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: ''foo''->x with: ''bar''->(x := 2)\x0a' return: {'foo'->Array. 'bar'->2}.\x0a\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])\x0a' return: {'foo'->Array. 'bar'->2}.\x0a\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: ''foo''->x with: ''bar''->(true ifTrue: [ x := 2 ])\x0a' return: {'foo'->1. 'bar'->2}.\x0a\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }\x0a' return: {'foo'->1. 'bar'->2}.\x0a\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.",
  762. referencedClasses: ["Array"],
  763. //>>excludeEnd("ide");
  764. pragmas: [],
  765. messageSends: ["should:return:", "->"]
  766. }, function ($methodClass){ return function (){
  767. var self=this,$self=this;
  768. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  769. return $core.withContext(function($ctx1) {
  770. //>>excludeEnd("ctx");
  771. var $2,$3,$1,$5,$6,$4,$8,$9,$7,$11,$10;
  772. $2="foo".__minus_gt($globals.Array);
  773. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  774. $ctx1.sendIdx["->"]=1;
  775. //>>excludeEnd("ctx");
  776. $3="bar".__minus_gt((2));
  777. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  778. $ctx1.sendIdx["->"]=2;
  779. //>>excludeEnd("ctx");
  780. $1=[$2,$3];
  781. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: 'foo'->x with: 'bar'->(x := 2)\x0a",$1);
  782. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  783. $ctx1.sendIdx["should:return:"]=1;
  784. //>>excludeEnd("ctx");
  785. $5="foo".__minus_gt($globals.Array);
  786. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  787. $ctx1.sendIdx["->"]=3;
  788. //>>excludeEnd("ctx");
  789. $6="bar".__minus_gt((2));
  790. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  791. $ctx1.sendIdx["->"]=4;
  792. //>>excludeEnd("ctx");
  793. $4=[$5,$6];
  794. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",$4);
  795. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  796. $ctx1.sendIdx["should:return:"]=2;
  797. //>>excludeEnd("ctx");
  798. $8="foo".__minus_gt((1));
  799. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  800. $ctx1.sendIdx["->"]=5;
  801. //>>excludeEnd("ctx");
  802. $9="bar".__minus_gt((2));
  803. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  804. $ctx1.sendIdx["->"]=6;
  805. //>>excludeEnd("ctx");
  806. $7=[$8,$9];
  807. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",$7);
  808. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  809. $ctx1.sendIdx["should:return:"]=3;
  810. //>>excludeEnd("ctx");
  811. $11="foo".__minus_gt((1));
  812. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  813. $ctx1.sendIdx["->"]=7;
  814. //>>excludeEnd("ctx");
  815. $10=[$11,"bar".__minus_gt((2))];
  816. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",$10);
  817. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  818. $ctx1.sendIdx["should:return:"]=4;
  819. //>>excludeEnd("ctx");
  820. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",$globals.HashedCollection._newFromPairs_(["foo",(1),"bar",(2)]));
  821. return self;
  822. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  823. }, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{})});
  824. //>>excludeEnd("ctx");
  825. }; }),
  826. $globals.CodeGeneratorTest);
  827. $core.addMethod(
  828. $core.method({
  829. selector: "testLexicalScope",
  830. protocol: "tests",
  831. //>>excludeStart("ide", pragmas.excludeIdeData);
  832. args: [],
  833. source: "testLexicalScope\x0a\x09self should: 'foo | a | a := 1. [ a := 2 ] value. ^ a' return: 2",
  834. referencedClasses: [],
  835. //>>excludeEnd("ide");
  836. pragmas: [],
  837. messageSends: ["should:return:"]
  838. }, function ($methodClass){ return function (){
  839. var self=this,$self=this;
  840. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  841. return $core.withContext(function($ctx1) {
  842. //>>excludeEnd("ctx");
  843. $self._should_return_("foo | a | a := 1. [ a := 2 ] value. ^ a",(2));
  844. return self;
  845. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  846. }, function($ctx1) {$ctx1.fill(self,"testLexicalScope",{})});
  847. //>>excludeEnd("ctx");
  848. }; }),
  849. $globals.CodeGeneratorTest);
  850. $core.addMethod(
  851. $core.method({
  852. selector: "testLiterals",
  853. protocol: "tests",
  854. //>>excludeStart("ide", pragmas.excludeIdeData);
  855. args: [],
  856. source: "testLiterals\x0a\x09self should: 'foo ^ 1' return: 1.\x0a\x09self should: 'foo ^ ''hello''' return: 'hello'.\x0a\x09self should: 'foo ^ #(1 2 3 4)' return: #(1 2 3 4).\x0a\x09self should: 'foo ^ {1. [:x | x ] value: 2. 3. [4] value}' return: #(1 2 3 4).\x0a\x09self should: 'foo ^ true' return: true.\x0a\x09self should: 'foo ^ false' return: false.\x0a\x09self should: 'foo ^ #{1->2. 3->4}' return: #{1->2. 3->4}.\x0a\x09self should: 'foo ^ #hello' return: #hello.\x0a\x09self should: 'foo ^ $h' return: 'h'.\x0a\x09self should: 'foo ^ -123.456' return: -123.456.\x0a\x09self should: 'foo ^ -2.5e4' return: -25000.",
  857. referencedClasses: [],
  858. //>>excludeEnd("ide");
  859. pragmas: [],
  860. messageSends: ["should:return:"]
  861. }, function ($methodClass){ return function (){
  862. var self=this,$self=this;
  863. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  864. return $core.withContext(function($ctx1) {
  865. //>>excludeEnd("ctx");
  866. $self._should_return_("foo ^ 1",(1));
  867. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  868. $ctx1.sendIdx["should:return:"]=1;
  869. //>>excludeEnd("ctx");
  870. $self._should_return_("foo ^ 'hello'","hello");
  871. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  872. $ctx1.sendIdx["should:return:"]=2;
  873. //>>excludeEnd("ctx");
  874. $self._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  875. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  876. $ctx1.sendIdx["should:return:"]=3;
  877. //>>excludeEnd("ctx");
  878. $self._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  879. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  880. $ctx1.sendIdx["should:return:"]=4;
  881. //>>excludeEnd("ctx");
  882. $self._should_return_("foo ^ true",true);
  883. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  884. $ctx1.sendIdx["should:return:"]=5;
  885. //>>excludeEnd("ctx");
  886. $self._should_return_("foo ^ false",false);
  887. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  888. $ctx1.sendIdx["should:return:"]=6;
  889. //>>excludeEnd("ctx");
  890. $self._should_return_("foo ^ #{1->2. 3->4}",$globals.HashedCollection._newFromPairs_([(1),(2),(3),(4)]));
  891. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  892. $ctx1.sendIdx["should:return:"]=7;
  893. //>>excludeEnd("ctx");
  894. $self._should_return_("foo ^ #hello","hello");
  895. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  896. $ctx1.sendIdx["should:return:"]=8;
  897. //>>excludeEnd("ctx");
  898. $self._should_return_("foo ^ $h","h");
  899. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  900. $ctx1.sendIdx["should:return:"]=9;
  901. //>>excludeEnd("ctx");
  902. $self._should_return_("foo ^ -123.456",(-123.456));
  903. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  904. $ctx1.sendIdx["should:return:"]=10;
  905. //>>excludeEnd("ctx");
  906. $self._should_return_("foo ^ -2.5e4",(-25000));
  907. return self;
  908. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  909. }, function($ctx1) {$ctx1.fill(self,"testLiterals",{})});
  910. //>>excludeEnd("ctx");
  911. }; }),
  912. $globals.CodeGeneratorTest);
  913. $core.addMethod(
  914. $core.method({
  915. selector: "testLocalReturn",
  916. protocol: "tests",
  917. //>>excludeStart("ide", pragmas.excludeIdeData);
  918. args: [],
  919. source: "testLocalReturn\x0a\x09self should: 'foo ^ 1' return: 1.\x0a\x09self should: 'foo ^ 1 + 1' return: 2.\x0a\x09self should: 'foo ' return: receiver.\x0a\x09self should: 'foo self asString' return: receiver.\x0a\x09self should: 'foo | a b | a := 1. b := 2. ^ a + b' return: 3",
  920. referencedClasses: [],
  921. //>>excludeEnd("ide");
  922. pragmas: [],
  923. messageSends: ["should:return:"]
  924. }, function ($methodClass){ return function (){
  925. var self=this,$self=this;
  926. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  927. return $core.withContext(function($ctx1) {
  928. //>>excludeEnd("ctx");
  929. $self._should_return_("foo ^ 1",(1));
  930. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  931. $ctx1.sendIdx["should:return:"]=1;
  932. //>>excludeEnd("ctx");
  933. $self._should_return_("foo ^ 1 + 1",(2));
  934. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  935. $ctx1.sendIdx["should:return:"]=2;
  936. //>>excludeEnd("ctx");
  937. $self._should_return_("foo ",$self.receiver);
  938. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  939. $ctx1.sendIdx["should:return:"]=3;
  940. //>>excludeEnd("ctx");
  941. $self._should_return_("foo self asString",$self.receiver);
  942. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  943. $ctx1.sendIdx["should:return:"]=4;
  944. //>>excludeEnd("ctx");
  945. $self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  946. return self;
  947. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  948. }, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{})});
  949. //>>excludeEnd("ctx");
  950. }; }),
  951. $globals.CodeGeneratorTest);
  952. $core.addMethod(
  953. $core.method({
  954. selector: "testMessageSends",
  955. protocol: "tests",
  956. //>>excludeStart("ide", pragmas.excludeIdeData);
  957. args: [],
  958. source: "testMessageSends\x0a\x09self should: 'foo ^ 1 asString' return: '1'.\x0a\x0a\x09self should: 'foo ^ 1 + 1' return: 2.\x0a\x09self should: 'foo ^ 1 + 2 * 3' return: 9.\x0a\x0a\x09self should: 'foo ^ 1 to: 3' return: #(1 2 3).\x0a\x09self should: 'foo ^ 1 to: 5 by: 2' return: #(1 3 5)",
  959. referencedClasses: [],
  960. //>>excludeEnd("ide");
  961. pragmas: [],
  962. messageSends: ["should:return:"]
  963. }, function ($methodClass){ return function (){
  964. var self=this,$self=this;
  965. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  966. return $core.withContext(function($ctx1) {
  967. //>>excludeEnd("ctx");
  968. $self._should_return_("foo ^ 1 asString","1");
  969. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  970. $ctx1.sendIdx["should:return:"]=1;
  971. //>>excludeEnd("ctx");
  972. $self._should_return_("foo ^ 1 + 1",(2));
  973. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  974. $ctx1.sendIdx["should:return:"]=2;
  975. //>>excludeEnd("ctx");
  976. $self._should_return_("foo ^ 1 + 2 * 3",(9));
  977. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  978. $ctx1.sendIdx["should:return:"]=3;
  979. //>>excludeEnd("ctx");
  980. $self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  981. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  982. $ctx1.sendIdx["should:return:"]=4;
  983. //>>excludeEnd("ctx");
  984. $self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  985. return self;
  986. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  987. }, function($ctx1) {$ctx1.fill(self,"testMessageSends",{})});
  988. //>>excludeEnd("ctx");
  989. }; }),
  990. $globals.CodeGeneratorTest);
  991. $core.addMethod(
  992. $core.method({
  993. selector: "testMultipleSequences",
  994. protocol: "tests",
  995. //>>excludeStart("ide", pragmas.excludeIdeData);
  996. args: [],
  997. source: "testMultipleSequences\x0a\x09self should: 'foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6' return: 30",
  998. referencedClasses: [],
  999. //>>excludeEnd("ide");
  1000. pragmas: [],
  1001. messageSends: ["should:return:"]
  1002. }, function ($methodClass){ return function (){
  1003. var self=this,$self=this;
  1004. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1005. return $core.withContext(function($ctx1) {
  1006. //>>excludeEnd("ctx");
  1007. $self._should_return_("foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6",(30));
  1008. return self;
  1009. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1010. }, function($ctx1) {$ctx1.fill(self,"testMultipleSequences",{})});
  1011. //>>excludeEnd("ctx");
  1012. }; }),
  1013. $globals.CodeGeneratorTest);
  1014. $core.addMethod(
  1015. $core.method({
  1016. selector: "testMutableLiterals",
  1017. protocol: "tests",
  1018. //>>excludeStart("ide", pragmas.excludeIdeData);
  1019. args: [],
  1020. source: "testMutableLiterals\x0a\x09\x22Mutable literals must be aliased in cascades.\x0a\x09See https://lolg.it/amber/amber/issues/428\x22\x0a\x09\x0a\x09self \x0a\x09\x09should: 'foo ^ #( 1 2 ) at: 1 put: 3; yourself' \x0a\x09\x09return: #(3 2)",
  1021. referencedClasses: [],
  1022. //>>excludeEnd("ide");
  1023. pragmas: [],
  1024. messageSends: ["should:return:"]
  1025. }, function ($methodClass){ return function (){
  1026. var self=this,$self=this;
  1027. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1028. return $core.withContext(function($ctx1) {
  1029. //>>excludeEnd("ctx");
  1030. $self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  1031. return self;
  1032. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1033. }, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{})});
  1034. //>>excludeEnd("ctx");
  1035. }; }),
  1036. $globals.CodeGeneratorTest);
  1037. $core.addMethod(
  1038. $core.method({
  1039. selector: "testNestedIfTrue",
  1040. protocol: "tests",
  1041. //>>excludeStart("ide", pragmas.excludeIdeData);
  1042. args: [],
  1043. source: "testNestedIfTrue\x0a\x09self should: 'foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]' return: 1.\x0a\x09self should: 'foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]' return: nil.\x0a\x0a\x09self should: 'foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]' return: 1.\x0a\x09self should: 'foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]' return: receiver.",
  1044. referencedClasses: [],
  1045. //>>excludeEnd("ide");
  1046. pragmas: [],
  1047. messageSends: ["should:return:"]
  1048. }, function ($methodClass){ return function (){
  1049. var self=this,$self=this;
  1050. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1051. return $core.withContext(function($ctx1) {
  1052. //>>excludeEnd("ctx");
  1053. $self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  1054. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1055. $ctx1.sendIdx["should:return:"]=1;
  1056. //>>excludeEnd("ctx");
  1057. $self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  1058. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1059. $ctx1.sendIdx["should:return:"]=2;
  1060. //>>excludeEnd("ctx");
  1061. $self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  1062. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1063. $ctx1.sendIdx["should:return:"]=3;
  1064. //>>excludeEnd("ctx");
  1065. $self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",$self.receiver);
  1066. return self;
  1067. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1068. }, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{})});
  1069. //>>excludeEnd("ctx");
  1070. }; }),
  1071. $globals.CodeGeneratorTest);
  1072. $core.addMethod(
  1073. $core.method({
  1074. selector: "testNestedSends",
  1075. protocol: "tests",
  1076. //>>excludeStart("ide", pragmas.excludeIdeData);
  1077. args: [],
  1078. source: "testNestedSends\x0a\x09self should: 'foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString' return: (Point x: (2@3) y: 4) asString",
  1079. referencedClasses: ["Point"],
  1080. //>>excludeEnd("ide");
  1081. pragmas: [],
  1082. messageSends: ["should:return:", "asString", "x:y:", "@"]
  1083. }, function ($methodClass){ return function (){
  1084. var self=this,$self=this;
  1085. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1086. return $core.withContext(function($ctx1) {
  1087. //>>excludeEnd("ctx");
  1088. $self._should_return_("foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString",$recv($recv($globals.Point)._x_y_((2).__at((3)),(4)))._asString());
  1089. return self;
  1090. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1091. }, function($ctx1) {$ctx1.fill(self,"testNestedSends",{})});
  1092. //>>excludeEnd("ctx");
  1093. }; }),
  1094. $globals.CodeGeneratorTest);
  1095. $core.addMethod(
  1096. $core.method({
  1097. selector: "testNilPerform",
  1098. protocol: "tests",
  1099. //>>excludeStart("ide", pragmas.excludeIdeData);
  1100. args: [],
  1101. source: "testNilPerform\x0a\x09self should: 'foo ^ nil perform: #yourself' return: nil",
  1102. referencedClasses: [],
  1103. //>>excludeEnd("ide");
  1104. pragmas: [],
  1105. messageSends: ["should:return:"]
  1106. }, function ($methodClass){ return function (){
  1107. var self=this,$self=this;
  1108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1109. return $core.withContext(function($ctx1) {
  1110. //>>excludeEnd("ctx");
  1111. $self._should_return_("foo ^ nil perform: #yourself",nil);
  1112. return self;
  1113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1114. }, function($ctx1) {$ctx1.fill(self,"testNilPerform",{})});
  1115. //>>excludeEnd("ctx");
  1116. }; }),
  1117. $globals.CodeGeneratorTest);
  1118. $core.addMethod(
  1119. $core.method({
  1120. selector: "testNonLocalReturn",
  1121. protocol: "tests",
  1122. //>>excludeStart("ide", pragmas.excludeIdeData);
  1123. args: [],
  1124. source: "testNonLocalReturn\x0a\x09self should: 'foo [ ^ 1 ] value' return: 1.\x0a\x09self should: 'foo [ ^ 1 + 1 ] value' return: 2.\x0a\x09self should: 'foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt' return: 3.\x0a\x09self should: 'foo [ :x | ^ x + x ] value: 4. ^ 2' return: 8",
  1125. referencedClasses: [],
  1126. //>>excludeEnd("ide");
  1127. pragmas: [],
  1128. messageSends: ["should:return:"]
  1129. }, function ($methodClass){ return function (){
  1130. var self=this,$self=this;
  1131. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1132. return $core.withContext(function($ctx1) {
  1133. //>>excludeEnd("ctx");
  1134. $self._should_return_("foo [ ^ 1 ] value",(1));
  1135. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1136. $ctx1.sendIdx["should:return:"]=1;
  1137. //>>excludeEnd("ctx");
  1138. $self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  1139. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1140. $ctx1.sendIdx["should:return:"]=2;
  1141. //>>excludeEnd("ctx");
  1142. $self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  1143. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1144. $ctx1.sendIdx["should:return:"]=3;
  1145. //>>excludeEnd("ctx");
  1146. $self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  1147. return self;
  1148. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1149. }, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{})});
  1150. //>>excludeEnd("ctx");
  1151. }; }),
  1152. $globals.CodeGeneratorTest);
  1153. $core.addMethod(
  1154. $core.method({
  1155. selector: "testPascalCaseGlobal",
  1156. protocol: "tests",
  1157. //>>excludeStart("ide", pragmas.excludeIdeData);
  1158. args: [],
  1159. source: "testPascalCaseGlobal\x0a\x09self should: 'foo ^Object' return: (Smalltalk globals at: 'Object').\x0a\x09self should: 'foo ^NonExistent' return: nil",
  1160. referencedClasses: ["Smalltalk"],
  1161. //>>excludeEnd("ide");
  1162. pragmas: [],
  1163. messageSends: ["should:return:", "at:", "globals"]
  1164. }, function ($methodClass){ return function (){
  1165. var self=this,$self=this;
  1166. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1167. return $core.withContext(function($ctx1) {
  1168. //>>excludeEnd("ctx");
  1169. $self._should_return_("foo ^Object",$recv($recv($globals.Smalltalk)._globals())._at_("Object"));
  1170. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1171. $ctx1.sendIdx["should:return:"]=1;
  1172. //>>excludeEnd("ctx");
  1173. $self._should_return_("foo ^NonExistent",nil);
  1174. return self;
  1175. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1176. }, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{})});
  1177. //>>excludeEnd("ctx");
  1178. }; }),
  1179. $globals.CodeGeneratorTest);
  1180. $core.addMethod(
  1181. $core.method({
  1182. selector: "testPragmaJSStatement",
  1183. protocol: "tests",
  1184. //>>excludeStart("ide", pragmas.excludeIdeData);
  1185. args: [],
  1186. source: "testPragmaJSStatement\x0a\x09self should: 'foo < inlineJS: ''return 2+3'' >' return: 5",
  1187. referencedClasses: [],
  1188. //>>excludeEnd("ide");
  1189. pragmas: [],
  1190. messageSends: ["should:return:"]
  1191. }, function ($methodClass){ return function (){
  1192. var self=this,$self=this;
  1193. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1194. return $core.withContext(function($ctx1) {
  1195. //>>excludeEnd("ctx");
  1196. $self._should_return_("foo < inlineJS: 'return 2+3' >",(5));
  1197. return self;
  1198. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1199. }, function($ctx1) {$ctx1.fill(self,"testPragmaJSStatement",{})});
  1200. //>>excludeEnd("ctx");
  1201. }; }),
  1202. $globals.CodeGeneratorTest);
  1203. $core.addMethod(
  1204. $core.method({
  1205. selector: "testRootSuperSend",
  1206. protocol: "tests",
  1207. //>>excludeStart("ide", pragmas.excludeIdeData);
  1208. args: [],
  1209. source: "testRootSuperSend\x0a\x09self \x0a\x09\x09should: 'foo ^ super class' \x0a\x09\x09receiver: ProtoObject new\x0a\x09\x09raise: MessageNotUnderstood",
  1210. referencedClasses: ["ProtoObject", "MessageNotUnderstood"],
  1211. //>>excludeEnd("ide");
  1212. pragmas: [],
  1213. messageSends: ["should:receiver:raise:", "new"]
  1214. }, function ($methodClass){ return function (){
  1215. var self=this,$self=this;
  1216. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1217. return $core.withContext(function($ctx1) {
  1218. //>>excludeEnd("ctx");
  1219. $self._should_receiver_raise_("foo ^ super class",$recv($globals.ProtoObject)._new(),$globals.MessageNotUnderstood);
  1220. return self;
  1221. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1222. }, function($ctx1) {$ctx1.fill(self,"testRootSuperSend",{})});
  1223. //>>excludeEnd("ctx");
  1224. }; }),
  1225. $globals.CodeGeneratorTest);
  1226. $core.addMethod(
  1227. $core.method({
  1228. selector: "testSendReceiverAndArgumentsOrdered",
  1229. protocol: "tests",
  1230. //>>excludeStart("ide", pragmas.excludeIdeData);
  1231. args: [],
  1232. source: "testSendReceiverAndArgumentsOrdered\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a' return: #(1 2).\x0a\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a' return: {Array. 2}.",
  1233. referencedClasses: ["Array"],
  1234. //>>excludeEnd("ide");
  1235. pragmas: [],
  1236. messageSends: ["should:return:"]
  1237. }, function ($methodClass){ return function (){
  1238. var self=this,$self=this;
  1239. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1240. return $core.withContext(function($ctx1) {
  1241. //>>excludeEnd("ctx");
  1242. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  1243. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1244. $ctx1.sendIdx["should:return:"]=1;
  1245. //>>excludeEnd("ctx");
  1246. $self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$globals.Array,(2)]);
  1247. return self;
  1248. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1249. }, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{})});
  1250. //>>excludeEnd("ctx");
  1251. }; }),
  1252. $globals.CodeGeneratorTest);
  1253. $core.addMethod(
  1254. $core.method({
  1255. selector: "testSuperSend",
  1256. protocol: "tests",
  1257. //>>excludeStart("ide", pragmas.excludeIdeData);
  1258. args: [],
  1259. source: "testSuperSend\x0a\x09self \x0a\x09\x09should: 'foo ^ super isBoolean' \x0a\x09\x09receiver: true\x0a\x09\x09return: false",
  1260. referencedClasses: [],
  1261. //>>excludeEnd("ide");
  1262. pragmas: [],
  1263. messageSends: ["should:receiver:return:"]
  1264. }, function ($methodClass){ return function (){
  1265. var self=this,$self=this;
  1266. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1267. return $core.withContext(function($ctx1) {
  1268. //>>excludeEnd("ctx");
  1269. $self._should_receiver_return_("foo ^ super isBoolean",true,false);
  1270. return self;
  1271. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1272. }, function($ctx1) {$ctx1.fill(self,"testSuperSend",{})});
  1273. //>>excludeEnd("ctx");
  1274. }; }),
  1275. $globals.CodeGeneratorTest);
  1276. $core.addMethod(
  1277. $core.method({
  1278. selector: "testSuperSend2",
  1279. protocol: "tests",
  1280. //>>excludeStart("ide", pragmas.excludeIdeData);
  1281. args: [],
  1282. source: "testSuperSend2\x0a\x09self \x0a\x09\x09should: 'foo ^ super isNil'\x0a\x09\x09receiver: nil\x0a\x09\x09return: false",
  1283. referencedClasses: [],
  1284. //>>excludeEnd("ide");
  1285. pragmas: [],
  1286. messageSends: ["should:receiver:return:"]
  1287. }, function ($methodClass){ return function (){
  1288. var self=this,$self=this;
  1289. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1290. return $core.withContext(function($ctx1) {
  1291. //>>excludeEnd("ctx");
  1292. $self._should_receiver_return_("foo ^ super isNil",nil,false);
  1293. return self;
  1294. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1295. }, function($ctx1) {$ctx1.fill(self,"testSuperSend2",{})});
  1296. //>>excludeEnd("ctx");
  1297. }; }),
  1298. $globals.CodeGeneratorTest);
  1299. $core.addMethod(
  1300. $core.method({
  1301. selector: "testSuperSend3",
  1302. protocol: "tests",
  1303. //>>excludeStart("ide", pragmas.excludeIdeData);
  1304. args: [],
  1305. source: "testSuperSend3\x0a\x09self \x0a\x09\x09should: 'doo ^ super isNil'\x0a\x09\x09class: Object\x0a\x09\x09receiver: nil\x0a\x09\x09return: false",
  1306. referencedClasses: ["Object"],
  1307. //>>excludeEnd("ide");
  1308. pragmas: [],
  1309. messageSends: ["should:class:receiver:return:"]
  1310. }, function ($methodClass){ return function (){
  1311. var self=this,$self=this;
  1312. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1313. return $core.withContext(function($ctx1) {
  1314. //>>excludeEnd("ctx");
  1315. $self._should_class_receiver_return_("doo ^ super isNil",$globals.Object,nil,false);
  1316. return self;
  1317. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1318. }, function($ctx1) {$ctx1.fill(self,"testSuperSend3",{})});
  1319. //>>excludeEnd("ctx");
  1320. }; }),
  1321. $globals.CodeGeneratorTest);
  1322. $core.addMethod(
  1323. $core.method({
  1324. selector: "testSuperSend4",
  1325. protocol: "tests",
  1326. //>>excludeStart("ide", pragmas.excludeIdeData);
  1327. args: [],
  1328. source: "testSuperSend4\x0a\x09self \x0a\x09\x09should: 'foo ^ super asJavaScriptObject'\x0a\x09\x09receiver: 'me'\x0a\x09\x09return: #('m' 'e')",
  1329. referencedClasses: [],
  1330. //>>excludeEnd("ide");
  1331. pragmas: [],
  1332. messageSends: ["should:receiver:return:"]
  1333. }, function ($methodClass){ return function (){
  1334. var self=this,$self=this;
  1335. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1336. return $core.withContext(function($ctx1) {
  1337. //>>excludeEnd("ctx");
  1338. $self._should_receiver_return_("foo ^ super asJavaScriptObject","me",["m", "e"]);
  1339. return self;
  1340. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1341. }, function($ctx1) {$ctx1.fill(self,"testSuperSend4",{})});
  1342. //>>excludeEnd("ctx");
  1343. }; }),
  1344. $globals.CodeGeneratorTest);
  1345. $core.addMethod(
  1346. $core.method({
  1347. selector: "testSuperSend5",
  1348. protocol: "tests",
  1349. //>>excludeStart("ide", pragmas.excludeIdeData);
  1350. args: [],
  1351. source: "testSuperSend5\x0a\x09self \x0a\x09\x09should: 'foo [super addLast: 4] on: Error do: [ self add: 5 ]. ^ self'\x0a\x09\x09class: SequenceableCollection\x0a\x09\x09receiver: #(1 2 3)\x0a\x09\x09return: #(1 2 3 5)",
  1352. referencedClasses: ["SequenceableCollection"],
  1353. //>>excludeEnd("ide");
  1354. pragmas: [],
  1355. messageSends: ["should:class:receiver:return:"]
  1356. }, function ($methodClass){ return function (){
  1357. var self=this,$self=this;
  1358. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1359. return $core.withContext(function($ctx1) {
  1360. //>>excludeEnd("ctx");
  1361. $self._should_class_receiver_return_("foo [super addLast: 4] on: Error do: [ self add: 5 ]. ^ self",$globals.SequenceableCollection,[(1), (2), (3)],[(1), (2), (3), (5)]);
  1362. return self;
  1363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1364. }, function($ctx1) {$ctx1.fill(self,"testSuperSend5",{})});
  1365. //>>excludeEnd("ctx");
  1366. }; }),
  1367. $globals.CodeGeneratorTest);
  1368. $core.addMethod(
  1369. $core.method({
  1370. selector: "testTempVariables",
  1371. protocol: "tests",
  1372. //>>excludeStart("ide", pragmas.excludeIdeData);
  1373. args: [],
  1374. source: "testTempVariables\x0a\x09self should: 'foo | a | ^ a' return: nil.\x0a\x09self should: 'foo | AVariable | ^ AVariable' return: nil.\x0a\x09self should: 'foo | a b c | ^ c' return: nil.\x0a\x09self should: 'foo | a | [ | d | ^ d ] value' return: nil.\x0a\x09\x0a\x09self should: 'foo | a | a:= 1. ^ a' return: 1.\x0a\x09self should: 'foo | AVariable | AVariable := 1. ^ AVariable' return: 1.",
  1375. referencedClasses: [],
  1376. //>>excludeEnd("ide");
  1377. pragmas: [],
  1378. messageSends: ["should:return:"]
  1379. }, function ($methodClass){ return function (){
  1380. var self=this,$self=this;
  1381. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1382. return $core.withContext(function($ctx1) {
  1383. //>>excludeEnd("ctx");
  1384. $self._should_return_("foo | a | ^ a",nil);
  1385. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1386. $ctx1.sendIdx["should:return:"]=1;
  1387. //>>excludeEnd("ctx");
  1388. $self._should_return_("foo | AVariable | ^ AVariable",nil);
  1389. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1390. $ctx1.sendIdx["should:return:"]=2;
  1391. //>>excludeEnd("ctx");
  1392. $self._should_return_("foo | a b c | ^ c",nil);
  1393. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1394. $ctx1.sendIdx["should:return:"]=3;
  1395. //>>excludeEnd("ctx");
  1396. $self._should_return_("foo | a | [ | d | ^ d ] value",nil);
  1397. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1398. $ctx1.sendIdx["should:return:"]=4;
  1399. //>>excludeEnd("ctx");
  1400. $self._should_return_("foo | a | a:= 1. ^ a",(1));
  1401. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1402. $ctx1.sendIdx["should:return:"]=5;
  1403. //>>excludeEnd("ctx");
  1404. $self._should_return_("foo | AVariable | AVariable := 1. ^ AVariable",(1));
  1405. return self;
  1406. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1407. }, function($ctx1) {$ctx1.fill(self,"testTempVariables",{})});
  1408. //>>excludeEnd("ctx");
  1409. }; }),
  1410. $globals.CodeGeneratorTest);
  1411. $core.addMethod(
  1412. $core.method({
  1413. selector: "testThisContext",
  1414. protocol: "tests",
  1415. //>>excludeStart("ide", pragmas.excludeIdeData);
  1416. args: [],
  1417. source: "testThisContext\x0a\x09self should: 'foo ^ [ thisContext ] value outerContext == thisContext' return: true",
  1418. referencedClasses: [],
  1419. //>>excludeEnd("ide");
  1420. pragmas: [],
  1421. messageSends: ["should:return:"]
  1422. }, function ($methodClass){ return function (){
  1423. var self=this,$self=this;
  1424. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1425. return $core.withContext(function($ctx1) {
  1426. //>>excludeEnd("ctx");
  1427. $self._should_return_("foo ^ [ thisContext ] value outerContext == thisContext",true);
  1428. return self;
  1429. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1430. }, function($ctx1) {$ctx1.fill(self,"testThisContext",{})});
  1431. //>>excludeEnd("ctx");
  1432. }; }),
  1433. $globals.CodeGeneratorTest);
  1434. $core.addMethod(
  1435. $core.method({
  1436. selector: "testUnknownPragma",
  1437. protocol: "tests",
  1438. //>>excludeStart("ide", pragmas.excludeIdeData);
  1439. args: [],
  1440. source: "testUnknownPragma\x0a\x09self should: 'foo < fooBar: ''return 2+3'' > | x | ^ x := 6' return: 6.\x0a\x09self should: 'foo | x | < fooBar: ''return 2+3'' > ^ x := 6' return: 6",
  1441. referencedClasses: [],
  1442. //>>excludeEnd("ide");
  1443. pragmas: [],
  1444. messageSends: ["should:return:"]
  1445. }, function ($methodClass){ return function (){
  1446. var self=this,$self=this;
  1447. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1448. return $core.withContext(function($ctx1) {
  1449. //>>excludeEnd("ctx");
  1450. $self._should_return_("foo < fooBar: 'return 2+3' > | x | ^ x := 6",(6));
  1451. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1452. $ctx1.sendIdx["should:return:"]=1;
  1453. //>>excludeEnd("ctx");
  1454. $self._should_return_("foo | x | < fooBar: 'return 2+3' > ^ x := 6",(6));
  1455. return self;
  1456. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1457. }, function($ctx1) {$ctx1.fill(self,"testUnknownPragma",{})});
  1458. //>>excludeEnd("ctx");
  1459. }; }),
  1460. $globals.CodeGeneratorTest);
  1461. $core.addMethod(
  1462. $core.method({
  1463. selector: "testifFalse",
  1464. protocol: "tests",
  1465. //>>excludeStart("ide", pragmas.excludeIdeData);
  1466. args: [],
  1467. source: "testifFalse\x0a\x09self should: 'foo true ifFalse: [ ^ 1 ]' return: receiver.\x0a\x09self should: 'foo false ifFalse: [ ^ 2 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ true ifFalse: [ 1 ]' return: nil.\x0a\x09self should: 'foo ^ false ifFalse: [ 2 ]' return: 2.",
  1468. referencedClasses: [],
  1469. //>>excludeEnd("ide");
  1470. pragmas: [],
  1471. messageSends: ["should:return:"]
  1472. }, function ($methodClass){ return function (){
  1473. var self=this,$self=this;
  1474. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1475. return $core.withContext(function($ctx1) {
  1476. //>>excludeEnd("ctx");
  1477. $self._should_return_("foo true ifFalse: [ ^ 1 ]",$self.receiver);
  1478. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1479. $ctx1.sendIdx["should:return:"]=1;
  1480. //>>excludeEnd("ctx");
  1481. $self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  1482. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1483. $ctx1.sendIdx["should:return:"]=2;
  1484. //>>excludeEnd("ctx");
  1485. $self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  1486. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1487. $ctx1.sendIdx["should:return:"]=3;
  1488. //>>excludeEnd("ctx");
  1489. $self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  1490. return self;
  1491. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1492. }, function($ctx1) {$ctx1.fill(self,"testifFalse",{})});
  1493. //>>excludeEnd("ctx");
  1494. }; }),
  1495. $globals.CodeGeneratorTest);
  1496. $core.addMethod(
  1497. $core.method({
  1498. selector: "testifFalseIfTrue",
  1499. protocol: "tests",
  1500. //>>excludeStart("ide", pragmas.excludeIdeData);
  1501. args: [],
  1502. source: "testifFalseIfTrue\x0a\x09self should: 'foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]' return: 2.\x0a\x09self should: 'foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]' return: 2.\x0a\x09self should: 'foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]' return: 2.",
  1503. referencedClasses: [],
  1504. //>>excludeEnd("ide");
  1505. pragmas: [],
  1506. messageSends: ["should:return:"]
  1507. }, function ($methodClass){ return function (){
  1508. var self=this,$self=this;
  1509. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1510. return $core.withContext(function($ctx1) {
  1511. //>>excludeEnd("ctx");
  1512. $self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  1513. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1514. $ctx1.sendIdx["should:return:"]=1;
  1515. //>>excludeEnd("ctx");
  1516. $self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  1517. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1518. $ctx1.sendIdx["should:return:"]=2;
  1519. //>>excludeEnd("ctx");
  1520. $self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  1521. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1522. $ctx1.sendIdx["should:return:"]=3;
  1523. //>>excludeEnd("ctx");
  1524. $self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  1525. return self;
  1526. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1527. }, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{})});
  1528. //>>excludeEnd("ctx");
  1529. }; }),
  1530. $globals.CodeGeneratorTest);
  1531. $core.addMethod(
  1532. $core.method({
  1533. selector: "testifNil",
  1534. protocol: "tests",
  1535. //>>excludeStart("ide", pragmas.excludeIdeData);
  1536. args: [],
  1537. source: "testifNil\x0a\x09self should: 'foo ^ 1 ifNil: [ 2 ]' return: 1.\x0a\x09self should: 'foo ^ nil ifNil: [ 2 ]' return: 2.\x0a\x0a\x09self should: 'foo 1 ifNil: [ ^ 2 ]' return: receiver.\x0a\x09self should: 'foo nil ifNil: [ ^ 2 ]' return: 2.",
  1538. referencedClasses: [],
  1539. //>>excludeEnd("ide");
  1540. pragmas: [],
  1541. messageSends: ["should:return:"]
  1542. }, function ($methodClass){ return function (){
  1543. var self=this,$self=this;
  1544. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1545. return $core.withContext(function($ctx1) {
  1546. //>>excludeEnd("ctx");
  1547. $self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  1548. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1549. $ctx1.sendIdx["should:return:"]=1;
  1550. //>>excludeEnd("ctx");
  1551. $self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  1552. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1553. $ctx1.sendIdx["should:return:"]=2;
  1554. //>>excludeEnd("ctx");
  1555. $self._should_return_("foo 1 ifNil: [ ^ 2 ]",$self.receiver);
  1556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1557. $ctx1.sendIdx["should:return:"]=3;
  1558. //>>excludeEnd("ctx");
  1559. $self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  1560. return self;
  1561. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1562. }, function($ctx1) {$ctx1.fill(self,"testifNil",{})});
  1563. //>>excludeEnd("ctx");
  1564. }; }),
  1565. $globals.CodeGeneratorTest);
  1566. $core.addMethod(
  1567. $core.method({
  1568. selector: "testifNilIfNotNil",
  1569. protocol: "tests",
  1570. //>>excludeStart("ide", pragmas.excludeIdeData);
  1571. args: [],
  1572. source: "testifNilIfNotNil\x0a\x09self should: 'foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 3.\x0a\x09self should: 'foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]' return: 2.\x0a\x0a\x09self should: 'foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 3.\x0a\x09self should: 'foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]' return: 2.",
  1573. referencedClasses: [],
  1574. //>>excludeEnd("ide");
  1575. pragmas: [],
  1576. messageSends: ["should:return:"]
  1577. }, function ($methodClass){ return function (){
  1578. var self=this,$self=this;
  1579. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1580. return $core.withContext(function($ctx1) {
  1581. //>>excludeEnd("ctx");
  1582. $self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  1583. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1584. $ctx1.sendIdx["should:return:"]=1;
  1585. //>>excludeEnd("ctx");
  1586. $self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  1587. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1588. $ctx1.sendIdx["should:return:"]=2;
  1589. //>>excludeEnd("ctx");
  1590. $self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  1591. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1592. $ctx1.sendIdx["should:return:"]=3;
  1593. //>>excludeEnd("ctx");
  1594. $self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  1595. return self;
  1596. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1597. }, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{})});
  1598. //>>excludeEnd("ctx");
  1599. }; }),
  1600. $globals.CodeGeneratorTest);
  1601. $core.addMethod(
  1602. $core.method({
  1603. selector: "testifNotNil",
  1604. protocol: "tests",
  1605. //>>excludeStart("ide", pragmas.excludeIdeData);
  1606. args: [],
  1607. source: "testifNotNil\x0a\x09self should: 'foo ^ 1 ifNotNil: [ 2 ]' return: 2.\x0a\x09self should: 'foo ^ nil ifNotNil: [ 2 ]' return: nil.\x0a\x0a\x09self should: 'foo 1 ifNotNil: [ ^ 2 ]' return: 2.\x0a\x09self should: 'foo nil ifNotNil: [ ^ 2 ]' return: receiver.",
  1608. referencedClasses: [],
  1609. //>>excludeEnd("ide");
  1610. pragmas: [],
  1611. messageSends: ["should:return:"]
  1612. }, function ($methodClass){ return function (){
  1613. var self=this,$self=this;
  1614. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1615. return $core.withContext(function($ctx1) {
  1616. //>>excludeEnd("ctx");
  1617. $self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  1618. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1619. $ctx1.sendIdx["should:return:"]=1;
  1620. //>>excludeEnd("ctx");
  1621. $self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  1622. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1623. $ctx1.sendIdx["should:return:"]=2;
  1624. //>>excludeEnd("ctx");
  1625. $self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  1626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1627. $ctx1.sendIdx["should:return:"]=3;
  1628. //>>excludeEnd("ctx");
  1629. $self._should_return_("foo nil ifNotNil: [ ^ 2 ]",$self.receiver);
  1630. return self;
  1631. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1632. }, function($ctx1) {$ctx1.fill(self,"testifNotNil",{})});
  1633. //>>excludeEnd("ctx");
  1634. }; }),
  1635. $globals.CodeGeneratorTest);
  1636. $core.addMethod(
  1637. $core.method({
  1638. selector: "testifNotNilWithArgument",
  1639. protocol: "tests",
  1640. //>>excludeStart("ide", pragmas.excludeIdeData);
  1641. args: [],
  1642. source: "testifNotNilWithArgument\x0a\x09self should: 'foo ^ 1 ifNotNil: [ :val | val + 2 ]' return: 3.\x0a\x09self should: 'foo ^ nil ifNotNil: [ :val | val + 2 ]' return: nil.\x0a\x09\x0a\x09self should: 'foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]' return: 3.\x0a\x09self should: 'foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]' return: 5.\x0a\x09\x0a\x09self should: 'foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]' return: 3.\x0a\x09self should: 'foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]' return: 5",
  1643. referencedClasses: [],
  1644. //>>excludeEnd("ide");
  1645. pragmas: [],
  1646. messageSends: ["should:return:"]
  1647. }, function ($methodClass){ return function (){
  1648. var self=this,$self=this;
  1649. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1650. return $core.withContext(function($ctx1) {
  1651. //>>excludeEnd("ctx");
  1652. $self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  1653. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1654. $ctx1.sendIdx["should:return:"]=1;
  1655. //>>excludeEnd("ctx");
  1656. $self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  1657. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1658. $ctx1.sendIdx["should:return:"]=2;
  1659. //>>excludeEnd("ctx");
  1660. $self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  1661. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1662. $ctx1.sendIdx["should:return:"]=3;
  1663. //>>excludeEnd("ctx");
  1664. $self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  1665. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1666. $ctx1.sendIdx["should:return:"]=4;
  1667. //>>excludeEnd("ctx");
  1668. $self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  1669. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1670. $ctx1.sendIdx["should:return:"]=5;
  1671. //>>excludeEnd("ctx");
  1672. $self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  1673. return self;
  1674. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1675. }, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{})});
  1676. //>>excludeEnd("ctx");
  1677. }; }),
  1678. $globals.CodeGeneratorTest);
  1679. $core.addMethod(
  1680. $core.method({
  1681. selector: "testifTrue",
  1682. protocol: "tests",
  1683. //>>excludeStart("ide", pragmas.excludeIdeData);
  1684. args: [],
  1685. source: "testifTrue\x0a\x09self should: 'foo false ifTrue: [ ^ 1 ]' return: receiver.\x0a\x09self should: 'foo true ifTrue: [ ^ 2 ]' return: 2.\x0a\x09\x0a\x09self should: 'foo ^ false ifTrue: [ 1 ]' return: nil.\x0a\x09self should: 'foo ^ true ifTrue: [ 2 ]' return: 2.",
  1686. referencedClasses: [],
  1687. //>>excludeEnd("ide");
  1688. pragmas: [],
  1689. messageSends: ["should:return:"]
  1690. }, function ($methodClass){ return function (){
  1691. var self=this,$self=this;
  1692. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1693. return $core.withContext(function($ctx1) {
  1694. //>>excludeEnd("ctx");
  1695. $self._should_return_("foo false ifTrue: [ ^ 1 ]",$self.receiver);
  1696. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1697. $ctx1.sendIdx["should:return:"]=1;
  1698. //>>excludeEnd("ctx");
  1699. $self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  1700. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1701. $ctx1.sendIdx["should:return:"]=2;
  1702. //>>excludeEnd("ctx");
  1703. $self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  1704. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1705. $ctx1.sendIdx["should:return:"]=3;
  1706. //>>excludeEnd("ctx");
  1707. $self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  1708. return self;
  1709. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1710. }, function($ctx1) {$ctx1.fill(self,"testifTrue",{})});
  1711. //>>excludeEnd("ctx");
  1712. }; }),
  1713. $globals.CodeGeneratorTest);
  1714. $core.addMethod(
  1715. $core.method({
  1716. selector: "testifTrueIfFalse",
  1717. protocol: "tests",
  1718. //>>excludeStart("ide", pragmas.excludeIdeData);
  1719. args: [],
  1720. source: "testifTrueIfFalse\x0a\x09self should: 'foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]' return: 2.\x0a\x09self should: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]' return: 1.\x0a\x09\x0a\x09self should: 'foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 1.\x0a\x09self should: 'foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]' return: 2.",
  1721. referencedClasses: [],
  1722. //>>excludeEnd("ide");
  1723. pragmas: [],
  1724. messageSends: ["should:return:"]
  1725. }, function ($methodClass){ return function (){
  1726. var self=this,$self=this;
  1727. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1728. return $core.withContext(function($ctx1) {
  1729. //>>excludeEnd("ctx");
  1730. $self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  1731. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1732. $ctx1.sendIdx["should:return:"]=1;
  1733. //>>excludeEnd("ctx");
  1734. $self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  1735. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1736. $ctx1.sendIdx["should:return:"]=2;
  1737. //>>excludeEnd("ctx");
  1738. $self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  1739. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1740. $ctx1.sendIdx["should:return:"]=3;
  1741. //>>excludeEnd("ctx");
  1742. $self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  1743. return self;
  1744. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1745. }, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{})});
  1746. //>>excludeEnd("ctx");
  1747. }; }),
  1748. $globals.CodeGeneratorTest);
  1749. $core.addClass("ASTInterpreterTest", $globals.CodeGeneratorTest, [], "Compiler-Tests");
  1750. $core.addMethod(
  1751. $core.method({
  1752. selector: "actOn:in:",
  1753. protocol: "running",
  1754. //>>excludeStart("ide", pragmas.excludeIdeData);
  1755. args: ["aMethod", "aClass"],
  1756. source: "actOn: aMethod in: aClass\x0a\x09^ self\x0a\x09\x09interpret: aMethod source\x0a\x09\x09forClass: aClass\x0a\x09\x09receiver: receiver\x0a\x09\x09withArguments: #{}",
  1757. referencedClasses: [],
  1758. //>>excludeEnd("ide");
  1759. pragmas: [],
  1760. messageSends: ["interpret:forClass:receiver:withArguments:", "source"]
  1761. }, function ($methodClass){ return function (aMethod,aClass){
  1762. var self=this,$self=this;
  1763. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1764. return $core.withContext(function($ctx1) {
  1765. //>>excludeEnd("ctx");
  1766. return $self._interpret_forClass_receiver_withArguments_($recv(aMethod)._source(),aClass,$self.receiver,$globals.HashedCollection._newFromPairs_([]));
  1767. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1768. }, function($ctx1) {$ctx1.fill(self,"actOn:in:",{aMethod:aMethod,aClass:aClass})});
  1769. //>>excludeEnd("ctx");
  1770. }; }),
  1771. $globals.ASTInterpreterTest);
  1772. $core.addMethod(
  1773. $core.method({
  1774. selector: "interpret:forClass:receiver:withArguments:",
  1775. protocol: "private",
  1776. //>>excludeStart("ide", pragmas.excludeIdeData);
  1777. args: ["aString", "aClass", "anObject", "aDictionary"],
  1778. source: "interpret: aString forClass: aClass receiver: anObject withArguments: aDictionary\x0a\x09\x22The food is a methodNode. Interpret the sequenceNode only\x22\x0a\x09\x0a\x09| ctx |\x0a\x09\x0a\x09ctx := self prepareContextFor: aString class: aClass receiver: anObject withArguments: aDictionary.\x0a\x09\x0a\x09^ ctx interpreter proceed; result",
  1779. referencedClasses: [],
  1780. //>>excludeEnd("ide");
  1781. pragmas: [],
  1782. messageSends: ["prepareContextFor:class:receiver:withArguments:", "proceed", "interpreter", "result"]
  1783. }, function ($methodClass){ return function (aString,aClass,anObject,aDictionary){
  1784. var self=this,$self=this;
  1785. var ctx;
  1786. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1787. return $core.withContext(function($ctx1) {
  1788. //>>excludeEnd("ctx");
  1789. var $1;
  1790. ctx=$self._prepareContextFor_class_receiver_withArguments_(aString,aClass,anObject,aDictionary);
  1791. $1=$recv(ctx)._interpreter();
  1792. $recv($1)._proceed();
  1793. return $recv($1)._result();
  1794. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1795. }, function($ctx1) {$ctx1.fill(self,"interpret:forClass:receiver:withArguments:",{aString:aString,aClass:aClass,anObject:anObject,aDictionary:aDictionary,ctx:ctx})});
  1796. //>>excludeEnd("ctx");
  1797. }; }),
  1798. $globals.ASTInterpreterTest);
  1799. $core.addMethod(
  1800. $core.method({
  1801. selector: "prepareContextFor:class:receiver:withArguments:",
  1802. protocol: "private",
  1803. //>>excludeStart("ide", pragmas.excludeIdeData);
  1804. args: ["aString", "aClass", "anObject", "aDictionary"],
  1805. source: "prepareContextFor: aString class: aClass receiver: anObject withArguments: aDictionary\x0a\x09\x22The food is a methodNode. Interpret the sequenceNode only\x22\x0a\x09\x0a\x09| ctx ast |\x0a\x09\x0a\x09ast := self parse: aString forClass: aClass.\x0a\x09\x0a\x09ctx := AIContext new\x0a\x09\x09receiver: anObject;\x0a\x09\x09selector: ast selector;\x0a\x09\x09interpreter: ASTInterpreter new;\x0a\x09\x09yourself.\x0a\x09\x09\x0a\x09\x22Define locals for the context\x22\x0a\x09ast sequenceNode ifNotNil: [ :sequence |\x0a\x09\x09sequence temps do: [ :each |\x0a\x09\x09\x09ctx defineLocal: each ] ].\x0a\x09\x09\x0a\x09aDictionary keysAndValuesDo: [ :key :value |\x0a\x09\x09ctx localAt: key put: value ].\x0a\x09\x0a\x09ctx interpreter\x0a\x09\x09context: ctx;\x0a\x09\x09node: ast;\x0a\x09\x09enterNode.\x0a\x09\x0a\x09^ctx",
  1806. referencedClasses: ["AIContext", "ASTInterpreter"],
  1807. //>>excludeEnd("ide");
  1808. pragmas: [],
  1809. messageSends: ["parse:forClass:", "receiver:", "new", "selector:", "selector", "interpreter:", "yourself", "ifNotNil:", "sequenceNode", "do:", "temps", "defineLocal:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "node:", "enterNode"]
  1810. }, function ($methodClass){ return function (aString,aClass,anObject,aDictionary){
  1811. var self=this,$self=this;
  1812. var ctx,ast;
  1813. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1814. return $core.withContext(function($ctx1) {
  1815. //>>excludeEnd("ctx");
  1816. var $1,$2,$3,$receiver;
  1817. ast=$self._parse_forClass_(aString,aClass);
  1818. $1=$recv($globals.AIContext)._new();
  1819. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1820. $ctx1.sendIdx["new"]=1;
  1821. //>>excludeEnd("ctx");
  1822. $recv($1)._receiver_(anObject);
  1823. $recv($1)._selector_($recv(ast)._selector());
  1824. $recv($1)._interpreter_($recv($globals.ASTInterpreter)._new());
  1825. ctx=$recv($1)._yourself();
  1826. $2=$recv(ast)._sequenceNode();
  1827. if(($receiver = $2) == null || $receiver.a$nil){
  1828. $2;
  1829. } else {
  1830. var sequence;
  1831. sequence=$receiver;
  1832. $recv($recv(sequence)._temps())._do_((function(each){
  1833. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1834. return $core.withContext(function($ctx2) {
  1835. //>>excludeEnd("ctx");
  1836. return $recv(ctx)._defineLocal_(each);
  1837. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1838. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  1839. //>>excludeEnd("ctx");
  1840. }));
  1841. }
  1842. $recv(aDictionary)._keysAndValuesDo_((function(key,value){
  1843. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1844. return $core.withContext(function($ctx2) {
  1845. //>>excludeEnd("ctx");
  1846. return $recv(ctx)._localAt_put_(key,value);
  1847. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1848. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,3)});
  1849. //>>excludeEnd("ctx");
  1850. }));
  1851. $3=$recv(ctx)._interpreter();
  1852. $recv($3)._context_(ctx);
  1853. $recv($3)._node_(ast);
  1854. $recv($3)._enterNode();
  1855. return ctx;
  1856. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1857. }, function($ctx1) {$ctx1.fill(self,"prepareContextFor:class:receiver:withArguments:",{aString:aString,aClass:aClass,anObject:anObject,aDictionary:aDictionary,ctx:ctx,ast:ast})});
  1858. //>>excludeEnd("ctx");
  1859. }; }),
  1860. $globals.ASTInterpreterTest);
  1861. $core.addClass("ASTDebuggerTest", $globals.ASTInterpreterTest, [], "Compiler-Tests");
  1862. $core.addMethod(
  1863. $core.method({
  1864. selector: "interpret:forClass:receiver:withArguments:",
  1865. protocol: "private",
  1866. //>>excludeStart("ide", pragmas.excludeIdeData);
  1867. args: ["aString", "aClass", "anObject", "aDictionary"],
  1868. source: "interpret: aString forClass: aClass receiver: anObject withArguments: aDictionary\x0a\x09\x22The food is a methodNode. Interpret the sequenceNode only\x22\x0a\x09\x0a\x09| ctx |\x0a\x09\x0a\x09ctx := self prepareContextFor: aString class: aClass receiver: anObject withArguments: aDictionary.\x0a\x09\x0a\x09^ (ASTDebugger context: ctx) proceed; result",
  1869. referencedClasses: ["ASTDebugger"],
  1870. //>>excludeEnd("ide");
  1871. pragmas: [],
  1872. messageSends: ["prepareContextFor:class:receiver:withArguments:", "proceed", "context:", "result"]
  1873. }, function ($methodClass){ return function (aString,aClass,anObject,aDictionary){
  1874. var self=this,$self=this;
  1875. var ctx;
  1876. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1877. return $core.withContext(function($ctx1) {
  1878. //>>excludeEnd("ctx");
  1879. var $1;
  1880. ctx=$self._prepareContextFor_class_receiver_withArguments_(aString,aClass,anObject,aDictionary);
  1881. $1=$recv($globals.ASTDebugger)._context_(ctx);
  1882. $recv($1)._proceed();
  1883. return $recv($1)._result();
  1884. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1885. }, function($ctx1) {$ctx1.fill(self,"interpret:forClass:receiver:withArguments:",{aString:aString,aClass:aClass,anObject:anObject,aDictionary:aDictionary,ctx:ctx})});
  1886. //>>excludeEnd("ctx");
  1887. }; }),
  1888. $globals.ASTDebuggerTest);
  1889. $core.addClass("InliningCodeGeneratorTest", $globals.CodeGeneratorTest, [], "Compiler-Tests");
  1890. $core.addMethod(
  1891. $core.method({
  1892. selector: "codeGeneratorClass",
  1893. protocol: "accessing",
  1894. //>>excludeStart("ide", pragmas.excludeIdeData);
  1895. args: [],
  1896. source: "codeGeneratorClass\x0a\x09^ InliningCodeGenerator",
  1897. referencedClasses: ["InliningCodeGenerator"],
  1898. //>>excludeEnd("ide");
  1899. pragmas: [],
  1900. messageSends: []
  1901. }, function ($methodClass){ return function (){
  1902. var self=this,$self=this;
  1903. return $globals.InliningCodeGenerator;
  1904. }; }),
  1905. $globals.InliningCodeGeneratorTest);
  1906. $core.addClass("CodeGeneratorInstallTest", $globals.ASTCompilingTest, [], "Compiler-Tests");
  1907. $core.addMethod(
  1908. $core.method({
  1909. selector: "codeGeneratorClass",
  1910. protocol: "accessing",
  1911. //>>excludeStart("ide", pragmas.excludeIdeData);
  1912. args: [],
  1913. source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
  1914. referencedClasses: ["CodeGenerator"],
  1915. //>>excludeEnd("ide");
  1916. pragmas: [],
  1917. messageSends: []
  1918. }, function ($methodClass){ return function (){
  1919. var self=this,$self=this;
  1920. return $globals.CodeGenerator;
  1921. }; }),
  1922. $globals.CodeGeneratorInstallTest);
  1923. $core.addMethod(
  1924. $core.method({
  1925. selector: "shouldntInstall:",
  1926. protocol: "testing",
  1927. //>>excludeStart("ide", pragmas.excludeIdeData);
  1928. args: ["aString"],
  1929. source: "shouldntInstall: aString\x0a\x09| method |\x0a\x0a\x09[ self\x0a\x09\x09should: [ method := self install: aString forClass: receiver class ]\x0a\x09\x09raise: ParseError ]\x0a\x09ensure: [ method ifNotNil: [ receiver class removeCompiledMethod: method ] ]",
  1930. referencedClasses: ["ParseError"],
  1931. //>>excludeEnd("ide");
  1932. pragmas: [],
  1933. messageSends: ["ensure:", "should:raise:", "install:forClass:", "class", "ifNotNil:", "removeCompiledMethod:"]
  1934. }, function ($methodClass){ return function (aString){
  1935. var self=this,$self=this;
  1936. var method;
  1937. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1938. return $core.withContext(function($ctx1) {
  1939. //>>excludeEnd("ctx");
  1940. var $1,$2,$receiver;
  1941. $recv((function(){
  1942. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1943. return $core.withContext(function($ctx2) {
  1944. //>>excludeEnd("ctx");
  1945. return $self._should_raise_((function(){
  1946. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1947. return $core.withContext(function($ctx3) {
  1948. //>>excludeEnd("ctx");
  1949. $1=$recv($self.receiver)._class();
  1950. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1951. $ctx3.sendIdx["class"]=1;
  1952. //>>excludeEnd("ctx");
  1953. method=$self._install_forClass_(aString,$1);
  1954. return method;
  1955. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1956. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  1957. //>>excludeEnd("ctx");
  1958. }),$globals.ParseError);
  1959. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1960. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1961. //>>excludeEnd("ctx");
  1962. }))._ensure_((function(){
  1963. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1964. return $core.withContext(function($ctx2) {
  1965. //>>excludeEnd("ctx");
  1966. $2=method;
  1967. if(($receiver = $2) == null || $receiver.a$nil){
  1968. return $2;
  1969. } else {
  1970. return $recv($recv($self.receiver)._class())._removeCompiledMethod_(method);
  1971. }
  1972. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1973. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1974. //>>excludeEnd("ctx");
  1975. }));
  1976. return self;
  1977. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1978. }, function($ctx1) {$ctx1.fill(self,"shouldntInstall:",{aString:aString,method:method})});
  1979. //>>excludeEnd("ctx");
  1980. }; }),
  1981. $globals.CodeGeneratorInstallTest);
  1982. $core.addMethod(
  1983. $core.method({
  1984. selector: "testMistypedPragmaJSStatement",
  1985. protocol: "tests",
  1986. //>>excludeStart("ide", pragmas.excludeIdeData);
  1987. args: [],
  1988. source: "testMistypedPragmaJSStatement\x0a\x09self shouldntInstall: 'foo < inlineJS: ''return ''foo'''' >'",
  1989. referencedClasses: [],
  1990. //>>excludeEnd("ide");
  1991. pragmas: [],
  1992. messageSends: ["shouldntInstall:"]
  1993. }, function ($methodClass){ return function (){
  1994. var self=this,$self=this;
  1995. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1996. return $core.withContext(function($ctx1) {
  1997. //>>excludeEnd("ctx");
  1998. $self._shouldntInstall_("foo < inlineJS: 'return 'foo'' >");
  1999. return self;
  2000. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2001. }, function($ctx1) {$ctx1.fill(self,"testMistypedPragmaJSStatement",{})});
  2002. //>>excludeEnd("ctx");
  2003. }; }),
  2004. $globals.CodeGeneratorInstallTest);
  2005. $core.addMethod(
  2006. $core.method({
  2007. selector: "testNiladicJSOverride",
  2008. protocol: "tests",
  2009. //>>excludeStart("ide", pragmas.excludeIdeData);
  2010. args: [],
  2011. source: "testNiladicJSOverride\x0a\x09receiver := ObjectMock new.\x0a\x09receiver foo: 4.\x0a\x09self while: 'baz <jsOverride: #baz> ^ (foo := foo + 3)' should: [\x0a\x09\x09self assert: receiver baz equals: 7.\x0a\x09\x09self assert: (receiver basicPerform: #baz) equals: 10.\x0a\x09\x09self assert: receiver baz equals: 13.\x0a\x09\x09self assert: receiver foo equals: 13 ]",
  2012. referencedClasses: ["ObjectMock"],
  2013. //>>excludeEnd("ide");
  2014. pragmas: [],
  2015. messageSends: ["new", "foo:", "while:should:", "assert:equals:", "baz", "basicPerform:", "foo"]
  2016. }, function ($methodClass){ return function (){
  2017. var self=this,$self=this;
  2018. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2019. return $core.withContext(function($ctx1) {
  2020. //>>excludeEnd("ctx");
  2021. var $1;
  2022. $self.receiver=$recv($globals.ObjectMock)._new();
  2023. $recv($self.receiver)._foo_((4));
  2024. $self._while_should_("baz <jsOverride: #baz> ^ (foo := foo + 3)",(function(){
  2025. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2026. return $core.withContext(function($ctx2) {
  2027. //>>excludeEnd("ctx");
  2028. $1=$recv($self.receiver)._baz();
  2029. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2030. $ctx2.sendIdx["baz"]=1;
  2031. //>>excludeEnd("ctx");
  2032. $self._assert_equals_($1,(7));
  2033. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2034. $ctx2.sendIdx["assert:equals:"]=1;
  2035. //>>excludeEnd("ctx");
  2036. $self._assert_equals_($recv($self.receiver)._basicPerform_("baz"),(10));
  2037. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2038. $ctx2.sendIdx["assert:equals:"]=2;
  2039. //>>excludeEnd("ctx");
  2040. $self._assert_equals_($recv($self.receiver)._baz(),(13));
  2041. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2042. $ctx2.sendIdx["assert:equals:"]=3;
  2043. //>>excludeEnd("ctx");
  2044. return $self._assert_equals_($recv($self.receiver)._foo(),(13));
  2045. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2046. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2047. //>>excludeEnd("ctx");
  2048. }));
  2049. return self;
  2050. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2051. }, function($ctx1) {$ctx1.fill(self,"testNiladicJSOverride",{})});
  2052. //>>excludeEnd("ctx");
  2053. }; }),
  2054. $globals.CodeGeneratorInstallTest);
  2055. $core.addMethod(
  2056. $core.method({
  2057. selector: "testNiladicJSOverrideDifferentNames",
  2058. protocol: "tests",
  2059. //>>excludeStart("ide", pragmas.excludeIdeData);
  2060. args: [],
  2061. source: "testNiladicJSOverrideDifferentNames\x0a\x09receiver := ObjectMock new.\x0a\x09receiver foo: 4.\x0a\x09self while: 'quux <jsOverride: #mux> ^ (foo := foo + 3)' should: [\x0a\x09\x09self should: [ receiver mux ] raise: MessageNotUnderstood.\x0a\x09\x09self assert: (receiver basicPerform: #mux) equals: 7.\x0a\x09\x09self assert: receiver quux equals: 10.\x0a\x09\x09self should: [ receiver basicPerform: #quux ] raise: Error.\x0a\x09\x09self assert: receiver foo equals: 10 ]",
  2062. referencedClasses: ["ObjectMock", "MessageNotUnderstood", "Error"],
  2063. //>>excludeEnd("ide");
  2064. pragmas: [],
  2065. messageSends: ["new", "foo:", "while:should:", "should:raise:", "mux", "assert:equals:", "basicPerform:", "quux", "foo"]
  2066. }, function ($methodClass){ return function (){
  2067. var self=this,$self=this;
  2068. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2069. return $core.withContext(function($ctx1) {
  2070. //>>excludeEnd("ctx");
  2071. var $1;
  2072. $self.receiver=$recv($globals.ObjectMock)._new();
  2073. $recv($self.receiver)._foo_((4));
  2074. $self._while_should_("quux <jsOverride: #mux> ^ (foo := foo + 3)",(function(){
  2075. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2076. return $core.withContext(function($ctx2) {
  2077. //>>excludeEnd("ctx");
  2078. $self._should_raise_((function(){
  2079. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2080. return $core.withContext(function($ctx3) {
  2081. //>>excludeEnd("ctx");
  2082. return $recv($self.receiver)._mux();
  2083. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2084. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  2085. //>>excludeEnd("ctx");
  2086. }),$globals.MessageNotUnderstood);
  2087. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2088. $ctx2.sendIdx["should:raise:"]=1;
  2089. //>>excludeEnd("ctx");
  2090. $1=$recv($self.receiver)._basicPerform_("mux");
  2091. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2092. $ctx2.sendIdx["basicPerform:"]=1;
  2093. //>>excludeEnd("ctx");
  2094. $self._assert_equals_($1,(7));
  2095. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2096. $ctx2.sendIdx["assert:equals:"]=1;
  2097. //>>excludeEnd("ctx");
  2098. $self._assert_equals_($recv($self.receiver)._quux(),(10));
  2099. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2100. $ctx2.sendIdx["assert:equals:"]=2;
  2101. //>>excludeEnd("ctx");
  2102. $self._should_raise_((function(){
  2103. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2104. return $core.withContext(function($ctx3) {
  2105. //>>excludeEnd("ctx");
  2106. return $recv($self.receiver)._basicPerform_("quux");
  2107. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2108. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,3)});
  2109. //>>excludeEnd("ctx");
  2110. }),$globals.Error);
  2111. return $self._assert_equals_($recv($self.receiver)._foo(),(10));
  2112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2113. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2114. //>>excludeEnd("ctx");
  2115. }));
  2116. return self;
  2117. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2118. }, function($ctx1) {$ctx1.fill(self,"testNiladicJSOverrideDifferentNames",{})});
  2119. //>>excludeEnd("ctx");
  2120. }; }),
  2121. $globals.CodeGeneratorInstallTest);
  2122. $core.addMethod(
  2123. $core.method({
  2124. selector: "testPragmaInBlock",
  2125. protocol: "tests",
  2126. //>>excludeStart("ide", pragmas.excludeIdeData);
  2127. args: [],
  2128. source: "testPragmaInBlock\x0a\x09self shouldntInstall: 'foo ^ [ < fooBar > 4 ] value'",
  2129. referencedClasses: [],
  2130. //>>excludeEnd("ide");
  2131. pragmas: [],
  2132. messageSends: ["shouldntInstall:"]
  2133. }, function ($methodClass){ return function (){
  2134. var self=this,$self=this;
  2135. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2136. return $core.withContext(function($ctx1) {
  2137. //>>excludeEnd("ctx");
  2138. $self._shouldntInstall_("foo ^ [ < fooBar > 4 ] value");
  2139. return self;
  2140. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2141. }, function($ctx1) {$ctx1.fill(self,"testPragmaInBlock",{})});
  2142. //>>excludeEnd("ctx");
  2143. }; }),
  2144. $globals.CodeGeneratorInstallTest);
  2145. $core.addClass("InliningCodeGeneratorInstallTest", $globals.CodeGeneratorInstallTest, [], "Compiler-Tests");
  2146. $core.addMethod(
  2147. $core.method({
  2148. selector: "codeGeneratorClass",
  2149. protocol: "accessing",
  2150. //>>excludeStart("ide", pragmas.excludeIdeData);
  2151. args: [],
  2152. source: "codeGeneratorClass\x0a\x09^ InliningCodeGenerator",
  2153. referencedClasses: ["InliningCodeGenerator"],
  2154. //>>excludeEnd("ide");
  2155. pragmas: [],
  2156. messageSends: []
  2157. }, function ($methodClass){ return function (){
  2158. var self=this,$self=this;
  2159. return $globals.InliningCodeGenerator;
  2160. }; }),
  2161. $globals.InliningCodeGeneratorInstallTest);
  2162. $core.addClass("ASTPCNodeVisitorTest", $globals.ASTParsingTest, [], "Compiler-Tests");
  2163. $core.addMethod(
  2164. $core.method({
  2165. selector: "astPCNodeVisitor",
  2166. protocol: "factory",
  2167. //>>excludeStart("ide", pragmas.excludeIdeData);
  2168. args: [],
  2169. source: "astPCNodeVisitor\x0a\x09^ ASTPCNodeVisitor new\x0a\x09\x09index: 0;\x0a\x09\x09yourself",
  2170. referencedClasses: ["ASTPCNodeVisitor"],
  2171. //>>excludeEnd("ide");
  2172. pragmas: [],
  2173. messageSends: ["index:", "new", "yourself"]
  2174. }, function ($methodClass){ return function (){
  2175. var self=this,$self=this;
  2176. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2177. return $core.withContext(function($ctx1) {
  2178. //>>excludeEnd("ctx");
  2179. var $1;
  2180. $1=$recv($globals.ASTPCNodeVisitor)._new();
  2181. $recv($1)._index_((0));
  2182. return $recv($1)._yourself();
  2183. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2184. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitor",{})});
  2185. //>>excludeEnd("ctx");
  2186. }; }),
  2187. $globals.ASTPCNodeVisitorTest);
  2188. $core.addMethod(
  2189. $core.method({
  2190. selector: "astPCNodeVisitorForSelector:",
  2191. protocol: "factory",
  2192. //>>excludeStart("ide", pragmas.excludeIdeData);
  2193. args: ["aString"],
  2194. source: "astPCNodeVisitorForSelector: aString\x0a\x09^ ASTPCNodeVisitor new\x0a\x09\x09selector: aString;\x0a\x09\x09index: 0;\x0a\x09\x09yourself",
  2195. referencedClasses: ["ASTPCNodeVisitor"],
  2196. //>>excludeEnd("ide");
  2197. pragmas: [],
  2198. messageSends: ["selector:", "new", "index:", "yourself"]
  2199. }, function ($methodClass){ return function (aString){
  2200. var self=this,$self=this;
  2201. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2202. return $core.withContext(function($ctx1) {
  2203. //>>excludeEnd("ctx");
  2204. var $1;
  2205. $1=$recv($globals.ASTPCNodeVisitor)._new();
  2206. $recv($1)._selector_(aString);
  2207. $recv($1)._index_((0));
  2208. return $recv($1)._yourself();
  2209. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2210. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitorForSelector:",{aString:aString})});
  2211. //>>excludeEnd("ctx");
  2212. }; }),
  2213. $globals.ASTPCNodeVisitorTest);
  2214. $core.addMethod(
  2215. $core.method({
  2216. selector: "testJSStatementNode",
  2217. protocol: "tests",
  2218. //>>excludeStart("ide", pragmas.excludeIdeData);
  2219. args: [],
  2220. source: "testJSStatementNode\x0a\x09| ast visitor |\x0a\x09\x0a\x09ast := self parse: 'foo <inlineJS: ''consolee.log(1)''>' forClass: Object.\x0a\x09self assert: (self astPCNodeVisitor\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) isJSStatementNode",
  2221. referencedClasses: ["Object"],
  2222. //>>excludeEnd("ide");
  2223. pragmas: [],
  2224. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"]
  2225. }, function ($methodClass){ return function (){
  2226. var self=this,$self=this;
  2227. var ast,visitor;
  2228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2229. return $core.withContext(function($ctx1) {
  2230. //>>excludeEnd("ctx");
  2231. var $3,$2,$1;
  2232. ast=$self._parse_forClass_("foo <inlineJS: 'consolee.log(1)'>",$globals.Object);
  2233. $3=$self._astPCNodeVisitor();
  2234. $recv($3)._visit_(ast);
  2235. $2=$recv($3)._currentNode();
  2236. $1=$recv($2)._isJSStatementNode();
  2237. $self._assert_($1);
  2238. return self;
  2239. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2240. }, function($ctx1) {$ctx1.fill(self,"testJSStatementNode",{ast:ast,visitor:visitor})});
  2241. //>>excludeEnd("ctx");
  2242. }; }),
  2243. $globals.ASTPCNodeVisitorTest);
  2244. $core.addMethod(
  2245. $core.method({
  2246. selector: "testMessageSend",
  2247. protocol: "tests",
  2248. //>>excludeStart("ide", pragmas.excludeIdeData);
  2249. args: [],
  2250. source: "testMessageSend\x0a\x09| ast |\x0a\x09\x0a\x09ast := self parse: 'foo self asString yourself. ^ self asBoolean' forClass: Object.\x0a\x09self assert: ((self astPCNodeVisitorForSelector: 'yourself')\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) selector equals: 'yourself'",
  2251. referencedClasses: ["Object"],
  2252. //>>excludeEnd("ide");
  2253. pragmas: [],
  2254. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForSelector:", "currentNode"]
  2255. }, function ($methodClass){ return function (){
  2256. var self=this,$self=this;
  2257. var ast;
  2258. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2259. return $core.withContext(function($ctx1) {
  2260. //>>excludeEnd("ctx");
  2261. var $3,$2,$1;
  2262. ast=$self._parse_forClass_("foo self asString yourself. ^ self asBoolean",$globals.Object);
  2263. $3=$self._astPCNodeVisitorForSelector_("yourself");
  2264. $recv($3)._visit_(ast);
  2265. $2=$recv($3)._currentNode();
  2266. $1=$recv($2)._selector();
  2267. $self._assert_equals_($1,"yourself");
  2268. return self;
  2269. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2270. }, function($ctx1) {$ctx1.fill(self,"testMessageSend",{ast:ast})});
  2271. //>>excludeEnd("ctx");
  2272. }; }),
  2273. $globals.ASTPCNodeVisitorTest);
  2274. $core.addMethod(
  2275. $core.method({
  2276. selector: "testMessageSendWithBlocks",
  2277. protocol: "tests",
  2278. //>>excludeStart("ide", pragmas.excludeIdeData);
  2279. args: [],
  2280. source: "testMessageSendWithBlocks\x0a\x09| ast |\x0a\x09\x0a\x09ast := self parse: 'foo true ifTrue: [ [ self asString yourself ] value. ]. ^ self asBoolean' forClass: Object.\x0a\x09self assert: ((self astPCNodeVisitorForSelector: 'yourself')\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) selector equals: 'yourself'",
  2281. referencedClasses: ["Object"],
  2282. //>>excludeEnd("ide");
  2283. pragmas: [],
  2284. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForSelector:", "currentNode"]
  2285. }, function ($methodClass){ return function (){
  2286. var self=this,$self=this;
  2287. var ast;
  2288. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2289. return $core.withContext(function($ctx1) {
  2290. //>>excludeEnd("ctx");
  2291. var $3,$2,$1;
  2292. ast=$self._parse_forClass_("foo true ifTrue: [ [ self asString yourself ] value. ]. ^ self asBoolean",$globals.Object);
  2293. $3=$self._astPCNodeVisitorForSelector_("yourself");
  2294. $recv($3)._visit_(ast);
  2295. $2=$recv($3)._currentNode();
  2296. $1=$recv($2)._selector();
  2297. $self._assert_equals_($1,"yourself");
  2298. return self;
  2299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2300. }, function($ctx1) {$ctx1.fill(self,"testMessageSendWithBlocks",{ast:ast})});
  2301. //>>excludeEnd("ctx");
  2302. }; }),
  2303. $globals.ASTPCNodeVisitorTest);
  2304. $core.addMethod(
  2305. $core.method({
  2306. selector: "testMessageSendWithInlining",
  2307. protocol: "tests",
  2308. //>>excludeStart("ide", pragmas.excludeIdeData);
  2309. args: [],
  2310. source: "testMessageSendWithInlining\x0a\x09| ast |\x0a\x09\x0a\x09ast := self parse: 'foo true ifTrue: [ self asString yourself ]. ^ self asBoolean' forClass: Object.\x0a\x09self assert: ((self astPCNodeVisitorForSelector: 'yourself')\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) selector equals: 'yourself'.\x0a\x09\x09\x0a\x09ast := self parse: 'foo true ifTrue: [ self asString yourself ]. ^ self asBoolean' forClass: Object.\x0a\x09self assert: ((self astPCNodeVisitorForSelector: 'asBoolean')\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) selector equals: 'asBoolean'",
  2311. referencedClasses: ["Object"],
  2312. //>>excludeEnd("ide");
  2313. pragmas: [],
  2314. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForSelector:", "currentNode"]
  2315. }, function ($methodClass){ return function (){
  2316. var self=this,$self=this;
  2317. var ast;
  2318. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2319. return $core.withContext(function($ctx1) {
  2320. //>>excludeEnd("ctx");
  2321. var $3,$4,$2,$1,$7,$6,$5;
  2322. ast=$self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$globals.Object);
  2323. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2324. $ctx1.sendIdx["parse:forClass:"]=1;
  2325. //>>excludeEnd("ctx");
  2326. $3=$self._astPCNodeVisitorForSelector_("yourself");
  2327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2328. $ctx1.sendIdx["astPCNodeVisitorForSelector:"]=1;
  2329. //>>excludeEnd("ctx");
  2330. $recv($3)._visit_(ast);
  2331. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2332. $ctx1.sendIdx["visit:"]=1;
  2333. //>>excludeEnd("ctx");
  2334. $4=$recv($3)._currentNode();
  2335. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2336. $ctx1.sendIdx["currentNode"]=1;
  2337. //>>excludeEnd("ctx");
  2338. $2=$4;
  2339. $1=$recv($2)._selector();
  2340. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2341. $ctx1.sendIdx["selector"]=1;
  2342. //>>excludeEnd("ctx");
  2343. $self._assert_equals_($1,"yourself");
  2344. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2345. $ctx1.sendIdx["assert:equals:"]=1;
  2346. //>>excludeEnd("ctx");
  2347. ast=$self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$globals.Object);
  2348. $7=$self._astPCNodeVisitorForSelector_("asBoolean");
  2349. $recv($7)._visit_(ast);
  2350. $6=$recv($7)._currentNode();
  2351. $5=$recv($6)._selector();
  2352. $self._assert_equals_($5,"asBoolean");
  2353. return self;
  2354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2355. }, function($ctx1) {$ctx1.fill(self,"testMessageSendWithInlining",{ast:ast})});
  2356. //>>excludeEnd("ctx");
  2357. }; }),
  2358. $globals.ASTPCNodeVisitorTest);
  2359. $core.addMethod(
  2360. $core.method({
  2361. selector: "testNoMessageSend",
  2362. protocol: "tests",
  2363. //>>excludeStart("ide", pragmas.excludeIdeData);
  2364. args: [],
  2365. source: "testNoMessageSend\x0a\x09| ast |\x0a\x09\x0a\x09ast := self parse: 'foo ^ self' forClass: Object.\x0a\x09self assert: (self astPCNodeVisitor\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) isNil",
  2366. referencedClasses: ["Object"],
  2367. //>>excludeEnd("ide");
  2368. pragmas: [],
  2369. messageSends: ["parse:forClass:", "assert:", "isNil", "visit:", "astPCNodeVisitor", "currentNode"]
  2370. }, function ($methodClass){ return function (){
  2371. var self=this,$self=this;
  2372. var ast;
  2373. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2374. return $core.withContext(function($ctx1) {
  2375. //>>excludeEnd("ctx");
  2376. var $3,$2,$1;
  2377. ast=$self._parse_forClass_("foo ^ self",$globals.Object);
  2378. $3=$self._astPCNodeVisitor();
  2379. $recv($3)._visit_(ast);
  2380. $2=$recv($3)._currentNode();
  2381. $1=$recv($2)._isNil();
  2382. $self._assert_($1);
  2383. return self;
  2384. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2385. }, function($ctx1) {$ctx1.fill(self,"testNoMessageSend",{ast:ast})});
  2386. //>>excludeEnd("ctx");
  2387. }; }),
  2388. $globals.ASTPCNodeVisitorTest);
  2389. $core.addClass("ASTPositionTest", $globals.ASTParsingTest, [], "Compiler-Tests");
  2390. $core.addMethod(
  2391. $core.method({
  2392. selector: "testNodeAtPosition",
  2393. protocol: "tests",
  2394. //>>excludeStart("ide", pragmas.excludeIdeData);
  2395. args: [],
  2396. source: "testNodeAtPosition\x0a\x09| node |\x0a\x09\x0a\x09node := self parse: 'yourself\x0a\x09^ self' forClass: Object.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@4 ifAbsent: [ nil ]) source equals: 'self'.\x0a\x09\x0a\x09node := self parse: 'foo\x0a\x09true ifTrue: [ 1 ]' forClass: Object.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@7 ifAbsent: [ nil ]) selector equals: 'ifTrue:'.\x0a\x09\x0a\x09node := self parse: 'foo\x0a\x09self foo; bar; baz' forClass: Object.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@8 ifAbsent: [ nil ]) selector equals: 'foo'",
  2397. referencedClasses: ["Object"],
  2398. //>>excludeEnd("ide");
  2399. pragmas: [],
  2400. messageSends: ["parse:forClass:", "assert:equals:", "source", "navigationNodeAt:ifAbsent:", "@", "selector"]
  2401. }, function ($methodClass){ return function (){
  2402. var self=this,$self=this;
  2403. var node;
  2404. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2405. return $core.withContext(function($ctx1) {
  2406. //>>excludeEnd("ctx");
  2407. var $3,$4,$2,$1,$7,$8,$6,$5;
  2408. node=$self._parse_forClass_("yourself\x0a\x09^ self",$globals.Object);
  2409. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2410. $ctx1.sendIdx["parse:forClass:"]=1;
  2411. //>>excludeEnd("ctx");
  2412. $3=node;
  2413. $4=(2).__at((4));
  2414. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2415. $ctx1.sendIdx["@"]=1;
  2416. //>>excludeEnd("ctx");
  2417. $2=$recv($3)._navigationNodeAt_ifAbsent_($4,(function(){
  2418. return nil;
  2419. }));
  2420. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2421. $ctx1.sendIdx["navigationNodeAt:ifAbsent:"]=1;
  2422. //>>excludeEnd("ctx");
  2423. $1=$recv($2)._source();
  2424. $self._assert_equals_($1,"self");
  2425. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2426. $ctx1.sendIdx["assert:equals:"]=1;
  2427. //>>excludeEnd("ctx");
  2428. node=$self._parse_forClass_("foo\x0a\x09true ifTrue: [ 1 ]",$globals.Object);
  2429. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2430. $ctx1.sendIdx["parse:forClass:"]=2;
  2431. //>>excludeEnd("ctx");
  2432. $7=node;
  2433. $8=(2).__at((7));
  2434. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2435. $ctx1.sendIdx["@"]=2;
  2436. //>>excludeEnd("ctx");
  2437. $6=$recv($7)._navigationNodeAt_ifAbsent_($8,(function(){
  2438. return nil;
  2439. }));
  2440. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2441. $ctx1.sendIdx["navigationNodeAt:ifAbsent:"]=2;
  2442. //>>excludeEnd("ctx");
  2443. $5=$recv($6)._selector();
  2444. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2445. $ctx1.sendIdx["selector"]=1;
  2446. //>>excludeEnd("ctx");
  2447. $self._assert_equals_($5,"ifTrue:");
  2448. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2449. $ctx1.sendIdx["assert:equals:"]=2;
  2450. //>>excludeEnd("ctx");
  2451. node=$self._parse_forClass_("foo\x0a\x09self foo; bar; baz",$globals.Object);
  2452. $self._assert_equals_($recv($recv(node)._navigationNodeAt_ifAbsent_((2).__at((8)),(function(){
  2453. return nil;
  2454. })))._selector(),"foo");
  2455. return self;
  2456. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2457. }, function($ctx1) {$ctx1.fill(self,"testNodeAtPosition",{node:node})});
  2458. //>>excludeEnd("ctx");
  2459. }; }),
  2460. $globals.ASTPositionTest);
  2461. $core.addClass("ScopeVarTest", $globals.TestCase, [], "Compiler-Tests");
  2462. $core.addMethod(
  2463. $core.method({
  2464. selector: "testClassRefVar",
  2465. protocol: "tests",
  2466. //>>excludeStart("ide", pragmas.excludeIdeData);
  2467. args: [],
  2468. source: "testClassRefVar\x0a\x09| node |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'Object';\x0a\x09\x09yourself.\x0a\x09SemanticAnalyzer new \x0a\x09\x09pushScope: MethodLexicalScope new;\x0a\x09\x09visit: node.\x0a\x09self assert: node binding isClassRefVar",
  2469. referencedClasses: ["VariableNode", "SemanticAnalyzer", "MethodLexicalScope"],
  2470. //>>excludeEnd("ide");
  2471. pragmas: [],
  2472. messageSends: ["value:", "new", "yourself", "pushScope:", "visit:", "assert:", "isClassRefVar", "binding"]
  2473. }, function ($methodClass){ return function (){
  2474. var self=this,$self=this;
  2475. var node;
  2476. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2477. return $core.withContext(function($ctx1) {
  2478. //>>excludeEnd("ctx");
  2479. var $1,$2;
  2480. $1=$recv($globals.VariableNode)._new();
  2481. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2482. $ctx1.sendIdx["new"]=1;
  2483. //>>excludeEnd("ctx");
  2484. $recv($1)._value_("Object");
  2485. node=$recv($1)._yourself();
  2486. $2=$recv($globals.SemanticAnalyzer)._new();
  2487. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2488. $ctx1.sendIdx["new"]=2;
  2489. //>>excludeEnd("ctx");
  2490. $recv($2)._pushScope_($recv($globals.MethodLexicalScope)._new());
  2491. $recv($2)._visit_(node);
  2492. $self._assert_($recv($recv(node)._binding())._isClassRefVar());
  2493. return self;
  2494. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2495. }, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node})});
  2496. //>>excludeEnd("ctx");
  2497. }; }),
  2498. $globals.ScopeVarTest);
  2499. $core.addMethod(
  2500. $core.method({
  2501. selector: "testInstanceVar",
  2502. protocol: "tests",
  2503. //>>excludeStart("ide", pragmas.excludeIdeData);
  2504. args: [],
  2505. source: "testInstanceVar\x0a\x09| node scope |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09scope := MethodLexicalScope new.\x0a\x09scope addIVar: 'bzzz'.\x0a\x09self assert: (scope bindingFor: node) isInstanceVar",
  2506. referencedClasses: ["VariableNode", "MethodLexicalScope"],
  2507. //>>excludeEnd("ide");
  2508. pragmas: [],
  2509. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]
  2510. }, function ($methodClass){ return function (){
  2511. var self=this,$self=this;
  2512. var node,scope;
  2513. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2514. return $core.withContext(function($ctx1) {
  2515. //>>excludeEnd("ctx");
  2516. var $1;
  2517. $1=$recv($globals.VariableNode)._new();
  2518. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2519. $ctx1.sendIdx["new"]=1;
  2520. //>>excludeEnd("ctx");
  2521. $recv($1)._value_("bzzz");
  2522. node=$recv($1)._yourself();
  2523. scope=$recv($globals.MethodLexicalScope)._new();
  2524. $recv(scope)._addIVar_("bzzz");
  2525. $self._assert_($recv($recv(scope)._bindingFor_(node))._isInstanceVar());
  2526. return self;
  2527. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2528. }, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope})});
  2529. //>>excludeEnd("ctx");
  2530. }; }),
  2531. $globals.ScopeVarTest);
  2532. $core.addMethod(
  2533. $core.method({
  2534. selector: "testPseudoVar",
  2535. protocol: "tests",
  2536. //>>excludeStart("ide", pragmas.excludeIdeData);
  2537. args: [],
  2538. source: "testPseudoVar\x0a\x09| node pseudoVars |\x0a\x09pseudoVars := #('self' 'super' 'true' 'false' 'nil').\x0a\x09pseudoVars do: [:each |\x0a\x09\x09node := VariableNode new\x0a\x09\x09value: each;\x0a\x09\x09yourself.\x0a\x09\x09self assert: (MethodLexicalScope new bindingFor: node) isPseudoVar]",
  2539. referencedClasses: ["VariableNode", "MethodLexicalScope"],
  2540. //>>excludeEnd("ide");
  2541. pragmas: [],
  2542. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]
  2543. }, function ($methodClass){ return function (){
  2544. var self=this,$self=this;
  2545. var node,pseudoVars;
  2546. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2547. return $core.withContext(function($ctx1) {
  2548. //>>excludeEnd("ctx");
  2549. var $1;
  2550. pseudoVars=["self", "super", "true", "false", "nil"];
  2551. $recv(pseudoVars)._do_((function(each){
  2552. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2553. return $core.withContext(function($ctx2) {
  2554. //>>excludeEnd("ctx");
  2555. $1=$recv($globals.VariableNode)._new();
  2556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2557. $ctx2.sendIdx["new"]=1;
  2558. //>>excludeEnd("ctx");
  2559. $recv($1)._value_(each);
  2560. node=$recv($1)._yourself();
  2561. return $self._assert_($recv($recv($recv($globals.MethodLexicalScope)._new())._bindingFor_(node))._isPseudoVar());
  2562. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2563. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2564. //>>excludeEnd("ctx");
  2565. }));
  2566. return self;
  2567. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2568. }, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars})});
  2569. //>>excludeEnd("ctx");
  2570. }; }),
  2571. $globals.ScopeVarTest);
  2572. $core.addMethod(
  2573. $core.method({
  2574. selector: "testTempVar",
  2575. protocol: "tests",
  2576. //>>excludeStart("ide", pragmas.excludeIdeData);
  2577. args: [],
  2578. source: "testTempVar\x0a\x09| node scope |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09scope := MethodLexicalScope new.\x0a\x09scope addTemp: 'bzzz'.\x0a\x09self assert: (scope bindingFor: node) isTempVar",
  2579. referencedClasses: ["VariableNode", "MethodLexicalScope"],
  2580. //>>excludeEnd("ide");
  2581. pragmas: [],
  2582. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]
  2583. }, function ($methodClass){ return function (){
  2584. var self=this,$self=this;
  2585. var node,scope;
  2586. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2587. return $core.withContext(function($ctx1) {
  2588. //>>excludeEnd("ctx");
  2589. var $1;
  2590. $1=$recv($globals.VariableNode)._new();
  2591. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2592. $ctx1.sendIdx["new"]=1;
  2593. //>>excludeEnd("ctx");
  2594. $recv($1)._value_("bzzz");
  2595. node=$recv($1)._yourself();
  2596. scope=$recv($globals.MethodLexicalScope)._new();
  2597. $recv(scope)._addTemp_("bzzz");
  2598. $self._assert_($recv($recv(scope)._bindingFor_(node))._isTempVar());
  2599. return self;
  2600. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2601. }, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope})});
  2602. //>>excludeEnd("ctx");
  2603. }; }),
  2604. $globals.ScopeVarTest);
  2605. $core.addMethod(
  2606. $core.method({
  2607. selector: "testUnknownVar",
  2608. protocol: "tests",
  2609. //>>excludeStart("ide", pragmas.excludeIdeData);
  2610. args: [],
  2611. source: "testUnknownVar\x0a\x09| node |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09self assert: (MethodLexicalScope new bindingFor: node) isNil",
  2612. referencedClasses: ["VariableNode", "MethodLexicalScope"],
  2613. //>>excludeEnd("ide");
  2614. pragmas: [],
  2615. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]
  2616. }, function ($methodClass){ return function (){
  2617. var self=this,$self=this;
  2618. var node;
  2619. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2620. return $core.withContext(function($ctx1) {
  2621. //>>excludeEnd("ctx");
  2622. var $1;
  2623. $1=$recv($globals.VariableNode)._new();
  2624. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2625. $ctx1.sendIdx["new"]=1;
  2626. //>>excludeEnd("ctx");
  2627. $recv($1)._value_("bzzz");
  2628. node=$recv($1)._yourself();
  2629. $self._assert_($recv($recv($recv($globals.MethodLexicalScope)._new())._bindingFor_(node))._isNil());
  2630. return self;
  2631. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2632. }, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node})});
  2633. //>>excludeEnd("ctx");
  2634. }; }),
  2635. $globals.ScopeVarTest);
  2636. $core.addClass("SemanticAnalyzerTest", $globals.TestCase, ["analyzer"], "Compiler-Tests");
  2637. $core.addMethod(
  2638. $core.method({
  2639. selector: "setUp",
  2640. protocol: "running",
  2641. //>>excludeStart("ide", pragmas.excludeIdeData);
  2642. args: [],
  2643. source: "setUp\x0a\x09analyzer := SemanticAnalyzer on: Object",
  2644. referencedClasses: ["SemanticAnalyzer", "Object"],
  2645. //>>excludeEnd("ide");
  2646. pragmas: [],
  2647. messageSends: ["on:"]
  2648. }, function ($methodClass){ return function (){
  2649. var self=this,$self=this;
  2650. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2651. return $core.withContext(function($ctx1) {
  2652. //>>excludeEnd("ctx");
  2653. $self.analyzer=$recv($globals.SemanticAnalyzer)._on_($globals.Object);
  2654. return self;
  2655. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2656. }, function($ctx1) {$ctx1.fill(self,"setUp",{})});
  2657. //>>excludeEnd("ctx");
  2658. }; }),
  2659. $globals.SemanticAnalyzerTest);
  2660. $core.addMethod(
  2661. $core.method({
  2662. selector: "testAssignment",
  2663. protocol: "tests",
  2664. //>>excludeStart("ide", pragmas.excludeIdeData);
  2665. args: [],
  2666. source: "testAssignment\x0a\x09| src ast |\x0a\x0a\x09src := 'foo self := 1'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: InvalidAssignmentError",
  2667. referencedClasses: ["Smalltalk", "InvalidAssignmentError"],
  2668. //>>excludeEnd("ide");
  2669. pragmas: [],
  2670. messageSends: ["parse:", "should:raise:", "visit:"]
  2671. }, function ($methodClass){ return function (){
  2672. var self=this,$self=this;
  2673. var src,ast;
  2674. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2675. return $core.withContext(function($ctx1) {
  2676. //>>excludeEnd("ctx");
  2677. src="foo self := 1";
  2678. ast=$recv($globals.Smalltalk)._parse_(src);
  2679. $self._should_raise_((function(){
  2680. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2681. return $core.withContext(function($ctx2) {
  2682. //>>excludeEnd("ctx");
  2683. return $recv($self.analyzer)._visit_(ast);
  2684. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2685. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2686. //>>excludeEnd("ctx");
  2687. }),$globals.InvalidAssignmentError);
  2688. return self;
  2689. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2690. }, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast})});
  2691. //>>excludeEnd("ctx");
  2692. }; }),
  2693. $globals.SemanticAnalyzerTest);
  2694. $core.addMethod(
  2695. $core.method({
  2696. selector: "testNonLocalReturn",
  2697. protocol: "tests",
  2698. //>>excludeStart("ide", pragmas.excludeIdeData);
  2699. args: [],
  2700. source: "testNonLocalReturn\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. ^ a'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast scope hasNonLocalReturn",
  2701. referencedClasses: ["Smalltalk"],
  2702. //>>excludeEnd("ide");
  2703. pragmas: [],
  2704. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]
  2705. }, function ($methodClass){ return function (){
  2706. var self=this,$self=this;
  2707. var src,ast;
  2708. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2709. return $core.withContext(function($ctx1) {
  2710. //>>excludeEnd("ctx");
  2711. src="foo | a | a + 1. ^ a";
  2712. ast=$recv($globals.Smalltalk)._parse_(src);
  2713. $recv($self.analyzer)._visit_(ast);
  2714. $self._deny_($recv($recv(ast)._scope())._hasNonLocalReturn());
  2715. return self;
  2716. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2717. }, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast})});
  2718. //>>excludeEnd("ctx");
  2719. }; }),
  2720. $globals.SemanticAnalyzerTest);
  2721. $core.addMethod(
  2722. $core.method({
  2723. selector: "testNonLocalReturn2",
  2724. protocol: "tests",
  2725. //>>excludeStart("ide", pragmas.excludeIdeData);
  2726. args: [],
  2727. source: "testNonLocalReturn2\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ ^ a] ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self assert: ast scope hasNonLocalReturn",
  2728. referencedClasses: ["Smalltalk"],
  2729. //>>excludeEnd("ide");
  2730. pragmas: [],
  2731. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]
  2732. }, function ($methodClass){ return function (){
  2733. var self=this,$self=this;
  2734. var src,ast;
  2735. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2736. return $core.withContext(function($ctx1) {
  2737. //>>excludeEnd("ctx");
  2738. src="foo | a | a + 1. [ [ ^ a] ]";
  2739. ast=$recv($globals.Smalltalk)._parse_(src);
  2740. $recv($self.analyzer)._visit_(ast);
  2741. $self._assert_($recv($recv(ast)._scope())._hasNonLocalReturn());
  2742. return self;
  2743. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2744. }, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast})});
  2745. //>>excludeEnd("ctx");
  2746. }; }),
  2747. $globals.SemanticAnalyzerTest);
  2748. $core.addMethod(
  2749. $core.method({
  2750. selector: "testScope",
  2751. protocol: "tests",
  2752. //>>excludeStart("ide", pragmas.excludeIdeData);
  2753. args: [],
  2754. source: "testScope\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast dagChildren first dagChildren last scope == ast scope.",
  2755. referencedClasses: ["Smalltalk"],
  2756. //>>excludeEnd("ide");
  2757. pragmas: [],
  2758. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "dagChildren", "first"]
  2759. }, function ($methodClass){ return function (){
  2760. var self=this,$self=this;
  2761. var src,ast;
  2762. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2763. return $core.withContext(function($ctx1) {
  2764. //>>excludeEnd("ctx");
  2765. var $4,$3,$2,$1;
  2766. src="foo | a | a + 1. [ | b | b := a ]";
  2767. ast=$recv($globals.Smalltalk)._parse_(src);
  2768. $recv($self.analyzer)._visit_(ast);
  2769. $4=$recv($recv($recv(ast)._dagChildren())._first())._dagChildren();
  2770. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2771. $ctx1.sendIdx["dagChildren"]=1;
  2772. //>>excludeEnd("ctx");
  2773. $3=$recv($4)._last();
  2774. $2=$recv($3)._scope();
  2775. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2776. $ctx1.sendIdx["scope"]=1;
  2777. //>>excludeEnd("ctx");
  2778. $1=$recv($2).__eq_eq($recv(ast)._scope());
  2779. $self._deny_($1);
  2780. return self;
  2781. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2782. }, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast})});
  2783. //>>excludeEnd("ctx");
  2784. }; }),
  2785. $globals.SemanticAnalyzerTest);
  2786. $core.addMethod(
  2787. $core.method({
  2788. selector: "testScope2",
  2789. protocol: "tests",
  2790. //>>excludeStart("ide", pragmas.excludeIdeData);
  2791. args: [],
  2792. source: "testScope2\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast dagChildren first dagChildren last dagChildren first dagChildren first scope == ast scope.",
  2793. referencedClasses: ["Smalltalk"],
  2794. //>>excludeEnd("ide");
  2795. pragmas: [],
  2796. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "dagChildren", "last"]
  2797. }, function ($methodClass){ return function (){
  2798. var self=this,$self=this;
  2799. var src,ast;
  2800. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2801. return $core.withContext(function($ctx1) {
  2802. //>>excludeEnd("ctx");
  2803. var $8,$7,$6,$5,$4,$3,$2,$1;
  2804. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  2805. ast=$recv($globals.Smalltalk)._parse_(src);
  2806. $recv($self.analyzer)._visit_(ast);
  2807. $8=$recv($recv($recv(ast)._dagChildren())._first())._dagChildren();
  2808. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2809. $ctx1.sendIdx["dagChildren"]=3;
  2810. //>>excludeEnd("ctx");
  2811. $7=$recv($8)._last();
  2812. $6=$recv($7)._dagChildren();
  2813. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2814. $ctx1.sendIdx["dagChildren"]=2;
  2815. //>>excludeEnd("ctx");
  2816. $5=$recv($6)._first();
  2817. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2818. $ctx1.sendIdx["first"]=2;
  2819. //>>excludeEnd("ctx");
  2820. $4=$recv($5)._dagChildren();
  2821. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2822. $ctx1.sendIdx["dagChildren"]=1;
  2823. //>>excludeEnd("ctx");
  2824. $3=$recv($4)._first();
  2825. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2826. $ctx1.sendIdx["first"]=1;
  2827. //>>excludeEnd("ctx");
  2828. $2=$recv($3)._scope();
  2829. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2830. $ctx1.sendIdx["scope"]=1;
  2831. //>>excludeEnd("ctx");
  2832. $1=$recv($2).__eq_eq($recv(ast)._scope());
  2833. $self._deny_($1);
  2834. return self;
  2835. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2836. }, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast})});
  2837. //>>excludeEnd("ctx");
  2838. }; }),
  2839. $globals.SemanticAnalyzerTest);
  2840. $core.addMethod(
  2841. $core.method({
  2842. selector: "testScopeLevel",
  2843. protocol: "tests",
  2844. //>>excludeStart("ide", pragmas.excludeIdeData);
  2845. args: [],
  2846. source: "testScopeLevel\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self assert: ast scope scopeLevel equals: 1.\x0a\x09self assert: ast dagChildren first dagChildren last dagChildren first dagChildren first scope scopeLevel equals: 3",
  2847. referencedClasses: ["Smalltalk"],
  2848. //>>excludeEnd("ide");
  2849. pragmas: [],
  2850. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "dagChildren", "last"]
  2851. }, function ($methodClass){ return function (){
  2852. var self=this,$self=this;
  2853. var src,ast;
  2854. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2855. return $core.withContext(function($ctx1) {
  2856. //>>excludeEnd("ctx");
  2857. var $2,$1,$10,$9,$8,$7,$6,$5,$4,$3;
  2858. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  2859. ast=$recv($globals.Smalltalk)._parse_(src);
  2860. $recv($self.analyzer)._visit_(ast);
  2861. $2=$recv(ast)._scope();
  2862. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2863. $ctx1.sendIdx["scope"]=1;
  2864. //>>excludeEnd("ctx");
  2865. $1=$recv($2)._scopeLevel();
  2866. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2867. $ctx1.sendIdx["scopeLevel"]=1;
  2868. //>>excludeEnd("ctx");
  2869. $self._assert_equals_($1,(1));
  2870. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2871. $ctx1.sendIdx["assert:equals:"]=1;
  2872. //>>excludeEnd("ctx");
  2873. $10=$recv($recv($recv(ast)._dagChildren())._first())._dagChildren();
  2874. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2875. $ctx1.sendIdx["dagChildren"]=3;
  2876. //>>excludeEnd("ctx");
  2877. $9=$recv($10)._last();
  2878. $8=$recv($9)._dagChildren();
  2879. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2880. $ctx1.sendIdx["dagChildren"]=2;
  2881. //>>excludeEnd("ctx");
  2882. $7=$recv($8)._first();
  2883. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2884. $ctx1.sendIdx["first"]=2;
  2885. //>>excludeEnd("ctx");
  2886. $6=$recv($7)._dagChildren();
  2887. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2888. $ctx1.sendIdx["dagChildren"]=1;
  2889. //>>excludeEnd("ctx");
  2890. $5=$recv($6)._first();
  2891. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2892. $ctx1.sendIdx["first"]=1;
  2893. //>>excludeEnd("ctx");
  2894. $4=$recv($5)._scope();
  2895. $3=$recv($4)._scopeLevel();
  2896. $self._assert_equals_($3,(3));
  2897. return self;
  2898. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2899. }, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast})});
  2900. //>>excludeEnd("ctx");
  2901. }; }),
  2902. $globals.SemanticAnalyzerTest);
  2903. $core.addMethod(
  2904. $core.method({
  2905. selector: "testUnknownVariables",
  2906. protocol: "tests",
  2907. //>>excludeStart("ide", pragmas.excludeIdeData);
  2908. args: [],
  2909. source: "testUnknownVariables\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | b + a'.\x0a\x09ast := Smalltalk parse: src.\x0a\x0a\x09self should: [ analyzer visit: ast ] raise: UnknownVariableError",
  2910. referencedClasses: ["Smalltalk", "UnknownVariableError"],
  2911. //>>excludeEnd("ide");
  2912. pragmas: [],
  2913. messageSends: ["parse:", "should:raise:", "visit:"]
  2914. }, function ($methodClass){ return function (){
  2915. var self=this,$self=this;
  2916. var src,ast;
  2917. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2918. return $core.withContext(function($ctx1) {
  2919. //>>excludeEnd("ctx");
  2920. src="foo | a | b + a";
  2921. ast=$recv($globals.Smalltalk)._parse_(src);
  2922. $self._should_raise_((function(){
  2923. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2924. return $core.withContext(function($ctx2) {
  2925. //>>excludeEnd("ctx");
  2926. return $recv($self.analyzer)._visit_(ast);
  2927. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2928. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2929. //>>excludeEnd("ctx");
  2930. }),$globals.UnknownVariableError);
  2931. return self;
  2932. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2933. }, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast})});
  2934. //>>excludeEnd("ctx");
  2935. }; }),
  2936. $globals.SemanticAnalyzerTest);
  2937. $core.addMethod(
  2938. $core.method({
  2939. selector: "testUnknownVariablesWithScope",
  2940. protocol: "tests",
  2941. //>>excludeStart("ide", pragmas.excludeIdeData);
  2942. args: [],
  2943. source: "testUnknownVariablesWithScope\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a b | [ c + 1. [ a + 1. d + 1 ]]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09\x0a\x09self should: [ analyzer visit: ast ] raise: UnknownVariableError",
  2944. referencedClasses: ["Smalltalk", "UnknownVariableError"],
  2945. //>>excludeEnd("ide");
  2946. pragmas: [],
  2947. messageSends: ["parse:", "should:raise:", "visit:"]
  2948. }, function ($methodClass){ return function (){
  2949. var self=this,$self=this;
  2950. var src,ast;
  2951. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2952. return $core.withContext(function($ctx1) {
  2953. //>>excludeEnd("ctx");
  2954. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  2955. ast=$recv($globals.Smalltalk)._parse_(src);
  2956. $self._should_raise_((function(){
  2957. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2958. return $core.withContext(function($ctx2) {
  2959. //>>excludeEnd("ctx");
  2960. return $recv($self.analyzer)._visit_(ast);
  2961. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2962. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2963. //>>excludeEnd("ctx");
  2964. }),$globals.UnknownVariableError);
  2965. return self;
  2966. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2967. }, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast})});
  2968. //>>excludeEnd("ctx");
  2969. }; }),
  2970. $globals.SemanticAnalyzerTest);
  2971. $core.addMethod(
  2972. $core.method({
  2973. selector: "testVariableShadowing",
  2974. protocol: "tests",
  2975. //>>excludeStart("ide", pragmas.excludeIdeData);
  2976. args: [],
  2977. source: "testVariableShadowing\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast",
  2978. referencedClasses: ["Smalltalk"],
  2979. //>>excludeEnd("ide");
  2980. pragmas: [],
  2981. messageSends: ["parse:", "visit:"]
  2982. }, function ($methodClass){ return function (){
  2983. var self=this,$self=this;
  2984. var src,ast;
  2985. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2986. return $core.withContext(function($ctx1) {
  2987. //>>excludeEnd("ctx");
  2988. src="foo | a | a + 1";
  2989. ast=$recv($globals.Smalltalk)._parse_(src);
  2990. $recv($self.analyzer)._visit_(ast);
  2991. return self;
  2992. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2993. }, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast})});
  2994. //>>excludeEnd("ctx");
  2995. }; }),
  2996. $globals.SemanticAnalyzerTest);
  2997. $core.addMethod(
  2998. $core.method({
  2999. selector: "testVariableShadowing2",
  3000. protocol: "tests",
  3001. //>>excludeStart("ide", pragmas.excludeIdeData);
  3002. args: [],
  3003. source: "testVariableShadowing2\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | a | a := 2 ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: ShadowingVariableError",
  3004. referencedClasses: ["Smalltalk", "ShadowingVariableError"],
  3005. //>>excludeEnd("ide");
  3006. pragmas: [],
  3007. messageSends: ["parse:", "should:raise:", "visit:"]
  3008. }, function ($methodClass){ return function (){
  3009. var self=this,$self=this;
  3010. var src,ast;
  3011. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3012. return $core.withContext(function($ctx1) {
  3013. //>>excludeEnd("ctx");
  3014. src="foo | a | a + 1. [ | a | a := 2 ]";
  3015. ast=$recv($globals.Smalltalk)._parse_(src);
  3016. $self._should_raise_((function(){
  3017. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3018. return $core.withContext(function($ctx2) {
  3019. //>>excludeEnd("ctx");
  3020. return $recv($self.analyzer)._visit_(ast);
  3021. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3022. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  3023. //>>excludeEnd("ctx");
  3024. }),$globals.ShadowingVariableError);
  3025. return self;
  3026. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3027. }, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast})});
  3028. //>>excludeEnd("ctx");
  3029. }; }),
  3030. $globals.SemanticAnalyzerTest);
  3031. $core.addMethod(
  3032. $core.method({
  3033. selector: "testVariableShadowing3",
  3034. protocol: "tests",
  3035. //>>excludeStart("ide", pragmas.excludeIdeData);
  3036. args: [],
  3037. source: "testVariableShadowing3\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | b | b := 2 ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast",
  3038. referencedClasses: ["Smalltalk"],
  3039. //>>excludeEnd("ide");
  3040. pragmas: [],
  3041. messageSends: ["parse:", "visit:"]
  3042. }, function ($methodClass){ return function (){
  3043. var self=this,$self=this;
  3044. var src,ast;
  3045. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3046. return $core.withContext(function($ctx1) {
  3047. //>>excludeEnd("ctx");
  3048. src="foo | a | a + 1. [ | b | b := 2 ]";
  3049. ast=$recv($globals.Smalltalk)._parse_(src);
  3050. $recv($self.analyzer)._visit_(ast);
  3051. return self;
  3052. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3053. }, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast})});
  3054. //>>excludeEnd("ctx");
  3055. }; }),
  3056. $globals.SemanticAnalyzerTest);
  3057. $core.addMethod(
  3058. $core.method({
  3059. selector: "testVariableShadowing4",
  3060. protocol: "tests",
  3061. //>>excludeStart("ide", pragmas.excludeIdeData);
  3062. args: [],
  3063. source: "testVariableShadowing4\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast",
  3064. referencedClasses: ["Smalltalk"],
  3065. //>>excludeEnd("ide");
  3066. pragmas: [],
  3067. messageSends: ["parse:", "visit:"]
  3068. }, function ($methodClass){ return function (){
  3069. var self=this,$self=this;
  3070. var src,ast;
  3071. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3072. return $core.withContext(function($ctx1) {
  3073. //>>excludeEnd("ctx");
  3074. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  3075. ast=$recv($globals.Smalltalk)._parse_(src);
  3076. $recv($self.analyzer)._visit_(ast);
  3077. return self;
  3078. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3079. }, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast})});
  3080. //>>excludeEnd("ctx");
  3081. }; }),
  3082. $globals.SemanticAnalyzerTest);
  3083. $core.addMethod(
  3084. $core.method({
  3085. selector: "testVariableShadowing5",
  3086. protocol: "tests",
  3087. //>>excludeStart("ide", pragmas.excludeIdeData);
  3088. args: [],
  3089. source: "testVariableShadowing5\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09self should: [analyzer visit: ast] raise: ShadowingVariableError",
  3090. referencedClasses: ["Smalltalk", "ShadowingVariableError"],
  3091. //>>excludeEnd("ide");
  3092. pragmas: [],
  3093. messageSends: ["parse:", "should:raise:", "visit:"]
  3094. }, function ($methodClass){ return function (){
  3095. var self=this,$self=this;
  3096. var src,ast;
  3097. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3098. return $core.withContext(function($ctx1) {
  3099. //>>excludeEnd("ctx");
  3100. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  3101. ast=$recv($globals.Smalltalk)._parse_(src);
  3102. $self._should_raise_((function(){
  3103. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3104. return $core.withContext(function($ctx2) {
  3105. //>>excludeEnd("ctx");
  3106. return $recv($self.analyzer)._visit_(ast);
  3107. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3108. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  3109. //>>excludeEnd("ctx");
  3110. }),$globals.ShadowingVariableError);
  3111. return self;
  3112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3113. }, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast})});
  3114. //>>excludeEnd("ctx");
  3115. }; }),
  3116. $globals.SemanticAnalyzerTest);
  3117. $core.addMethod(
  3118. $core.method({
  3119. selector: "testVariablesLookup",
  3120. protocol: "tests",
  3121. //>>excludeStart("ide", pragmas.excludeIdeData);
  3122. args: [],
  3123. source: "testVariablesLookup\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := Smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09\x22Binding for `a` in the message send\x22\x0a\x09self assert: ast dagChildren first dagChildren first receiver binding isTempVar.\x0a\x09self assert: ast dagChildren first dagChildren first receiver binding scope == ast scope.\x0a\x0a\x09\x22Binding for `b`\x22\x0a\x09self assert: ast dagChildren first dagChildren last dagChildren first dagChildren first left binding isTempVar.\x0a\x09self assert: ast dagChildren first dagChildren last dagChildren first dagChildren first left binding scope == ast dagChildren first dagChildren last scope.",
  3124. referencedClasses: ["Smalltalk"],
  3125. //>>excludeEnd("ide");
  3126. pragmas: [],
  3127. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "dagChildren", "==", "scope", "left", "last"]
  3128. }, function ($methodClass){ return function (){
  3129. var self=this,$self=this;
  3130. var src,ast;
  3131. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3132. return $core.withContext(function($ctx1) {
  3133. //>>excludeEnd("ctx");
  3134. var $7,$6,$5,$4,$3,$2,$1,$15,$14,$13,$12,$11,$10,$9,$16,$8,$27,$26,$25,$24,$23,$22,$21,$20,$19,$18,$17,$39,$38,$37,$36,$35,$34,$33,$32,$31,$30,$29,$42,$41,$40,$28;
  3135. src="foo | a | a + 1. [ | b | b := a ]";
  3136. ast=$recv($globals.Smalltalk)._parse_(src);
  3137. $recv($self.analyzer)._visit_(ast);
  3138. $7=$recv(ast)._dagChildren();
  3139. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3140. $ctx1.sendIdx["dagChildren"]=2;
  3141. //>>excludeEnd("ctx");
  3142. $6=$recv($7)._first();
  3143. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3144. $ctx1.sendIdx["first"]=2;
  3145. //>>excludeEnd("ctx");
  3146. $5=$recv($6)._dagChildren();
  3147. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3148. $ctx1.sendIdx["dagChildren"]=1;
  3149. //>>excludeEnd("ctx");
  3150. $4=$recv($5)._first();
  3151. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3152. $ctx1.sendIdx["first"]=1;
  3153. //>>excludeEnd("ctx");
  3154. $3=$recv($4)._receiver();
  3155. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3156. $ctx1.sendIdx["receiver"]=1;
  3157. //>>excludeEnd("ctx");
  3158. $2=$recv($3)._binding();
  3159. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3160. $ctx1.sendIdx["binding"]=1;
  3161. //>>excludeEnd("ctx");
  3162. $1=$recv($2)._isTempVar();
  3163. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3164. $ctx1.sendIdx["isTempVar"]=1;
  3165. //>>excludeEnd("ctx");
  3166. $self._assert_($1);
  3167. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3168. $ctx1.sendIdx["assert:"]=1;
  3169. //>>excludeEnd("ctx");
  3170. $15=$recv(ast)._dagChildren();
  3171. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3172. $ctx1.sendIdx["dagChildren"]=4;
  3173. //>>excludeEnd("ctx");
  3174. $14=$recv($15)._first();
  3175. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3176. $ctx1.sendIdx["first"]=4;
  3177. //>>excludeEnd("ctx");
  3178. $13=$recv($14)._dagChildren();
  3179. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3180. $ctx1.sendIdx["dagChildren"]=3;
  3181. //>>excludeEnd("ctx");
  3182. $12=$recv($13)._first();
  3183. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3184. $ctx1.sendIdx["first"]=3;
  3185. //>>excludeEnd("ctx");
  3186. $11=$recv($12)._receiver();
  3187. $10=$recv($11)._binding();
  3188. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3189. $ctx1.sendIdx["binding"]=2;
  3190. //>>excludeEnd("ctx");
  3191. $9=$recv($10)._scope();
  3192. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3193. $ctx1.sendIdx["scope"]=1;
  3194. //>>excludeEnd("ctx");
  3195. $16=$recv(ast)._scope();
  3196. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3197. $ctx1.sendIdx["scope"]=2;
  3198. //>>excludeEnd("ctx");
  3199. $8=$recv($9).__eq_eq($16);
  3200. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3201. $ctx1.sendIdx["=="]=1;
  3202. //>>excludeEnd("ctx");
  3203. $self._assert_($8);
  3204. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3205. $ctx1.sendIdx["assert:"]=2;
  3206. //>>excludeEnd("ctx");
  3207. $27=$recv(ast)._dagChildren();
  3208. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3209. $ctx1.sendIdx["dagChildren"]=8;
  3210. //>>excludeEnd("ctx");
  3211. $26=$recv($27)._first();
  3212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3213. $ctx1.sendIdx["first"]=7;
  3214. //>>excludeEnd("ctx");
  3215. $25=$recv($26)._dagChildren();
  3216. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3217. $ctx1.sendIdx["dagChildren"]=7;
  3218. //>>excludeEnd("ctx");
  3219. $24=$recv($25)._last();
  3220. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3221. $ctx1.sendIdx["last"]=1;
  3222. //>>excludeEnd("ctx");
  3223. $23=$recv($24)._dagChildren();
  3224. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3225. $ctx1.sendIdx["dagChildren"]=6;
  3226. //>>excludeEnd("ctx");
  3227. $22=$recv($23)._first();
  3228. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3229. $ctx1.sendIdx["first"]=6;
  3230. //>>excludeEnd("ctx");
  3231. $21=$recv($22)._dagChildren();
  3232. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3233. $ctx1.sendIdx["dagChildren"]=5;
  3234. //>>excludeEnd("ctx");
  3235. $20=$recv($21)._first();
  3236. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3237. $ctx1.sendIdx["first"]=5;
  3238. //>>excludeEnd("ctx");
  3239. $19=$recv($20)._left();
  3240. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3241. $ctx1.sendIdx["left"]=1;
  3242. //>>excludeEnd("ctx");
  3243. $18=$recv($19)._binding();
  3244. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3245. $ctx1.sendIdx["binding"]=3;
  3246. //>>excludeEnd("ctx");
  3247. $17=$recv($18)._isTempVar();
  3248. $self._assert_($17);
  3249. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3250. $ctx1.sendIdx["assert:"]=3;
  3251. //>>excludeEnd("ctx");
  3252. $39=$recv(ast)._dagChildren();
  3253. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3254. $ctx1.sendIdx["dagChildren"]=12;
  3255. //>>excludeEnd("ctx");
  3256. $38=$recv($39)._first();
  3257. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3258. $ctx1.sendIdx["first"]=10;
  3259. //>>excludeEnd("ctx");
  3260. $37=$recv($38)._dagChildren();
  3261. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3262. $ctx1.sendIdx["dagChildren"]=11;
  3263. //>>excludeEnd("ctx");
  3264. $36=$recv($37)._last();
  3265. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3266. $ctx1.sendIdx["last"]=2;
  3267. //>>excludeEnd("ctx");
  3268. $35=$recv($36)._dagChildren();
  3269. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3270. $ctx1.sendIdx["dagChildren"]=10;
  3271. //>>excludeEnd("ctx");
  3272. $34=$recv($35)._first();
  3273. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3274. $ctx1.sendIdx["first"]=9;
  3275. //>>excludeEnd("ctx");
  3276. $33=$recv($34)._dagChildren();
  3277. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3278. $ctx1.sendIdx["dagChildren"]=9;
  3279. //>>excludeEnd("ctx");
  3280. $32=$recv($33)._first();
  3281. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3282. $ctx1.sendIdx["first"]=8;
  3283. //>>excludeEnd("ctx");
  3284. $31=$recv($32)._left();
  3285. $30=$recv($31)._binding();
  3286. $29=$recv($30)._scope();
  3287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3288. $ctx1.sendIdx["scope"]=3;
  3289. //>>excludeEnd("ctx");
  3290. $42=$recv($recv($recv(ast)._dagChildren())._first())._dagChildren();
  3291. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3292. $ctx1.sendIdx["dagChildren"]=13;
  3293. //>>excludeEnd("ctx");
  3294. $41=$recv($42)._last();
  3295. $40=$recv($41)._scope();
  3296. $28=$recv($29).__eq_eq($40);
  3297. $self._assert_($28);
  3298. return self;
  3299. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3300. }, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast})});
  3301. //>>excludeEnd("ctx");
  3302. }; }),
  3303. $globals.SemanticAnalyzerTest);
  3304. $core.addClass("AISemanticAnalyzerTest", $globals.SemanticAnalyzerTest, [], "Compiler-Tests");
  3305. $core.addMethod(
  3306. $core.method({
  3307. selector: "setUp",
  3308. protocol: "running",
  3309. //>>excludeStart("ide", pragmas.excludeIdeData);
  3310. args: [],
  3311. source: "setUp\x0a\x09analyzer := (AISemanticAnalyzer on: Object)\x0a\x09\x09context: (AIContext new\x0a\x09\x09\x09defineLocal: 'local';\x0a\x09\x09\x09localAt: 'local' put: 3;\x0a\x09\x09\x09yourself);\x0a\x09\x09yourself",
  3312. referencedClasses: ["AISemanticAnalyzer", "Object", "AIContext"],
  3313. //>>excludeEnd("ide");
  3314. pragmas: [],
  3315. messageSends: ["context:", "on:", "defineLocal:", "new", "localAt:put:", "yourself"]
  3316. }, function ($methodClass){ return function (){
  3317. var self=this,$self=this;
  3318. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3319. return $core.withContext(function($ctx1) {
  3320. //>>excludeEnd("ctx");
  3321. var $1,$3,$4,$2;
  3322. $1=$recv($globals.AISemanticAnalyzer)._on_($globals.Object);
  3323. $3=$recv($globals.AIContext)._new();
  3324. $recv($3)._defineLocal_("local");
  3325. $recv($3)._localAt_put_("local",(3));
  3326. $4=$recv($3)._yourself();
  3327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3328. $ctx1.sendIdx["yourself"]=1;
  3329. //>>excludeEnd("ctx");
  3330. $2=$4;
  3331. $recv($1)._context_($2);
  3332. $self.analyzer=$recv($1)._yourself();
  3333. return self;
  3334. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3335. }, function($ctx1) {$ctx1.fill(self,"setUp",{})});
  3336. //>>excludeEnd("ctx");
  3337. }; }),
  3338. $globals.AISemanticAnalyzerTest);
  3339. $core.addMethod(
  3340. $core.method({
  3341. selector: "testContextVariables",
  3342. protocol: "tests",
  3343. //>>excludeStart("ide", pragmas.excludeIdeData);
  3344. args: [],
  3345. source: "testContextVariables\x0a\x09| src ast |\x0a\x09\x0a\x09src := 'foo | a | local + a'.\x0a\x09ast := Smalltalk parse: src.\x0a\x0a\x09self shouldnt: [ analyzer visit: ast ] raise: UnknownVariableError",
  3346. referencedClasses: ["Smalltalk", "UnknownVariableError"],
  3347. //>>excludeEnd("ide");
  3348. pragmas: [],
  3349. messageSends: ["parse:", "shouldnt:raise:", "visit:"]
  3350. }, function ($methodClass){ return function (){
  3351. var self=this,$self=this;
  3352. var src,ast;
  3353. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3354. return $core.withContext(function($ctx1) {
  3355. //>>excludeEnd("ctx");
  3356. src="foo | a | local + a";
  3357. ast=$recv($globals.Smalltalk)._parse_(src);
  3358. $self._shouldnt_raise_((function(){
  3359. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3360. return $core.withContext(function($ctx2) {
  3361. //>>excludeEnd("ctx");
  3362. return $recv($self.analyzer)._visit_(ast);
  3363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3364. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  3365. //>>excludeEnd("ctx");
  3366. }),$globals.UnknownVariableError);
  3367. return self;
  3368. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  3369. }, function($ctx1) {$ctx1.fill(self,"testContextVariables",{src:src,ast:ast})});
  3370. //>>excludeEnd("ctx");
  3371. }; }),
  3372. $globals.AISemanticAnalyzerTest);
  3373. });