Compiler-Tests.js 115 KB

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