Compiler-Tests.js 118 KB

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