Compiler-Tests.js 117 KB

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