Compiler-Tests.js 118 KB

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