2
0

Compiler-Tests.js 122 KB

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