Compiler-Tests.js 114 KB

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