1
0

Compiler-Tests.js 138 KB

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