Compiler-Tests.js 115 KB

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