Compiler-Tests.js 120 KB

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