Compiler-Tests.js 117 KB

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