Compiler-Tests.js 119 KB

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