Compiler-Tests.js 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021
  1. smalltalk.addPackage('Compiler-Tests');
  2. smalltalk.addClass('ASTVisitorTest', smalltalk.TestCase, [], 'Compiler-Tests');
  3. smalltalk.addMethod(
  4. smalltalk.method({
  5. selector: "analyze:forClass:",
  6. category: 'convenience',
  7. fn: function (aNode,aClass){
  8. var self=this;
  9. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  10. return smalltalk.withContext(function($ctx1) {
  11. var $1;
  12. _st(_st($SemanticAnalyzer())._on_(aClass))._visit_(aNode);
  13. $1=aNode;
  14. return $1;
  15. }, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},smalltalk.ASTVisitorTest)})},
  16. args: ["aNode", "aClass"],
  17. source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a\x09^ aNode",
  18. messageSends: ["visit:", "on:"],
  19. referencedClasses: ["SemanticAnalyzer"]
  20. }),
  21. smalltalk.ASTVisitorTest);
  22. smalltalk.addMethod(
  23. smalltalk.method({
  24. selector: "parse:",
  25. category: 'parsing',
  26. fn: function (aString){
  27. var self=this;
  28. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  29. return smalltalk.withContext(function($ctx1) {
  30. var $1;
  31. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  32. return $1;
  33. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.ASTVisitorTest)})},
  34. args: ["aString"],
  35. source: "parse: aString\x0a\x09^ Smalltalk current parse: aString",
  36. messageSends: ["parse:", "current"],
  37. referencedClasses: ["Smalltalk"]
  38. }),
  39. smalltalk.ASTVisitorTest);
  40. smalltalk.addMethod(
  41. smalltalk.method({
  42. selector: "parse:forClass:",
  43. category: 'parsing',
  44. fn: function (aString,aClass){
  45. var self=this;
  46. return smalltalk.withContext(function($ctx1) {
  47. var $1;
  48. $1=self._analyze_forClass_(self._parse_(aString),aClass);
  49. return $1;
  50. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.ASTVisitorTest)})},
  51. args: ["aString", "aClass"],
  52. source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
  53. messageSends: ["analyze:forClass:", "parse:"],
  54. referencedClasses: []
  55. }),
  56. smalltalk.ASTVisitorTest);
  57. smalltalk.addClass('ASTPCNodeVisitorTest', smalltalk.ASTVisitorTest, [], 'Compiler-Tests');
  58. smalltalk.addMethod(
  59. smalltalk.method({
  60. selector: "astPCNodeVisitor",
  61. category: 'factory',
  62. fn: function (){
  63. var self=this;
  64. return smalltalk.withContext(function($ctx1) {
  65. var $1;
  66. $1=self._astPCNodeVisitorForPC_((0));
  67. return $1;
  68. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitor",{},smalltalk.ASTPCNodeVisitorTest)})},
  69. args: [],
  70. source: "astPCNodeVisitor\x0a\x09^ self astPCNodeVisitorForPC: 0",
  71. messageSends: ["astPCNodeVisitorForPC:"],
  72. referencedClasses: []
  73. }),
  74. smalltalk.ASTPCNodeVisitorTest);
  75. smalltalk.addMethod(
  76. smalltalk.method({
  77. selector: "astPCNodeVisitorForPC:",
  78. category: 'factory',
  79. fn: function (anInteger){
  80. var self=this;
  81. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  82. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  83. return smalltalk.withContext(function($ctx1) {
  84. var $2,$3,$4,$5,$1;
  85. $2=_st($ASTPCNodeVisitor())._new();
  86. _st($2)._pc_((0));
  87. $3=_st($AIContext())._new();
  88. _st($3)._pc_(anInteger);
  89. $4=_st($3)._yourself();
  90. _st($2)._context_($4);
  91. $5=_st($2)._yourself();
  92. $1=$5;
  93. return $1;
  94. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitorForPC:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitorTest)})},
  95. args: ["anInteger"],
  96. source: "astPCNodeVisitorForPC: anInteger\x0a\x09^ ASTPCNodeVisitor new\x0a\x09\x09pc: 0;\x0a\x09\x09context: (AIContext new \x0a\x09\x09\x09pc: anInteger; \x0a\x09\x09\x09yourself);\x0a\x09\x09yourself",
  97. messageSends: ["pc:", "new", "context:", "yourself"],
  98. referencedClasses: ["ASTPCNodeVisitor", "AIContext"]
  99. }),
  100. smalltalk.ASTPCNodeVisitorTest);
  101. smalltalk.addMethod(
  102. smalltalk.method({
  103. selector: "testJSStatementNode",
  104. category: 'tests',
  105. fn: function (){
  106. var self=this;
  107. var ast,visitor;
  108. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  109. return smalltalk.withContext(function($ctx1) {
  110. var $1,$2;
  111. ast=self._parse_forClass_("foo <consolee.log(1)>",$Object());
  112. $1=self._astPCNodeVisitor();
  113. _st($1)._visit_(ast);
  114. $2=_st($1)._currentNode();
  115. self._assert_(_st($2)._isJSStatementNode());
  116. return self}, function($ctx1) {$ctx1.fill(self,"testJSStatementNode",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  117. args: [],
  118. source: "testJSStatementNode\x0a\x09| ast visitor |\x0a\x09\x0a\x09ast := self parse: 'foo <consolee.log(1)>' forClass: Object.\x0a\x09self assert: (self astPCNodeVisitor\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) isJSStatementNode",
  119. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"],
  120. referencedClasses: ["Object"]
  121. }),
  122. smalltalk.ASTPCNodeVisitorTest);
  123. smalltalk.addMethod(
  124. smalltalk.method({
  125. selector: "testMessageSend",
  126. category: 'tests',
  127. fn: function (){
  128. var self=this;
  129. var ast;
  130. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  131. return smalltalk.withContext(function($ctx1) {
  132. var $1,$2;
  133. ast=self._parse_forClass_("foo self asString yourself. ^ self asBoolean",$Object());
  134. $1=self._astPCNodeVisitorForPC_((2));
  135. _st($1)._visit_(ast);
  136. $2=_st($1)._currentNode();
  137. self._assert_equals_(_st($2)._selector(),"yourself");
  138. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  139. args: [],
  140. source: "testMessageSend\x0a\x09| ast |\x0a\x09\x0a\x09ast := self parse: 'foo self asString yourself. ^ self asBoolean' forClass: Object.\x0a\x09self assert: ((self astPCNodeVisitorForPC: 2)\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) selector equals: 'yourself'",
  141. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"],
  142. referencedClasses: ["Object"]
  143. }),
  144. smalltalk.ASTPCNodeVisitorTest);
  145. smalltalk.addMethod(
  146. smalltalk.method({
  147. selector: "testMessageSendWithInlining",
  148. category: 'tests',
  149. fn: function (){
  150. var self=this;
  151. var ast;
  152. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  153. return smalltalk.withContext(function($ctx1) {
  154. var $1,$2,$3,$4;
  155. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  156. $1=self._astPCNodeVisitorForPC_((2));
  157. _st($1)._visit_(ast);
  158. $2=_st($1)._currentNode();
  159. self._assert_equals_(_st($2)._selector(),"yourself");
  160. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  161. $3=self._astPCNodeVisitorForPC_((3));
  162. _st($3)._visit_(ast);
  163. $4=_st($3)._currentNode();
  164. self._assert_equals_(_st($4)._selector(),"asBoolean");
  165. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSendWithInlining",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  166. args: [],
  167. 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 astPCNodeVisitorForPC: 2)\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 astPCNodeVisitorForPC: 3)\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) selector equals: 'asBoolean'",
  168. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"],
  169. referencedClasses: ["Object"]
  170. }),
  171. smalltalk.ASTPCNodeVisitorTest);
  172. smalltalk.addMethod(
  173. smalltalk.method({
  174. selector: "testNoMessageSend",
  175. category: 'tests',
  176. fn: function (){
  177. var self=this;
  178. var ast;
  179. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  180. return smalltalk.withContext(function($ctx1) {
  181. var $1,$2;
  182. ast=self._parse_forClass_("foo ^ self",$Object());
  183. $1=self._astPCNodeVisitor();
  184. _st($1)._visit_(ast);
  185. $2=_st($1)._currentNode();
  186. self._assert_(_st($2)._isNil());
  187. return self}, function($ctx1) {$ctx1.fill(self,"testNoMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  188. args: [],
  189. 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",
  190. messageSends: ["parse:forClass:", "assert:", "isNil", "visit:", "astPCNodeVisitor", "currentNode"],
  191. referencedClasses: ["Object"]
  192. }),
  193. smalltalk.ASTPCNodeVisitorTest);
  194. smalltalk.addMethod(
  195. smalltalk.method({
  196. selector: "testPC",
  197. category: 'tests',
  198. fn: function (){
  199. var self=this;
  200. var ast,visitor;
  201. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  202. return smalltalk.withContext(function($ctx1) {
  203. var $1,$2;
  204. ast=self._parse_forClass_("foo <console.log(1)>",$Object());
  205. $1=self._astPCNodeVisitor();
  206. _st($1)._visit_(ast);
  207. $2=_st($1)._currentNode();
  208. self._assert_(_st($2)._isJSStatementNode());
  209. return self}, function($ctx1) {$ctx1.fill(self,"testPC",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  210. args: [],
  211. source: "testPC\x0a\x09| ast visitor |\x0a\x09\x0a\x09ast := self parse: 'foo <console.log(1)>' forClass: Object.\x0a\x09self assert: (self astPCNodeVisitor\x0a\x09\x09visit: ast;\x0a\x09\x09currentNode) isJSStatementNode",
  212. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"],
  213. referencedClasses: ["Object"]
  214. }),
  215. smalltalk.ASTPCNodeVisitorTest);
  216. smalltalk.addClass('AbstractASTInterpreterTest', smalltalk.ASTVisitorTest, [], 'Compiler-Tests');
  217. smalltalk.addMethod(
  218. smalltalk.method({
  219. selector: "interpret:",
  220. category: 'interpreting',
  221. fn: function (aString){
  222. var self=this;
  223. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  224. return smalltalk.withContext(function($ctx1) {
  225. var $1;
  226. $1=self._interpret_withArguments_(aString,_st($Dictionary())._new());
  227. return $1;
  228. }, function($ctx1) {$ctx1.fill(self,"interpret:",{aString:aString},smalltalk.AbstractASTInterpreterTest)})},
  229. args: ["aString"],
  230. source: "interpret: aString\x0a\x09^ self\x0a\x09\x09interpret: aString\x0a\x09\x09withArguments: Dictionary new",
  231. messageSends: ["interpret:withArguments:", "new"],
  232. referencedClasses: ["Dictionary"]
  233. }),
  234. smalltalk.AbstractASTInterpreterTest);
  235. smalltalk.addMethod(
  236. smalltalk.method({
  237. selector: "interpret:receiver:withArguments:",
  238. category: 'interpreting',
  239. fn: function (aString,anObject,aDictionary){
  240. var self=this;
  241. var ctx;
  242. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  243. return smalltalk.withContext(function($ctx1) {
  244. var $2,$3,$1;
  245. ctx=_st($AIContext())._new();
  246. _st(ctx)._receiver_(anObject);
  247. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  248. return smalltalk.withContext(function($ctx2) {
  249. return _st(ctx)._localAt_put_(key,value);
  250. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  251. $2=self._interpreter();
  252. _st($2)._context_(ctx);
  253. _st($2)._interpret_(_st(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nodes())._first());
  254. $3=_st($2)._result();
  255. $1=$3;
  256. return $1;
  257. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx},smalltalk.AbstractASTInterpreterTest)})},
  258. args: ["aString", "anObject", "aDictionary"],
  259. source: "interpret: aString 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 := AIContext new.\x0a\x09ctx receiver: anObject.\x0a\x09aDictionary keysAndValuesDo: [ :key :value |\x0a\x09\x09ctx localAt: key put: value ].\x0a\x09\x0a\x09^ self interpreter\x0a\x09\x09context: ctx;\x0a\x09\x09interpret: (self parse: aString forClass: anObject class)\x0a\x09\x09\x09nodes first;\x0a\x09\x09result",
  260. messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "first", "nodes", "parse:forClass:", "class", "result"],
  261. referencedClasses: ["AIContext"]
  262. }),
  263. smalltalk.AbstractASTInterpreterTest);
  264. smalltalk.addMethod(
  265. smalltalk.method({
  266. selector: "interpret:withArguments:",
  267. category: 'interpreting',
  268. fn: function (aString,aDictionary){
  269. var self=this;
  270. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  271. return smalltalk.withContext(function($ctx1) {
  272. var $1;
  273. $1=self._interpret_receiver_withArguments_(aString,_st($Object())._new(),aDictionary);
  274. return $1;
  275. }, function($ctx1) {$ctx1.fill(self,"interpret:withArguments:",{aString:aString,aDictionary:aDictionary},smalltalk.AbstractASTInterpreterTest)})},
  276. args: ["aString", "aDictionary"],
  277. source: "interpret: aString withArguments: aDictionary\x0a\x09^ self\x0a\x09\x09interpret: aString\x0a\x09\x09receiver: Object new\x0a\x09\x09withArguments: aDictionary",
  278. messageSends: ["interpret:receiver:withArguments:", "new"],
  279. referencedClasses: ["Object"]
  280. }),
  281. smalltalk.AbstractASTInterpreterTest);
  282. smalltalk.addMethod(
  283. smalltalk.method({
  284. selector: "interpreter",
  285. category: 'accessing',
  286. fn: function (){
  287. var self=this;
  288. return smalltalk.withContext(function($ctx1) {
  289. var $1;
  290. $1=self._subclassResponsibility();
  291. return $1;
  292. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AbstractASTInterpreterTest)})},
  293. args: [],
  294. source: "interpreter\x0a\x09^ self subclassResponsibility",
  295. messageSends: ["subclassResponsibility"],
  296. referencedClasses: []
  297. }),
  298. smalltalk.AbstractASTInterpreterTest);
  299. smalltalk.addClass('ASTInterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
  300. smalltalk.addMethod(
  301. smalltalk.method({
  302. selector: "interpreter",
  303. category: 'accessing',
  304. fn: function (){
  305. var self=this;
  306. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  307. return smalltalk.withContext(function($ctx1) {
  308. var $1;
  309. $1=_st($ASTInterpreter())._new();
  310. return $1;
  311. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTInterpreterTest)})},
  312. args: [],
  313. source: "interpreter\x0a\x09^ ASTInterpreter new",
  314. messageSends: ["new"],
  315. referencedClasses: ["ASTInterpreter"]
  316. }),
  317. smalltalk.ASTInterpreterTest);
  318. smalltalk.addMethod(
  319. smalltalk.method({
  320. selector: "testBinarySend",
  321. category: 'tests',
  322. fn: function (){
  323. var self=this;
  324. return smalltalk.withContext(function($ctx1) {
  325. self._assert_equals_(self._interpret_("foo 2+3+4"),(9));
  326. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.ASTInterpreterTest)})},
  327. args: [],
  328. source: "testBinarySend\x0a\x09self assert: (self interpret: 'foo 2+3+4') equals: 9",
  329. messageSends: ["assert:equals:", "interpret:"],
  330. referencedClasses: []
  331. }),
  332. smalltalk.ASTInterpreterTest);
  333. smalltalk.addMethod(
  334. smalltalk.method({
  335. selector: "testBlockLiteral",
  336. category: 'tests',
  337. fn: function (){
  338. var self=this;
  339. return smalltalk.withContext(function($ctx1) {
  340. self._assert_equals_(self._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  341. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  342. self._assert_equals_(self._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  343. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.ASTInterpreterTest)})},
  344. args: [],
  345. source: "testBlockLiteral\x0a\x09self assert: (self interpret: 'foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a\x09self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a\x09self assert: (self interpret: 'foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 2",
  346. messageSends: ["assert:equals:", "interpret:"],
  347. referencedClasses: []
  348. }),
  349. smalltalk.ASTInterpreterTest);
  350. smalltalk.addMethod(
  351. smalltalk.method({
  352. selector: "testCascade",
  353. category: 'tests',
  354. fn: function (){
  355. var self=this;
  356. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  357. return smalltalk.withContext(function($ctx1) {
  358. self._assert_equals_(self._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  359. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.ASTInterpreterTest)})},
  360. args: [],
  361. source: "testCascade\x0a\x09self assert: (self interpret: 'foo ^ OrderedCollection new add: 2; add: 3; yourself') equals: (OrderedCollection with: 2 with: 3)",
  362. messageSends: ["assert:equals:", "interpret:", "with:with:"],
  363. referencedClasses: ["OrderedCollection"]
  364. }),
  365. smalltalk.ASTInterpreterTest);
  366. smalltalk.addMethod(
  367. smalltalk.method({
  368. selector: "testDynamicArray",
  369. category: 'tests',
  370. fn: function (){
  371. var self=this;
  372. return smalltalk.withContext(function($ctx1) {
  373. self._assert_equals_(self._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  374. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.ASTInterpreterTest)})},
  375. args: [],
  376. source: "testDynamicArray\x0a\x09self assert: (self interpret: 'foo ^ {1+1. 2+2}') equals: #(2 4)",
  377. messageSends: ["assert:equals:", "interpret:"],
  378. referencedClasses: []
  379. }),
  380. smalltalk.ASTInterpreterTest);
  381. smalltalk.addMethod(
  382. smalltalk.method({
  383. selector: "testDynamicDictionary",
  384. category: 'tests',
  385. fn: function (){
  386. var self=this;
  387. return smalltalk.withContext(function($ctx1) {
  388. self._assert_equals_(self._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._from_([(1).__minus_gt((1)),(2).__minus_gt((3))]));
  389. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.ASTInterpreterTest)})},
  390. args: [],
  391. source: "testDynamicDictionary\x0a\x09self assert: (self interpret: 'foo ^ #{1->1. 2->3}') equals: #{1->1. 2->3}",
  392. messageSends: ["assert:equals:", "interpret:", "->"],
  393. referencedClasses: []
  394. }),
  395. smalltalk.ASTInterpreterTest);
  396. smalltalk.addMethod(
  397. smalltalk.method({
  398. selector: "testInlinedJSStatement",
  399. category: 'tests',
  400. fn: function (){
  401. var self=this;
  402. return smalltalk.withContext(function($ctx1) {
  403. self._assert_equals_(self._interpret_("foo <return 2+3>"),(5));
  404. self._assert_equals_(self._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._from_(["anInteger".__minus_gt((3))])),(5));
  405. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.ASTInterpreterTest)})},
  406. args: [],
  407. source: "testInlinedJSStatement\x0a\x09self assert: (self interpret: 'foo <return 2+3>') equals: 5.\x0a\x09\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo: anInteger <return 2 + anInteger>'\x0a\x09\x09\x09withArguments: #{ 'anInteger' -> 3})\x0a\x09\x09equals: 5",
  408. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"],
  409. referencedClasses: []
  410. }),
  411. smalltalk.ASTInterpreterTest);
  412. smalltalk.addMethod(
  413. smalltalk.method({
  414. selector: "testInstVarAccess",
  415. category: 'tests',
  416. fn: function (){
  417. var self=this;
  418. return smalltalk.withContext(function($ctx1) {
  419. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ x",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2));
  420. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.ASTInterpreterTest)})},
  421. args: [],
  422. source: "testInstVarAccess\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo ^ x'\x0a\x09\x09\x09receiver: 2@3\x0a\x09\x09\x09withArguments: #{})\x0a\x09\x09equals: 2",
  423. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"],
  424. referencedClasses: []
  425. }),
  426. smalltalk.ASTInterpreterTest);
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "testInstVarAssignment",
  430. category: 'tests',
  431. fn: function (){
  432. var self=this;
  433. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  434. return smalltalk.withContext(function($ctx1) {
  435. self._assert_equals_(self._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._from_(["anInteger".__minus_gt((2))])),(2));
  436. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.ASTInterpreterTest)})},
  437. args: [],
  438. source: "testInstVarAssignment\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo: anInteger x := anInteger. ^ x'\x0a\x09\x09\x09receiver: Point new\x0a\x09\x09\x09withArguments: #{'anInteger' -> 2})\x0a\x09\x09equals: 2",
  439. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"],
  440. referencedClasses: ["Point"]
  441. }),
  442. smalltalk.ASTInterpreterTest);
  443. smalltalk.addMethod(
  444. smalltalk.method({
  445. selector: "testNonlocalReturn",
  446. category: 'tests',
  447. fn: function (){
  448. var self=this;
  449. return smalltalk.withContext(function($ctx1) {
  450. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  451. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.ASTInterpreterTest)})},
  452. args: [],
  453. source: "testNonlocalReturn\x0a\x09self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ]. ^2') equals: 1",
  454. messageSends: ["assert:equals:", "interpret:"],
  455. referencedClasses: []
  456. }),
  457. smalltalk.ASTInterpreterTest);
  458. smalltalk.addMethod(
  459. smalltalk.method({
  460. selector: "testReceiver",
  461. category: 'tests',
  462. fn: function (){
  463. var self=this;
  464. return smalltalk.withContext(function($ctx1) {
  465. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ self",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2).__at((3)));
  466. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.ASTInterpreterTest)})},
  467. args: [],
  468. source: "testReceiver\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo ^ self'\x0a\x09\x09\x09receiver: 2@3\x0a\x09\x09\x09withArguments: #{})\x0a\x09\x09equals: 2@3",
  469. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"],
  470. referencedClasses: []
  471. }),
  472. smalltalk.ASTInterpreterTest);
  473. smalltalk.addMethod(
  474. smalltalk.method({
  475. selector: "testSuper",
  476. category: 'tests',
  477. fn: function (){
  478. var self=this;
  479. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  480. return smalltalk.withContext(function($ctx1) {
  481. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ super isBoolean",true,_st($Dictionary())._new()),false);
  482. return self}, function($ctx1) {$ctx1.fill(self,"testSuper",{},smalltalk.ASTInterpreterTest)})},
  483. args: [],
  484. source: "testSuper\x0a\x09self \x0a\x09\x09assert: (self \x0a\x09\x09\x09interpret: 'foo ^ super isBoolean' \x0a\x09\x09\x09receiver: true \x0a\x09\x09\x09withArguments: Dictionary new) \x0a\x09\x09equals: false",
  485. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new"],
  486. referencedClasses: ["Dictionary"]
  487. }),
  488. smalltalk.ASTInterpreterTest);
  489. smalltalk.addMethod(
  490. smalltalk.method({
  491. selector: "testTempAssignment",
  492. category: 'tests',
  493. fn: function (){
  494. var self=this;
  495. return smalltalk.withContext(function($ctx1) {
  496. self._assert_equals_(self._interpret_("foo | a | a := 2. ^ a"),(2));
  497. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.ASTInterpreterTest)})},
  498. args: [],
  499. source: "testTempAssignment\x0a\x09self assert: (self interpret: 'foo | a | a := 2. ^ a') equals: 2",
  500. messageSends: ["assert:equals:", "interpret:"],
  501. referencedClasses: []
  502. }),
  503. smalltalk.ASTInterpreterTest);
  504. smalltalk.addMethod(
  505. smalltalk.method({
  506. selector: "testThisContext",
  507. category: 'tests',
  508. fn: function (){
  509. var self=this;
  510. return smalltalk.withContext(function($ctx1) {
  511. self._assert_(_st(_st(self._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  512. self._assert_(_st(_st(self._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  513. self._assert_(self._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  514. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.ASTInterpreterTest)})},
  515. args: [],
  516. source: "testThisContext\x0a\x09self assert: (self interpret: 'foo ^ thisContext') outerContext isNil.\x0a\x09self assert: (self interpret: 'foo ^ [ thisContext ] value') outerContext notNil.\x0a\x09self assert: (self interpret: 'foo ^ [ thisContext ] value outerContext == thisContext')",
  517. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"],
  518. referencedClasses: []
  519. }),
  520. smalltalk.ASTInterpreterTest);
  521. smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');
  522. smalltalk.addMethod(
  523. smalltalk.method({
  524. selector: "interpreter",
  525. category: 'accessing',
  526. fn: function (){
  527. var self=this;
  528. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  529. return smalltalk.withContext(function($ctx1) {
  530. var $2,$1;
  531. $2=self["@interpreter"];
  532. if(($receiver = $2) == nil || $receiver == undefined){
  533. self["@interpreter"]=_st($ASTSteppingInterpreter())._new();
  534. $1=self["@interpreter"];
  535. } else {
  536. $1=$2;
  537. };
  538. return $1;
  539. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTSteppingInterpreterTest)})},
  540. args: [],
  541. source: "interpreter\x0a\x09^ interpreter ifNil: [ interpreter := ASTSteppingInterpreter new ]",
  542. messageSends: ["ifNil:", "new"],
  543. referencedClasses: ["ASTSteppingInterpreter"]
  544. }),
  545. smalltalk.ASTSteppingInterpreterTest);
  546. smalltalk.addMethod(
  547. smalltalk.method({
  548. selector: "testAtEnd",
  549. category: 'tests',
  550. fn: function (){
  551. var self=this;
  552. return smalltalk.withContext(function($ctx1) {
  553. self._interpret_("foo 1 + 2");
  554. self._deny_(_st(self._interpreter())._atEnd());
  555. _st(self._interpreter())._step();
  556. self._deny_(_st(self._interpreter())._atEnd());
  557. _st(self._interpreter())._step();
  558. self._deny_(_st(self._interpreter())._atEnd());
  559. _st(self._interpreter())._step();
  560. self._deny_(_st(self._interpreter())._atEnd());
  561. _st(self._interpreter())._step();
  562. self._assert_(_st(self._interpreter())._atEnd());
  563. return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.ASTSteppingInterpreterTest)})},
  564. args: [],
  565. source: "testAtEnd\x0a\x09self interpret: 'foo 1 + 2'.\x0a\x09self deny: self interpreter atEnd.\x0a\x0a\x09self interpreter step.\x0a\x09self deny: self interpreter atEnd.\x0a\x09\x0a\x09self interpreter step.\x0a\x09self deny: self interpreter atEnd.\x0a\x09\x0a\x09self interpreter step.\x0a\x09self deny: self interpreter atEnd.\x0a\x09\x0a\x09self interpreter step.\x0a\x09self assert: self interpreter atEnd",
  566. messageSends: ["interpret:", "deny:", "atEnd", "interpreter", "step", "assert:"],
  567. referencedClasses: []
  568. }),
  569. smalltalk.ASTSteppingInterpreterTest);
  570. smalltalk.addMethod(
  571. smalltalk.method({
  572. selector: "testMessageSend",
  573. category: 'tests',
  574. fn: function (){
  575. var self=this;
  576. return smalltalk.withContext(function($ctx1) {
  577. self._interpret_("foo 1 + 2");
  578. _st(self._interpreter())._step();
  579. _st(self._interpreter())._step();
  580. _st(self._interpreter())._step();
  581. self._assert_equals_(_st(_st(self._interpreter())._currentNode())._value(),(1));
  582. _st(self._interpreter())._step();
  583. self._assert_equals_(_st(_st(self._interpreter())._currentNode())._value(),(2));
  584. _st(self._interpreter())._step();
  585. self._assert_equals_(_st(self._interpreter())._result(),(3));
  586. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.ASTSteppingInterpreterTest)})},
  587. args: [],
  588. source: "testMessageSend\x0a\x09self interpret: 'foo 1 + 2'.\x0a\x09\x0a\x09\x22SequenceNode\x22\x0a\x09self interpreter step.\x0a\x09\x0a\x09\x22SendNode\x22\x0a\x09self interpreter step.\x0a\x09\x0a\x09\x22ValueNode\x22\x0a\x09self interpreter step.\x0a\x09self assert: self interpreter currentNode value equals: 1.\x0a\x09\x0a\x09\x22ValueNode\x22\x0a\x09self interpreter step.\x0a\x09self assert: self interpreter currentNode value equals: 2.\x0a\x09\x0a\x09\x22Result\x22\x0a\x09self interpreter step.\x0a\x09self assert: self interpreter result equals: 3",
  589. messageSends: ["interpret:", "step", "interpreter", "assert:equals:", "value", "currentNode", "result"],
  590. referencedClasses: []
  591. }),
  592. smalltalk.ASTSteppingInterpreterTest);
  593. smalltalk.addMethod(
  594. smalltalk.method({
  595. selector: "testSimpleStepping",
  596. category: 'tests',
  597. fn: function (){
  598. var self=this;
  599. return smalltalk.withContext(function($ctx1) {
  600. self._interpret_("foo 1");
  601. _st(self._interpreter())._step();
  602. self._assert_(_st(_st(self._interpreter())._result())._isNil());
  603. _st(self._interpreter())._step();
  604. self._assert_equals_(_st(self._interpreter())._result(),(1));
  605. return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{},smalltalk.ASTSteppingInterpreterTest)})},
  606. args: [],
  607. source: "testSimpleStepping\x0a\x09self interpret: 'foo 1'.\x0a\x09\x0a\x09\x22SequenceNode\x22\x0a\x09self interpreter step.\x0a\x09\x0a\x09self assert: self interpreter result isNil.\x0a\x09\x0a\x09\x22ValueNode\x22\x0a\x09self interpreter step.\x0a\x09\x0a\x09self assert: self interpreter result equals: 1",
  608. messageSends: ["interpret:", "step", "interpreter", "assert:", "isNil", "result", "assert:equals:"],
  609. referencedClasses: []
  610. }),
  611. smalltalk.ASTSteppingInterpreterTest);
  612. smalltalk.addClass('InterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
  613. smalltalk.addMethod(
  614. smalltalk.method({
  615. selector: "interpret:receiver:withArguments:",
  616. category: 'interpreting',
  617. fn: function (aString,anObject,aDictionary){
  618. var self=this;
  619. var ctx,interpreter;
  620. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  621. return smalltalk.withContext(function($ctx1) {
  622. var $1,$2,$4,$5,$3;
  623. interpreter=self._interpreter();
  624. $1=_st($AIContext())._new();
  625. _st($1)._receiver_(anObject);
  626. _st($1)._interpreter_(interpreter);
  627. $2=_st($1)._yourself();
  628. ctx=$2;
  629. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  630. return smalltalk.withContext(function($ctx2) {
  631. return _st(ctx)._localAt_put_(key,value);
  632. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  633. $4=interpreter;
  634. _st($4)._context_(ctx);
  635. _st($4)._interpret_(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nextChild());
  636. _st($4)._proceed();
  637. $5=_st($4)._result();
  638. $3=$5;
  639. return $3;
  640. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx,interpreter:interpreter},smalltalk.InterpreterTest)})},
  641. args: ["aString", "anObject", "aDictionary"],
  642. source: "interpret: aString receiver: anObject withArguments: aDictionary\x0a\x09\x22The food is a methodNode. Interpret the sequenceNode only\x22\x0a\x09\x0a\x09| ctx interpreter |\x0a\x09\x0a\x09interpreter := self interpreter.\x0a\x09\x0a\x09ctx := AIContext new\x0a\x09\x09receiver: anObject;\x0a\x09\x09interpreter: interpreter;\x0a\x09\x09yourself.\x0a\x09aDictionary keysAndValuesDo: [ :key :value |\x0a\x09\x09ctx localAt: key put: value ].\x0a\x09\x0a\x09^ interpreter\x0a\x09\x09context: ctx;\x0a\x09\x09interpret: (self parse: aString forClass: anObject class) nextChild;\x0a\x09\x09proceed;\x0a\x09\x09result",
  643. messageSends: ["interpreter", "receiver:", "new", "interpreter:", "yourself", "keysAndValuesDo:", "localAt:put:", "context:", "interpret:", "nextChild", "parse:forClass:", "class", "proceed", "result"],
  644. referencedClasses: ["AIContext"]
  645. }),
  646. smalltalk.InterpreterTest);
  647. smalltalk.addMethod(
  648. smalltalk.method({
  649. selector: "interpreter",
  650. category: 'accessing',
  651. fn: function (){
  652. var self=this;
  653. function $Interpreter(){return smalltalk.Interpreter||(typeof Interpreter=="undefined"?nil:Interpreter)}
  654. return smalltalk.withContext(function($ctx1) {
  655. var $1;
  656. $1=_st($Interpreter())._new();
  657. return $1;
  658. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.InterpreterTest)})},
  659. args: [],
  660. source: "interpreter\x0a\x09^ Interpreter new",
  661. messageSends: ["new"],
  662. referencedClasses: ["Interpreter"]
  663. }),
  664. smalltalk.InterpreterTest);
  665. smalltalk.addMethod(
  666. smalltalk.method({
  667. selector: "testBinarySend",
  668. category: 'tests',
  669. fn: function (){
  670. var self=this;
  671. return smalltalk.withContext(function($ctx1) {
  672. self._assert_equals_(self._interpret_("foo ^ 2+3+4"),(9));
  673. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.InterpreterTest)})},
  674. args: [],
  675. source: "testBinarySend\x0a\x09self assert: (self interpret: 'foo ^ 2+3+4') equals: 9",
  676. messageSends: ["assert:equals:", "interpret:"],
  677. referencedClasses: []
  678. }),
  679. smalltalk.InterpreterTest);
  680. smalltalk.addMethod(
  681. smalltalk.method({
  682. selector: "testBlockLiteral",
  683. category: 'tests',
  684. fn: function (){
  685. var self=this;
  686. return smalltalk.withContext(function($ctx1) {
  687. self._assert_equals_(self._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  688. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  689. self._assert_equals_(self._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  690. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.InterpreterTest)})},
  691. args: [],
  692. source: "testBlockLiteral\x0a\x09self assert: (self interpret: 'foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a\x09self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]') equals: 1.\x0a\x09self assert: (self interpret: 'foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]') equals: 2",
  693. messageSends: ["assert:equals:", "interpret:"],
  694. referencedClasses: []
  695. }),
  696. smalltalk.InterpreterTest);
  697. smalltalk.addMethod(
  698. smalltalk.method({
  699. selector: "testCascade",
  700. category: 'tests',
  701. fn: function (){
  702. var self=this;
  703. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  704. return smalltalk.withContext(function($ctx1) {
  705. self._assert_equals_(self._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  706. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.InterpreterTest)})},
  707. args: [],
  708. source: "testCascade\x0a\x09self assert: (self interpret: 'foo ^ OrderedCollection new add: 2; add: 3; yourself') equals: (OrderedCollection with: 2 with: 3)",
  709. messageSends: ["assert:equals:", "interpret:", "with:with:"],
  710. referencedClasses: ["OrderedCollection"]
  711. }),
  712. smalltalk.InterpreterTest);
  713. smalltalk.addMethod(
  714. smalltalk.method({
  715. selector: "testDynamicArray",
  716. category: 'tests',
  717. fn: function (){
  718. var self=this;
  719. return smalltalk.withContext(function($ctx1) {
  720. self._assert_equals_(self._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  721. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.InterpreterTest)})},
  722. args: [],
  723. source: "testDynamicArray\x0a\x09self assert: (self interpret: 'foo ^ {1+1. 2+2}') equals: #(2 4)",
  724. messageSends: ["assert:equals:", "interpret:"],
  725. referencedClasses: []
  726. }),
  727. smalltalk.InterpreterTest);
  728. smalltalk.addMethod(
  729. smalltalk.method({
  730. selector: "testDynamicDictionary",
  731. category: 'tests',
  732. fn: function (){
  733. var self=this;
  734. return smalltalk.withContext(function($ctx1) {
  735. self._assert_equals_(self._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._from_([(1).__minus_gt((1)),(2).__minus_gt((3))]));
  736. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.InterpreterTest)})},
  737. args: [],
  738. source: "testDynamicDictionary\x0a\x09self assert: (self interpret: 'foo ^ #{1->1. 2->3}') equals: #{1->1. 2->3}",
  739. messageSends: ["assert:equals:", "interpret:", "->"],
  740. referencedClasses: []
  741. }),
  742. smalltalk.InterpreterTest);
  743. smalltalk.addMethod(
  744. smalltalk.method({
  745. selector: "testGlobalVar",
  746. category: 'tests',
  747. fn: function (){
  748. var self=this;
  749. return smalltalk.withContext(function($ctx1) {
  750. self._assert_equals_(self._interpret_("foo ^ window document title"),_st(_st(window)._document())._title());
  751. return self}, function($ctx1) {$ctx1.fill(self,"testGlobalVar",{},smalltalk.InterpreterTest)})},
  752. args: [],
  753. source: "testGlobalVar\x0a\x09self assert: (self interpret: 'foo ^ window document title') equals: window document title",
  754. messageSends: ["assert:equals:", "interpret:", "title", "document"],
  755. referencedClasses: []
  756. }),
  757. smalltalk.InterpreterTest);
  758. smalltalk.addMethod(
  759. smalltalk.method({
  760. selector: "testInlinedJSStatement",
  761. category: 'tests',
  762. fn: function (){
  763. var self=this;
  764. return smalltalk.withContext(function($ctx1) {
  765. self._assert_equals_(self._interpret_("foo <return 2+3>"),(5));
  766. self._assert_equals_(self._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._from_(["anInteger".__minus_gt((3))])),(5));
  767. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.InterpreterTest)})},
  768. args: [],
  769. source: "testInlinedJSStatement\x0a\x09self assert: (self interpret: 'foo <return 2+3>') equals: 5.\x0a\x09\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo: anInteger <return 2 + anInteger>'\x0a\x09\x09\x09withArguments: #{ 'anInteger' -> 3})\x0a\x09\x09equals: 5",
  770. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"],
  771. referencedClasses: []
  772. }),
  773. smalltalk.InterpreterTest);
  774. smalltalk.addMethod(
  775. smalltalk.method({
  776. selector: "testInstVarAccess",
  777. category: 'tests',
  778. fn: function (){
  779. var self=this;
  780. return smalltalk.withContext(function($ctx1) {
  781. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ x",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2));
  782. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.InterpreterTest)})},
  783. args: [],
  784. source: "testInstVarAccess\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo ^ x'\x0a\x09\x09\x09receiver: 2@3\x0a\x09\x09\x09withArguments: #{})\x0a\x09\x09equals: 2",
  785. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"],
  786. referencedClasses: []
  787. }),
  788. smalltalk.InterpreterTest);
  789. smalltalk.addMethod(
  790. smalltalk.method({
  791. selector: "testInstVarAssignment",
  792. category: 'tests',
  793. fn: function (){
  794. var self=this;
  795. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  796. return smalltalk.withContext(function($ctx1) {
  797. self._assert_equals_(self._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._from_(["anInteger".__minus_gt((2))])),(2));
  798. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.InterpreterTest)})},
  799. args: [],
  800. source: "testInstVarAssignment\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo: anInteger x := anInteger. ^ x'\x0a\x09\x09\x09receiver: Point new\x0a\x09\x09\x09withArguments: #{'anInteger' -> 2})\x0a\x09\x09equals: 2",
  801. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"],
  802. referencedClasses: ["Point"]
  803. }),
  804. smalltalk.InterpreterTest);
  805. smalltalk.addMethod(
  806. smalltalk.method({
  807. selector: "testKeywordSend",
  808. category: 'tests',
  809. fn: function (){
  810. var self=this;
  811. return smalltalk.withContext(function($ctx1) {
  812. self._assert_equals_(self._interpret_("foo ^ Point x: 1 y: 2"),(1).__at((2)));
  813. return self}, function($ctx1) {$ctx1.fill(self,"testKeywordSend",{},smalltalk.InterpreterTest)})},
  814. args: [],
  815. source: "testKeywordSend\x0a\x09self assert: (self interpret: 'foo ^ Point x: 1 y: 2') equals: 1@2",
  816. messageSends: ["assert:equals:", "interpret:", "@"],
  817. referencedClasses: []
  818. }),
  819. smalltalk.InterpreterTest);
  820. smalltalk.addMethod(
  821. smalltalk.method({
  822. selector: "testMultipleSequences",
  823. category: 'tests',
  824. fn: function (){
  825. var self=this;
  826. return smalltalk.withContext(function($ctx1) {
  827. self._assert_equals_(self._interpret_("foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6"),(30));
  828. return self}, function($ctx1) {$ctx1.fill(self,"testMultipleSequences",{},smalltalk.InterpreterTest)})},
  829. args: [],
  830. source: "testMultipleSequences\x0a\x09self assert: (self interpret: 'foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6') equals: 30",
  831. messageSends: ["assert:equals:", "interpret:"],
  832. referencedClasses: []
  833. }),
  834. smalltalk.InterpreterTest);
  835. smalltalk.addMethod(
  836. smalltalk.method({
  837. selector: "testNestedSends",
  838. category: 'tests',
  839. fn: function (){
  840. var self=this;
  841. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  842. return smalltalk.withContext(function($ctx1) {
  843. self._assert_equals_(self._interpret_("foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString"),_st(_st($Point())._x_y_((2).__at((3)),(4)))._asString());
  844. return self}, function($ctx1) {$ctx1.fill(self,"testNestedSends",{},smalltalk.InterpreterTest)})},
  845. args: [],
  846. source: "testNestedSends\x0a\x09self assert: (self interpret: 'foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString') equals: (Point x: (2@3) y: 4) asString",
  847. messageSends: ["assert:equals:", "interpret:", "asString", "x:y:", "@"],
  848. referencedClasses: ["Point"]
  849. }),
  850. smalltalk.InterpreterTest);
  851. smalltalk.addMethod(
  852. smalltalk.method({
  853. selector: "testNonlocalReturn",
  854. category: 'tests',
  855. fn: function (){
  856. var self=this;
  857. return smalltalk.withContext(function($ctx1) {
  858. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  859. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.InterpreterTest)})},
  860. args: [],
  861. source: "testNonlocalReturn\x0a\x09self assert: (self interpret: 'foo true ifTrue: [ ^ 1 ]. ^2') equals: 1",
  862. messageSends: ["assert:equals:", "interpret:"],
  863. referencedClasses: []
  864. }),
  865. smalltalk.InterpreterTest);
  866. smalltalk.addMethod(
  867. smalltalk.method({
  868. selector: "testReceiver",
  869. category: 'tests',
  870. fn: function (){
  871. var self=this;
  872. return smalltalk.withContext(function($ctx1) {
  873. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ self",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2).__at((3)));
  874. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.InterpreterTest)})},
  875. args: [],
  876. source: "testReceiver\x0a\x09self\x0a\x09\x09assert: (self\x0a\x09\x09\x09interpret: 'foo ^ self'\x0a\x09\x09\x09receiver: 2@3\x0a\x09\x09\x09withArguments: #{})\x0a\x09\x09equals: 2@3",
  877. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"],
  878. referencedClasses: []
  879. }),
  880. smalltalk.InterpreterTest);
  881. smalltalk.addMethod(
  882. smalltalk.method({
  883. selector: "testSuper",
  884. category: 'tests',
  885. fn: function (){
  886. var self=this;
  887. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  888. return smalltalk.withContext(function($ctx1) {
  889. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ super isBoolean",true,_st($Dictionary())._new()),false);
  890. return self}, function($ctx1) {$ctx1.fill(self,"testSuper",{},smalltalk.InterpreterTest)})},
  891. args: [],
  892. source: "testSuper\x0a\x09self \x0a\x09\x09assert: (self \x0a\x09\x09\x09interpret: 'foo ^ super isBoolean' \x0a\x09\x09\x09receiver: true \x0a\x09\x09\x09withArguments: Dictionary new) \x0a\x09\x09equals: false",
  893. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new"],
  894. referencedClasses: ["Dictionary"]
  895. }),
  896. smalltalk.InterpreterTest);
  897. smalltalk.addMethod(
  898. smalltalk.method({
  899. selector: "testTempAssignment",
  900. category: 'tests',
  901. fn: function (){
  902. var self=this;
  903. return smalltalk.withContext(function($ctx1) {
  904. self._assert_equals_(self._interpret_("foo | a | a := 2. ^ a"),(2));
  905. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.InterpreterTest)})},
  906. args: [],
  907. source: "testTempAssignment\x0a\x09self assert: (self interpret: 'foo | a | a := 2. ^ a') equals: 2",
  908. messageSends: ["assert:equals:", "interpret:"],
  909. referencedClasses: []
  910. }),
  911. smalltalk.InterpreterTest);
  912. smalltalk.addMethod(
  913. smalltalk.method({
  914. selector: "testThisContext",
  915. category: 'tests',
  916. fn: function (){
  917. var self=this;
  918. return smalltalk.withContext(function($ctx1) {
  919. self._assert_(_st(_st(self._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  920. self._assert_(_st(_st(self._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  921. self._assert_(self._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  922. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.InterpreterTest)})},
  923. args: [],
  924. source: "testThisContext\x0a\x09self assert: (self interpret: 'foo ^ thisContext') outerContext isNil.\x0a\x09self assert: (self interpret: 'foo ^ [ thisContext ] value') outerContext notNil.\x0a\x09self assert: (self interpret: 'foo ^ [ thisContext ] value outerContext == thisContext')",
  925. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"],
  926. referencedClasses: []
  927. }),
  928. smalltalk.InterpreterTest);
  929. smalltalk.addMethod(
  930. smalltalk.method({
  931. selector: "testUnarySend",
  932. category: 'tests',
  933. fn: function (){
  934. var self=this;
  935. return smalltalk.withContext(function($ctx1) {
  936. self._assert_equals_(self._interpret_("foo ^ 1 asString"),"1");
  937. return self}, function($ctx1) {$ctx1.fill(self,"testUnarySend",{},smalltalk.InterpreterTest)})},
  938. args: [],
  939. source: "testUnarySend\x0a\x09self assert: (self interpret: 'foo ^ 1 asString') equals: '1'",
  940. messageSends: ["assert:equals:", "interpret:"],
  941. referencedClasses: []
  942. }),
  943. smalltalk.InterpreterTest);
  944. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  945. smalltalk.addMethod(
  946. smalltalk.method({
  947. selector: "codeGeneratorClass",
  948. category: 'accessing',
  949. fn: function (){
  950. var self=this;
  951. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  952. return smalltalk.withContext(function($ctx1) {
  953. var $1;
  954. $1=$CodeGenerator();
  955. return $1;
  956. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  957. args: [],
  958. source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
  959. messageSends: [],
  960. referencedClasses: ["CodeGenerator"]
  961. }),
  962. smalltalk.CodeGeneratorTest);
  963. smalltalk.addMethod(
  964. smalltalk.method({
  965. selector: "compiler",
  966. category: 'factory',
  967. fn: function (){
  968. var self=this;
  969. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  970. return smalltalk.withContext(function($ctx1) {
  971. var $2,$3,$1;
  972. $2=_st($Compiler())._new();
  973. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  974. $3=_st($2)._yourself();
  975. $1=$3;
  976. return $1;
  977. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  978. args: [],
  979. source: "compiler\x0a\x09^ Compiler new\x0a\x09\x09codeGeneratorClass: self codeGeneratorClass;\x0a\x09\x09yourself",
  980. messageSends: ["codeGeneratorClass:", "new", "codeGeneratorClass", "yourself"],
  981. referencedClasses: ["Compiler"]
  982. }),
  983. smalltalk.CodeGeneratorTest);
  984. smalltalk.addMethod(
  985. smalltalk.method({
  986. selector: "setUp",
  987. category: 'initialization',
  988. fn: function (){
  989. var self=this;
  990. return smalltalk.withContext(function($ctx1) {
  991. self["@receiver"]=_st(self._targetClass())._new();
  992. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  993. args: [],
  994. source: "setUp\x0a\x09receiver := self targetClass new",
  995. messageSends: ["new", "targetClass"],
  996. referencedClasses: []
  997. }),
  998. smalltalk.CodeGeneratorTest);
  999. smalltalk.addMethod(
  1000. smalltalk.method({
  1001. selector: "should:return:",
  1002. category: 'testing',
  1003. fn: function (aString,anObject){
  1004. var self=this;
  1005. var method,result;
  1006. return smalltalk.withContext(function($ctx1) {
  1007. method=_st(self._compiler())._install_forClass_category_(aString,self._targetClass(),"tests");
  1008. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  1009. _st(self._targetClass())._removeCompiledMethod_(method);
  1010. self._assert_equals_(anObject,result);
  1011. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  1012. args: ["aString", "anObject"],
  1013. source: "should: aString return: anObject\x0a\x09| method result |\x0a\x0a\x09method := self compiler install: aString forClass: self targetClass category: 'tests'.\x0a\x09result := receiver perform: method selector.\x0a\x09self targetClass removeCompiledMethod: method.\x0a\x09self assert: anObject equals: result",
  1014. messageSends: ["install:forClass:category:", "compiler", "targetClass", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"],
  1015. referencedClasses: []
  1016. }),
  1017. smalltalk.CodeGeneratorTest);
  1018. smalltalk.addMethod(
  1019. smalltalk.method({
  1020. selector: "targetClass",
  1021. category: 'accessing',
  1022. fn: function (){
  1023. var self=this;
  1024. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  1025. return smalltalk.withContext(function($ctx1) {
  1026. var $1;
  1027. $1=$DoIt();
  1028. return $1;
  1029. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  1030. args: [],
  1031. source: "targetClass\x0a\x09^ DoIt",
  1032. messageSends: [],
  1033. referencedClasses: ["DoIt"]
  1034. }),
  1035. smalltalk.CodeGeneratorTest);
  1036. smalltalk.addMethod(
  1037. smalltalk.method({
  1038. selector: "tearDown",
  1039. category: 'initialization',
  1040. fn: function (){
  1041. var self=this;
  1042. return smalltalk.withContext(function($ctx1) {
  1043. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  1044. args: [],
  1045. source: "tearDown\x0a\x09\x22receiver := nil\x22",
  1046. messageSends: [],
  1047. referencedClasses: []
  1048. }),
  1049. smalltalk.CodeGeneratorTest);
  1050. smalltalk.addMethod(
  1051. smalltalk.method({
  1052. selector: "testAssignment",
  1053. category: 'tests',
  1054. fn: function (){
  1055. var self=this;
  1056. return smalltalk.withContext(function($ctx1) {
  1057. self._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  1058. self._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  1059. self._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  1060. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  1061. args: [],
  1062. 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",
  1063. messageSends: ["should:return:"],
  1064. referencedClasses: []
  1065. }),
  1066. smalltalk.CodeGeneratorTest);
  1067. smalltalk.addMethod(
  1068. smalltalk.method({
  1069. selector: "testBackslashSelectors",
  1070. category: 'tests',
  1071. fn: function (){
  1072. var self=this;
  1073. return smalltalk.withContext(function($ctx1) {
  1074. self._should_return_("\x5c arg ^ 4",(4));
  1075. self._should_return_("\x5c\x5c arg ^ 42",(42));
  1076. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  1077. args: [],
  1078. source: "testBackslashSelectors\x0a\x09\x0a\x09self should: '\x5c arg ^ 4' return: 4.\x0a\x09self should: '\x5c\x5c arg ^ 42' return: 42",
  1079. messageSends: ["should:return:"],
  1080. referencedClasses: []
  1081. }),
  1082. smalltalk.CodeGeneratorTest);
  1083. smalltalk.addMethod(
  1084. smalltalk.method({
  1085. selector: "testBlockReturn",
  1086. category: 'tests',
  1087. fn: function (){
  1088. var self=this;
  1089. return smalltalk.withContext(function($ctx1) {
  1090. self._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  1091. self._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  1092. self._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  1093. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  1094. args: [],
  1095. 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).",
  1096. messageSends: ["should:return:"],
  1097. referencedClasses: []
  1098. }),
  1099. smalltalk.CodeGeneratorTest);
  1100. smalltalk.addMethod(
  1101. smalltalk.method({
  1102. selector: "testCascades",
  1103. category: 'tests',
  1104. fn: function (){
  1105. var self=this;
  1106. return smalltalk.withContext(function($ctx1) {
  1107. self._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  1108. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  1109. args: [],
  1110. source: "testCascades\x0a\x09\x0a\x09self should: 'foo ^ Array new add: 3; add: 4; yourself' return: #(3 4)",
  1111. messageSends: ["should:return:"],
  1112. referencedClasses: []
  1113. }),
  1114. smalltalk.CodeGeneratorTest);
  1115. smalltalk.addMethod(
  1116. smalltalk.method({
  1117. selector: "testDynamicArrayElementsOrdered",
  1118. category: 'tests',
  1119. fn: function (){
  1120. var self=this;
  1121. return smalltalk.withContext(function($ctx1) {
  1122. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  1123. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  1124. args: [],
  1125. source: "testDynamicArrayElementsOrdered\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a' return: #(1 2).",
  1126. messageSends: ["should:return:"],
  1127. referencedClasses: []
  1128. }),
  1129. smalltalk.CodeGeneratorTest);
  1130. smalltalk.addMethod(
  1131. smalltalk.method({
  1132. selector: "testDynamicDictionaryElementsOrdered",
  1133. category: 'tests',
  1134. fn: function (){
  1135. var self=this;
  1136. return smalltalk.withContext(function($ctx1) {
  1137. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 'foo'->1.\x0a\x09^ #{ x. (true ifTrue: [ x := 'bar'->2 ]) }\x0a",smalltalk.HashedCollection._from_(["foo".__minus_gt((1)),"bar".__minus_gt((2))]));
  1138. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  1139. args: [],
  1140. source: "testDynamicDictionaryElementsOrdered\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := ''foo''->1.\x0a\x09^ #{ x. (true ifTrue: [ x := ''bar''->2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.",
  1141. messageSends: ["should:return:", "->"],
  1142. referencedClasses: []
  1143. }),
  1144. smalltalk.CodeGeneratorTest);
  1145. smalltalk.addMethod(
  1146. smalltalk.method({
  1147. selector: "testInnerTemporalDependentElementsOrdered",
  1148. category: 'tests',
  1149. fn: function (){
  1150. var self=this;
  1151. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  1152. return smalltalk.withContext(function($ctx1) {
  1153. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",["foo".__minus_gt($Array()),"bar".__minus_gt((2))]);
  1154. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",["foo".__minus_gt((1)),"bar".__minus_gt((2))]);
  1155. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",["foo".__minus_gt((1)),"bar".__minus_gt((2))]);
  1156. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._from_(["foo".__minus_gt((1)),"bar".__minus_gt((2))]));
  1157. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  1158. args: [],
  1159. source: "testInnerTemporalDependentElementsOrdered\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\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\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\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ ''foo''->x. ''bar''->(true ifTrue: [ x := 2 ]) }\x0a' return: #{'foo'->1. 'bar'->2}.",
  1160. messageSends: ["should:return:", "->"],
  1161. referencedClasses: ["Array"]
  1162. }),
  1163. smalltalk.CodeGeneratorTest);
  1164. smalltalk.addMethod(
  1165. smalltalk.method({
  1166. selector: "testLiterals",
  1167. category: 'tests',
  1168. fn: function (){
  1169. var self=this;
  1170. return smalltalk.withContext(function($ctx1) {
  1171. self._should_return_("foo ^ 1",(1));
  1172. self._should_return_("foo ^ 'hello'","hello");
  1173. self._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  1174. self._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  1175. self._should_return_("foo ^ true",true);
  1176. self._should_return_("foo ^ false",false);
  1177. self._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._from_([(1).__minus_gt((2)),(3).__minus_gt((4))]));
  1178. self._should_return_("foo ^ #hello","hello");
  1179. self._should_return_("foo ^ -123.456",(-123.456));
  1180. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  1181. args: [],
  1182. 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 ^ -123.456' return: -123.456",
  1183. messageSends: ["should:return:", "->"],
  1184. referencedClasses: []
  1185. }),
  1186. smalltalk.CodeGeneratorTest);
  1187. smalltalk.addMethod(
  1188. smalltalk.method({
  1189. selector: "testLocalReturn",
  1190. category: 'tests',
  1191. fn: function (){
  1192. var self=this;
  1193. return smalltalk.withContext(function($ctx1) {
  1194. self._should_return_("foo ^ 1",(1));
  1195. self._should_return_("foo ^ 1 + 1",(2));
  1196. self._should_return_("foo ",self["@receiver"]);
  1197. self._should_return_("foo self asString",self["@receiver"]);
  1198. self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  1199. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  1200. args: [],
  1201. 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",
  1202. messageSends: ["should:return:"],
  1203. referencedClasses: []
  1204. }),
  1205. smalltalk.CodeGeneratorTest);
  1206. smalltalk.addMethod(
  1207. smalltalk.method({
  1208. selector: "testMessageSends",
  1209. category: 'tests',
  1210. fn: function (){
  1211. var self=this;
  1212. return smalltalk.withContext(function($ctx1) {
  1213. self._should_return_("foo ^ 1 asString","1");
  1214. self._should_return_("foo ^ 1 + 1",(2));
  1215. self._should_return_("foo ^ 1 + 2 * 3",(9));
  1216. self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  1217. self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  1218. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  1219. args: [],
  1220. 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)",
  1221. messageSends: ["should:return:"],
  1222. referencedClasses: []
  1223. }),
  1224. smalltalk.CodeGeneratorTest);
  1225. smalltalk.addMethod(
  1226. smalltalk.method({
  1227. selector: "testMutableLiterals",
  1228. category: 'tests',
  1229. fn: function (){
  1230. var self=this;
  1231. return smalltalk.withContext(function($ctx1) {
  1232. self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  1233. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  1234. args: [],
  1235. source: "testMutableLiterals\x0a\x09\x22Mutable literals must be aliased in cascades.\x0a\x09See https://github.com/amber-smalltalk/amber/issues/428\x22\x0a\x09\x0a\x09self \x0a\x09\x09should: 'foo ^ #( 1 2 ) at: 1 put: 3; yourself' \x0a\x09\x09return: #(3 2)",
  1236. messageSends: ["should:return:"],
  1237. referencedClasses: []
  1238. }),
  1239. smalltalk.CodeGeneratorTest);
  1240. smalltalk.addMethod(
  1241. smalltalk.method({
  1242. selector: "testNestedIfTrue",
  1243. category: 'tests',
  1244. fn: function (){
  1245. var self=this;
  1246. return smalltalk.withContext(function($ctx1) {
  1247. self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  1248. self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  1249. self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  1250. self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  1251. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  1252. args: [],
  1253. 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.",
  1254. messageSends: ["should:return:"],
  1255. referencedClasses: []
  1256. }),
  1257. smalltalk.CodeGeneratorTest);
  1258. smalltalk.addMethod(
  1259. smalltalk.method({
  1260. selector: "testNonLocalReturn",
  1261. category: 'tests',
  1262. fn: function (){
  1263. var self=this;
  1264. return smalltalk.withContext(function($ctx1) {
  1265. self._should_return_("foo [ ^ 1 ] value",(1));
  1266. self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  1267. self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  1268. self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  1269. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  1270. args: [],
  1271. 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",
  1272. messageSends: ["should:return:"],
  1273. referencedClasses: []
  1274. }),
  1275. smalltalk.CodeGeneratorTest);
  1276. smalltalk.addMethod(
  1277. smalltalk.method({
  1278. selector: "testPascalCaseGlobal",
  1279. category: 'tests',
  1280. fn: function (){
  1281. var self=this;
  1282. return smalltalk.withContext(function($ctx1) {
  1283. self._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  1284. self._should_return_("foo ^NonExistent",nil);
  1285. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  1286. args: [],
  1287. source: "testPascalCaseGlobal\x0a\x09self should: 'foo ^Object' return: (smalltalk at: 'Object').\x0a\x09self should: 'foo ^NonExistent' return: nil",
  1288. messageSends: ["should:return:", "at:"],
  1289. referencedClasses: []
  1290. }),
  1291. smalltalk.CodeGeneratorTest);
  1292. smalltalk.addMethod(
  1293. smalltalk.method({
  1294. selector: "testSendReceiverAndArgumentsOrdered",
  1295. category: 'tests',
  1296. fn: function (){
  1297. var self=this;
  1298. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  1299. return smalltalk.withContext(function($ctx1) {
  1300. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  1301. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  1302. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  1303. args: [],
  1304. 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}.",
  1305. messageSends: ["should:return:"],
  1306. referencedClasses: ["Array"]
  1307. }),
  1308. smalltalk.CodeGeneratorTest);
  1309. smalltalk.addMethod(
  1310. smalltalk.method({
  1311. selector: "testifFalse",
  1312. category: 'tests',
  1313. fn: function (){
  1314. var self=this;
  1315. return smalltalk.withContext(function($ctx1) {
  1316. self._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  1317. self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  1318. self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  1319. self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  1320. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  1321. args: [],
  1322. 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.",
  1323. messageSends: ["should:return:"],
  1324. referencedClasses: []
  1325. }),
  1326. smalltalk.CodeGeneratorTest);
  1327. smalltalk.addMethod(
  1328. smalltalk.method({
  1329. selector: "testifFalseIfTrue",
  1330. category: 'tests',
  1331. fn: function (){
  1332. var self=this;
  1333. return smalltalk.withContext(function($ctx1) {
  1334. self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  1335. self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  1336. self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  1337. self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  1338. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  1339. args: [],
  1340. 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.",
  1341. messageSends: ["should:return:"],
  1342. referencedClasses: []
  1343. }),
  1344. smalltalk.CodeGeneratorTest);
  1345. smalltalk.addMethod(
  1346. smalltalk.method({
  1347. selector: "testifNil",
  1348. category: 'tests',
  1349. fn: function (){
  1350. var self=this;
  1351. return smalltalk.withContext(function($ctx1) {
  1352. self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  1353. self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  1354. self._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  1355. self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  1356. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  1357. args: [],
  1358. 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.",
  1359. messageSends: ["should:return:"],
  1360. referencedClasses: []
  1361. }),
  1362. smalltalk.CodeGeneratorTest);
  1363. smalltalk.addMethod(
  1364. smalltalk.method({
  1365. selector: "testifNilIfNotNil",
  1366. category: 'tests',
  1367. fn: function (){
  1368. var self=this;
  1369. return smalltalk.withContext(function($ctx1) {
  1370. self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  1371. self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  1372. self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  1373. self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  1374. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  1375. args: [],
  1376. 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.",
  1377. messageSends: ["should:return:"],
  1378. referencedClasses: []
  1379. }),
  1380. smalltalk.CodeGeneratorTest);
  1381. smalltalk.addMethod(
  1382. smalltalk.method({
  1383. selector: "testifNotNil",
  1384. category: 'tests',
  1385. fn: function (){
  1386. var self=this;
  1387. return smalltalk.withContext(function($ctx1) {
  1388. self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  1389. self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  1390. self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  1391. self._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  1392. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  1393. args: [],
  1394. 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.",
  1395. messageSends: ["should:return:"],
  1396. referencedClasses: []
  1397. }),
  1398. smalltalk.CodeGeneratorTest);
  1399. smalltalk.addMethod(
  1400. smalltalk.method({
  1401. selector: "testifNotNilWithArgument",
  1402. category: 'tests',
  1403. fn: function (){
  1404. var self=this;
  1405. return smalltalk.withContext(function($ctx1) {
  1406. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  1407. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  1408. self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  1409. self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  1410. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  1411. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  1412. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  1413. args: [],
  1414. 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",
  1415. messageSends: ["should:return:"],
  1416. referencedClasses: []
  1417. }),
  1418. smalltalk.CodeGeneratorTest);
  1419. smalltalk.addMethod(
  1420. smalltalk.method({
  1421. selector: "testifTrue",
  1422. category: 'tests',
  1423. fn: function (){
  1424. var self=this;
  1425. return smalltalk.withContext(function($ctx1) {
  1426. self._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  1427. self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  1428. self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  1429. self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  1430. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  1431. args: [],
  1432. 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.",
  1433. messageSends: ["should:return:"],
  1434. referencedClasses: []
  1435. }),
  1436. smalltalk.CodeGeneratorTest);
  1437. smalltalk.addMethod(
  1438. smalltalk.method({
  1439. selector: "testifTrueIfFalse",
  1440. category: 'tests',
  1441. fn: function (){
  1442. var self=this;
  1443. return smalltalk.withContext(function($ctx1) {
  1444. self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  1445. self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  1446. self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  1447. self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  1448. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  1449. args: [],
  1450. 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.",
  1451. messageSends: ["should:return:"],
  1452. referencedClasses: []
  1453. }),
  1454. smalltalk.CodeGeneratorTest);
  1455. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  1456. smalltalk.addMethod(
  1457. smalltalk.method({
  1458. selector: "codeGeneratorClass",
  1459. category: 'accessing',
  1460. fn: function (){
  1461. var self=this;
  1462. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  1463. return smalltalk.withContext(function($ctx1) {
  1464. var $1;
  1465. $1=$InliningCodeGenerator();
  1466. return $1;
  1467. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  1468. args: [],
  1469. source: "codeGeneratorClass\x0a\x09^ InliningCodeGenerator",
  1470. messageSends: [],
  1471. referencedClasses: ["InliningCodeGenerator"]
  1472. }),
  1473. smalltalk.InliningCodeGeneratorTest);
  1474. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  1475. smalltalk.addMethod(
  1476. smalltalk.method({
  1477. selector: "testClassRefVar",
  1478. category: 'tests',
  1479. fn: function (){
  1480. var self=this;
  1481. var node;
  1482. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  1483. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1484. return smalltalk.withContext(function($ctx1) {
  1485. var $1,$2;
  1486. $1=_st($ClassReferenceNode())._new();
  1487. _st($1)._value_("Object");
  1488. $2=_st($1)._yourself();
  1489. node=$2;
  1490. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  1491. self._assert_(_st(_st(node)._binding())._isClassRefVar());
  1492. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  1493. args: [],
  1494. source: "testClassRefVar\x0a\x09| node |\x0a\x09node := ClassReferenceNode new\x0a\x09\x09value: 'Object';\x0a\x09\x09yourself.\x0a\x09SemanticAnalyzer new visit: node.\x0a\x09self assert: node binding isClassRefVar",
  1495. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"],
  1496. referencedClasses: ["ClassReferenceNode", "SemanticAnalyzer"]
  1497. }),
  1498. smalltalk.ScopeVarTest);
  1499. smalltalk.addMethod(
  1500. smalltalk.method({
  1501. selector: "testInstanceVar",
  1502. category: 'tests',
  1503. fn: function (){
  1504. var self=this;
  1505. var node,scope;
  1506. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1507. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1508. return smalltalk.withContext(function($ctx1) {
  1509. var $1,$2;
  1510. $1=_st($VariableNode())._new();
  1511. _st($1)._value_("bzzz");
  1512. $2=_st($1)._yourself();
  1513. node=$2;
  1514. scope=_st($MethodLexicalScope())._new();
  1515. _st(scope)._addIVar_("bzzz");
  1516. self._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  1517. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1518. args: [],
  1519. 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",
  1520. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"],
  1521. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1522. }),
  1523. smalltalk.ScopeVarTest);
  1524. smalltalk.addMethod(
  1525. smalltalk.method({
  1526. selector: "testPseudoVar",
  1527. category: 'tests',
  1528. fn: function (){
  1529. var self=this;
  1530. var node,pseudoVars;
  1531. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1532. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1533. return smalltalk.withContext(function($ctx1) {
  1534. var $1,$2;
  1535. pseudoVars=["self", "super", "true", "false", "nil"];
  1536. _st(pseudoVars)._do_((function(each){
  1537. return smalltalk.withContext(function($ctx2) {
  1538. $1=_st($VariableNode())._new();
  1539. _st($1)._value_(each);
  1540. $2=_st($1)._yourself();
  1541. node=$2;
  1542. node;
  1543. return self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  1544. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1545. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  1546. args: [],
  1547. 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 ]",
  1548. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"],
  1549. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1550. }),
  1551. smalltalk.ScopeVarTest);
  1552. smalltalk.addMethod(
  1553. smalltalk.method({
  1554. selector: "testTempVar",
  1555. category: 'tests',
  1556. fn: function (){
  1557. var self=this;
  1558. var node,scope;
  1559. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1560. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1561. return smalltalk.withContext(function($ctx1) {
  1562. var $1,$2;
  1563. $1=_st($VariableNode())._new();
  1564. _st($1)._value_("bzzz");
  1565. $2=_st($1)._yourself();
  1566. node=$2;
  1567. scope=_st($MethodLexicalScope())._new();
  1568. _st(scope)._addTemp_("bzzz");
  1569. self._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  1570. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1571. args: [],
  1572. 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",
  1573. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"],
  1574. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1575. }),
  1576. smalltalk.ScopeVarTest);
  1577. smalltalk.addMethod(
  1578. smalltalk.method({
  1579. selector: "testUnknownVar",
  1580. category: 'tests',
  1581. fn: function (){
  1582. var self=this;
  1583. var node;
  1584. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1585. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1586. return smalltalk.withContext(function($ctx1) {
  1587. var $1,$2;
  1588. $1=_st($VariableNode())._new();
  1589. _st($1)._value_("bzzz");
  1590. $2=_st($1)._yourself();
  1591. node=$2;
  1592. self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  1593. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  1594. args: [],
  1595. source: "testUnknownVar\x0a\x09| node |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09self assert: (MethodLexicalScope new bindingFor: node) isNil",
  1596. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"],
  1597. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1598. }),
  1599. smalltalk.ScopeVarTest);
  1600. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  1601. smalltalk.addMethod(
  1602. smalltalk.method({
  1603. selector: "setUp",
  1604. category: 'running',
  1605. fn: function (){
  1606. var self=this;
  1607. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1608. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1609. return smalltalk.withContext(function($ctx1) {
  1610. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  1611. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  1612. args: [],
  1613. source: "setUp\x0a\x09analyzer := SemanticAnalyzer on: Object",
  1614. messageSends: ["on:"],
  1615. referencedClasses: ["SemanticAnalyzer", "Object"]
  1616. }),
  1617. smalltalk.SemanticAnalyzerTest);
  1618. smalltalk.addMethod(
  1619. smalltalk.method({
  1620. selector: "testAssignment",
  1621. category: 'tests',
  1622. fn: function (){
  1623. var self=this;
  1624. var src,ast;
  1625. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  1626. return smalltalk.withContext(function($ctx1) {
  1627. src="foo self := 1";
  1628. ast=_st(smalltalk)._parse_(src);
  1629. self._should_raise_((function(){
  1630. return smalltalk.withContext(function($ctx2) {
  1631. return _st(self["@analyzer"])._visit_(ast);
  1632. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$InvalidAssignmentError());
  1633. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1634. args: [],
  1635. 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",
  1636. messageSends: ["parse:", "should:raise:", "visit:"],
  1637. referencedClasses: ["InvalidAssignmentError"]
  1638. }),
  1639. smalltalk.SemanticAnalyzerTest);
  1640. smalltalk.addMethod(
  1641. smalltalk.method({
  1642. selector: "testNonLocalReturn",
  1643. category: 'tests',
  1644. fn: function (){
  1645. var self=this;
  1646. var src,ast;
  1647. return smalltalk.withContext(function($ctx1) {
  1648. src="foo | a | a + 1. ^ a";
  1649. ast=_st(smalltalk)._parse_(src);
  1650. _st(self["@analyzer"])._visit_(ast);
  1651. self._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1652. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1653. args: [],
  1654. 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",
  1655. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"],
  1656. referencedClasses: []
  1657. }),
  1658. smalltalk.SemanticAnalyzerTest);
  1659. smalltalk.addMethod(
  1660. smalltalk.method({
  1661. selector: "testNonLocalReturn2",
  1662. category: 'tests',
  1663. fn: function (){
  1664. var self=this;
  1665. var src,ast;
  1666. return smalltalk.withContext(function($ctx1) {
  1667. src="foo | a | a + 1. [ [ ^ a] ]";
  1668. ast=_st(smalltalk)._parse_(src);
  1669. _st(self["@analyzer"])._visit_(ast);
  1670. self._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1671. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1672. args: [],
  1673. 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",
  1674. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"],
  1675. referencedClasses: []
  1676. }),
  1677. smalltalk.SemanticAnalyzerTest);
  1678. smalltalk.addMethod(
  1679. smalltalk.method({
  1680. selector: "testScope",
  1681. category: 'tests',
  1682. fn: function (){
  1683. var self=this;
  1684. var src,ast;
  1685. return smalltalk.withContext(function($ctx1) {
  1686. src="foo | a | a + 1. [ | b | b := a ]";
  1687. ast=_st(smalltalk)._parse_(src);
  1688. _st(self["@analyzer"])._visit_(ast);
  1689. self._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  1690. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1691. args: [],
  1692. source: "testScope\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast nodes first nodes last scope == ast scope.",
  1693. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"],
  1694. referencedClasses: []
  1695. }),
  1696. smalltalk.SemanticAnalyzerTest);
  1697. smalltalk.addMethod(
  1698. smalltalk.method({
  1699. selector: "testScope2",
  1700. category: 'tests',
  1701. fn: function (){
  1702. var self=this;
  1703. var src,ast;
  1704. return smalltalk.withContext(function($ctx1) {
  1705. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1706. ast=_st(smalltalk)._parse_(src);
  1707. _st(self["@analyzer"])._visit_(ast);
  1708. self._deny_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope()).__eq_eq(_st(ast)._scope()));
  1709. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1710. args: [],
  1711. source: "testScope2\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self deny: ast nodes first nodes last nodes first nodes first scope == ast scope.",
  1712. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"],
  1713. referencedClasses: []
  1714. }),
  1715. smalltalk.SemanticAnalyzerTest);
  1716. smalltalk.addMethod(
  1717. smalltalk.method({
  1718. selector: "testScopeLevel",
  1719. category: 'tests',
  1720. fn: function (){
  1721. var self=this;
  1722. var src,ast;
  1723. return smalltalk.withContext(function($ctx1) {
  1724. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1725. ast=_st(smalltalk)._parse_(src);
  1726. _st(self["@analyzer"])._visit_(ast);
  1727. self._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  1728. self._assert_equals_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope())._scopeLevel(),(3));
  1729. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1730. args: [],
  1731. source: "testScopeLevel\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ [ | b | b := a ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09self assert: ast scope scopeLevel equals: 1.\x0a\x09self assert: ast nodes first nodes last nodes first nodes first scope scopeLevel equals: 3",
  1732. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"],
  1733. referencedClasses: []
  1734. }),
  1735. smalltalk.SemanticAnalyzerTest);
  1736. smalltalk.addMethod(
  1737. smalltalk.method({
  1738. selector: "testUnknownVariables",
  1739. category: 'tests',
  1740. fn: function (){
  1741. var self=this;
  1742. var src,ast;
  1743. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1744. return smalltalk.withContext(function($ctx1) {
  1745. src="foo | a | b + a";
  1746. ast=_st(smalltalk)._parse_(src);
  1747. self._should_raise_((function(){
  1748. return smalltalk.withContext(function($ctx2) {
  1749. return _st(self["@analyzer"])._visit_(ast);
  1750. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1751. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1752. args: [],
  1753. 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",
  1754. messageSends: ["parse:", "should:raise:", "visit:"],
  1755. referencedClasses: ["UnknownVariableError"]
  1756. }),
  1757. smalltalk.SemanticAnalyzerTest);
  1758. smalltalk.addMethod(
  1759. smalltalk.method({
  1760. selector: "testUnknownVariablesWithScope",
  1761. category: 'tests',
  1762. fn: function (){
  1763. var self=this;
  1764. var src,ast;
  1765. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1766. return smalltalk.withContext(function($ctx1) {
  1767. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  1768. ast=_st(smalltalk)._parse_(src);
  1769. self._should_raise_((function(){
  1770. return smalltalk.withContext(function($ctx2) {
  1771. return _st(self["@analyzer"])._visit_(ast);
  1772. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1773. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1774. args: [],
  1775. 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",
  1776. messageSends: ["parse:", "should:raise:", "visit:"],
  1777. referencedClasses: ["UnknownVariableError"]
  1778. }),
  1779. smalltalk.SemanticAnalyzerTest);
  1780. smalltalk.addMethod(
  1781. smalltalk.method({
  1782. selector: "testVariableShadowing",
  1783. category: 'tests',
  1784. fn: function (){
  1785. var self=this;
  1786. var src,ast;
  1787. return smalltalk.withContext(function($ctx1) {
  1788. src="foo | a | a + 1";
  1789. ast=_st(smalltalk)._parse_(src);
  1790. _st(self["@analyzer"])._visit_(ast);
  1791. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1792. args: [],
  1793. source: "testVariableShadowing\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1794. messageSends: ["parse:", "visit:"],
  1795. referencedClasses: []
  1796. }),
  1797. smalltalk.SemanticAnalyzerTest);
  1798. smalltalk.addMethod(
  1799. smalltalk.method({
  1800. selector: "testVariableShadowing2",
  1801. category: 'tests',
  1802. fn: function (){
  1803. var self=this;
  1804. var src,ast;
  1805. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1806. return smalltalk.withContext(function($ctx1) {
  1807. src="foo | a | a + 1. [ | a | a := 2 ]";
  1808. ast=_st(smalltalk)._parse_(src);
  1809. self._should_raise_((function(){
  1810. return smalltalk.withContext(function($ctx2) {
  1811. return _st(self["@analyzer"])._visit_(ast);
  1812. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1813. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1814. args: [],
  1815. 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",
  1816. messageSends: ["parse:", "should:raise:", "visit:"],
  1817. referencedClasses: ["ShadowingVariableError"]
  1818. }),
  1819. smalltalk.SemanticAnalyzerTest);
  1820. smalltalk.addMethod(
  1821. smalltalk.method({
  1822. selector: "testVariableShadowing3",
  1823. category: 'tests',
  1824. fn: function (){
  1825. var self=this;
  1826. var src,ast;
  1827. return smalltalk.withContext(function($ctx1) {
  1828. src="foo | a | a + 1. [ | b | b := 2 ]";
  1829. ast=_st(smalltalk)._parse_(src);
  1830. _st(self["@analyzer"])._visit_(ast);
  1831. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1832. args: [],
  1833. source: "testVariableShadowing3\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | b | b := 2 ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1834. messageSends: ["parse:", "visit:"],
  1835. referencedClasses: []
  1836. }),
  1837. smalltalk.SemanticAnalyzerTest);
  1838. smalltalk.addMethod(
  1839. smalltalk.method({
  1840. selector: "testVariableShadowing4",
  1841. category: 'tests',
  1842. fn: function (){
  1843. var self=this;
  1844. var src,ast;
  1845. return smalltalk.withContext(function($ctx1) {
  1846. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1847. ast=_st(smalltalk)._parse_(src);
  1848. _st(self["@analyzer"])._visit_(ast);
  1849. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1850. args: [],
  1851. source: "testVariableShadowing4\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1852. messageSends: ["parse:", "visit:"],
  1853. referencedClasses: []
  1854. }),
  1855. smalltalk.SemanticAnalyzerTest);
  1856. smalltalk.addMethod(
  1857. smalltalk.method({
  1858. selector: "testVariableShadowing5",
  1859. category: 'tests',
  1860. fn: function (){
  1861. var self=this;
  1862. var src,ast;
  1863. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1864. return smalltalk.withContext(function($ctx1) {
  1865. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1866. ast=_st(smalltalk)._parse_(src);
  1867. self._should_raise_((function(){
  1868. return smalltalk.withContext(function($ctx2) {
  1869. return _st(self["@analyzer"])._visit_(ast);
  1870. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1871. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1872. args: [],
  1873. 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",
  1874. messageSends: ["parse:", "should:raise:", "visit:"],
  1875. referencedClasses: ["ShadowingVariableError"]
  1876. }),
  1877. smalltalk.SemanticAnalyzerTest);
  1878. smalltalk.addMethod(
  1879. smalltalk.method({
  1880. selector: "testVariablesLookup",
  1881. category: 'tests',
  1882. fn: function (){
  1883. var self=this;
  1884. var src,ast;
  1885. return smalltalk.withContext(function($ctx1) {
  1886. src="foo | a | a + 1. [ | b | b := a ]";
  1887. ast=_st(smalltalk)._parse_(src);
  1888. _st(self["@analyzer"])._visit_(ast);
  1889. self._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1890. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1891. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._isTempVar());
  1892. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._scope()).__eq_eq(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()));
  1893. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1894. args: [],
  1895. source: "testVariablesLookup\x0a\x09| src ast |\x0a\x0a\x09src := 'foo | a | a + 1. [ | b | b := a ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast.\x0a\x0a\x09\x22Binding for `a` in the message send\x22\x0a\x09self assert: ast nodes first nodes first receiver binding isTempVar.\x0a\x09self assert: ast nodes first nodes first receiver binding scope == ast scope.\x0a\x0a\x09\x22Binding for `b`\x22\x0a\x09self assert: ast nodes first nodes last nodes first nodes first left binding isTempVar.\x0a\x09self assert: ast nodes first nodes last nodes first nodes first left binding scope == ast nodes first nodes last scope.",
  1896. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"],
  1897. referencedClasses: []
  1898. }),
  1899. smalltalk.SemanticAnalyzerTest);