Compiler-Tests.js 119 KB

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