Compiler-Tests.js 117 KB

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