Compiler-Tests.js 116 KB

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