Compiler-Tests.js 118 KB

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