Compiler-Tests.js 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481
  1. define("amber_core/Compiler-Tests", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/SUnit"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Tests');
  3. smalltalk.packages["Compiler-Tests"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('ASTParsingTest', smalltalk.TestCase, [], 'Compiler-Tests');
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "analyze:forClass:",
  8. category: 'convenience',
  9. fn: function (aNode,aClass){
  10. var self=this;
  11. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  12. return smalltalk.withContext(function($ctx1) {
  13. var $1;
  14. _st(_st($SemanticAnalyzer())._on_(aClass))._visit_(aNode);
  15. $1=aNode;
  16. return $1;
  17. }, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},smalltalk.ASTParsingTest)})},
  18. args: ["aNode", "aClass"],
  19. source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a\x09^ aNode",
  20. messageSends: ["visit:", "on:"],
  21. referencedClasses: ["SemanticAnalyzer"]
  22. }),
  23. smalltalk.ASTParsingTest);
  24. smalltalk.addMethod(
  25. smalltalk.method({
  26. selector: "parse:",
  27. category: 'parsing',
  28. fn: function (aString){
  29. var self=this;
  30. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  31. return smalltalk.withContext(function($ctx1) {
  32. var $1;
  33. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  34. return $1;
  35. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.ASTParsingTest)})},
  36. args: ["aString"],
  37. source: "parse: aString\x0a\x09^ Smalltalk current parse: aString",
  38. messageSends: ["parse:", "current"],
  39. referencedClasses: ["Smalltalk"]
  40. }),
  41. smalltalk.ASTParsingTest);
  42. smalltalk.addMethod(
  43. smalltalk.method({
  44. selector: "parse:forClass:",
  45. category: 'parsing',
  46. fn: function (aString,aClass){
  47. var self=this;
  48. return smalltalk.withContext(function($ctx1) {
  49. var $1;
  50. $1=self._analyze_forClass_(self._parse_(aString),aClass);
  51. return $1;
  52. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.ASTParsingTest)})},
  53. args: ["aString", "aClass"],
  54. source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
  55. messageSends: ["analyze:forClass:", "parse:"],
  56. referencedClasses: []
  57. }),
  58. smalltalk.ASTParsingTest);
  59. smalltalk.addClass('ASTPCNodeVisitorTest', smalltalk.ASTParsingTest, [], 'Compiler-Tests');
  60. smalltalk.addMethod(
  61. smalltalk.method({
  62. selector: "astPCNodeVisitor",
  63. category: 'factory',
  64. fn: function (){
  65. var self=this;
  66. return smalltalk.withContext(function($ctx1) {
  67. var $1;
  68. $1=self._astPCNodeVisitorForPC_((0));
  69. return $1;
  70. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitor",{},smalltalk.ASTPCNodeVisitorTest)})},
  71. args: [],
  72. source: "astPCNodeVisitor\x0a\x09^ self astPCNodeVisitorForPC: 0",
  73. messageSends: ["astPCNodeVisitorForPC:"],
  74. referencedClasses: []
  75. }),
  76. smalltalk.ASTPCNodeVisitorTest);
  77. smalltalk.addMethod(
  78. smalltalk.method({
  79. selector: "astPCNodeVisitorForPC:",
  80. category: 'factory',
  81. fn: function (anInteger){
  82. var self=this;
  83. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  84. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  85. return smalltalk.withContext(function($ctx1) {
  86. var $2,$3,$4,$5,$1;
  87. $2=_st($ASTPCNodeVisitor())._new();
  88. _st($2)._pc_((0));
  89. $3=_st($AIContext())._new();
  90. _st($3)._pc_(anInteger);
  91. $4=_st($3)._yourself();
  92. _st($2)._context_($4);
  93. $5=_st($2)._yourself();
  94. $1=$5;
  95. return $1;
  96. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitorForPC:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitorTest)})},
  97. args: ["anInteger"],
  98. 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",
  99. messageSends: ["pc:", "new", "context:", "yourself"],
  100. referencedClasses: ["ASTPCNodeVisitor", "AIContext"]
  101. }),
  102. smalltalk.ASTPCNodeVisitorTest);
  103. smalltalk.addMethod(
  104. smalltalk.method({
  105. selector: "testJSStatementNode",
  106. category: 'tests',
  107. fn: function (){
  108. var self=this;
  109. var ast,visitor;
  110. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  111. return smalltalk.withContext(function($ctx1) {
  112. var $1,$2;
  113. ast=self._parse_forClass_("foo <consolee.log(1)>",$Object());
  114. $1=self._astPCNodeVisitor();
  115. _st($1)._visit_(ast);
  116. $2=_st($1)._currentNode();
  117. self._assert_(_st($2)._isJSStatementNode());
  118. return self}, function($ctx1) {$ctx1.fill(self,"testJSStatementNode",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  119. args: [],
  120. 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",
  121. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"],
  122. referencedClasses: ["Object"]
  123. }),
  124. smalltalk.ASTPCNodeVisitorTest);
  125. smalltalk.addMethod(
  126. smalltalk.method({
  127. selector: "testMessageSend",
  128. category: 'tests',
  129. fn: function (){
  130. var self=this;
  131. var ast;
  132. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  133. return smalltalk.withContext(function($ctx1) {
  134. var $1,$2;
  135. ast=self._parse_forClass_("foo self asString yourself. ^ self asBoolean",$Object());
  136. $1=self._astPCNodeVisitorForPC_((2));
  137. _st($1)._visit_(ast);
  138. $2=_st($1)._currentNode();
  139. self._assert_equals_(_st($2)._selector(),"yourself");
  140. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  141. args: [],
  142. 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'",
  143. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"],
  144. referencedClasses: ["Object"]
  145. }),
  146. smalltalk.ASTPCNodeVisitorTest);
  147. smalltalk.addMethod(
  148. smalltalk.method({
  149. selector: "testMessageSendWithInlining",
  150. category: 'tests',
  151. fn: function (){
  152. var self=this;
  153. var ast;
  154. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  155. return smalltalk.withContext(function($ctx1) {
  156. var $1,$2,$3,$4;
  157. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  158. $1=self._astPCNodeVisitorForPC_((2));
  159. _st($1)._visit_(ast);
  160. $2=_st($1)._currentNode();
  161. self._assert_equals_(_st($2)._selector(),"yourself");
  162. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  163. $3=self._astPCNodeVisitorForPC_((3));
  164. _st($3)._visit_(ast);
  165. $4=_st($3)._currentNode();
  166. self._assert_equals_(_st($4)._selector(),"asBoolean");
  167. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSendWithInlining",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  168. args: [],
  169. 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'",
  170. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"],
  171. referencedClasses: ["Object"]
  172. }),
  173. smalltalk.ASTPCNodeVisitorTest);
  174. smalltalk.addMethod(
  175. smalltalk.method({
  176. selector: "testNoMessageSend",
  177. category: 'tests',
  178. fn: function (){
  179. var self=this;
  180. var ast;
  181. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  182. return smalltalk.withContext(function($ctx1) {
  183. var $1,$2;
  184. ast=self._parse_forClass_("foo ^ self",$Object());
  185. $1=self._astPCNodeVisitor();
  186. _st($1)._visit_(ast);
  187. $2=_st($1)._currentNode();
  188. self._assert_(_st($2)._isNil());
  189. return self}, function($ctx1) {$ctx1.fill(self,"testNoMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  190. args: [],
  191. 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",
  192. messageSends: ["parse:forClass:", "assert:", "isNil", "visit:", "astPCNodeVisitor", "currentNode"],
  193. referencedClasses: ["Object"]
  194. }),
  195. smalltalk.ASTPCNodeVisitorTest);
  196. smalltalk.addMethod(
  197. smalltalk.method({
  198. selector: "testPC",
  199. category: 'tests',
  200. fn: function (){
  201. var self=this;
  202. var ast,visitor;
  203. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  204. return smalltalk.withContext(function($ctx1) {
  205. var $1,$2;
  206. ast=self._parse_forClass_("foo <console.log(1)>",$Object());
  207. $1=self._astPCNodeVisitor();
  208. _st($1)._visit_(ast);
  209. $2=_st($1)._currentNode();
  210. self._assert_(_st($2)._isJSStatementNode());
  211. return self}, function($ctx1) {$ctx1.fill(self,"testPC",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  212. args: [],
  213. 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",
  214. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"],
  215. referencedClasses: ["Object"]
  216. }),
  217. smalltalk.ASTPCNodeVisitorTest);
  218. smalltalk.addClass('CodeGeneratorTest', smalltalk.ASTParsingTest, ['receiver'], 'Compiler-Tests');
  219. smalltalk.addMethod(
  220. smalltalk.method({
  221. selector: "codeGeneratorClass",
  222. category: 'accessing',
  223. fn: function (){
  224. var self=this;
  225. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  226. return smalltalk.withContext(function($ctx1) {
  227. var $1;
  228. $1=$CodeGenerator();
  229. return $1;
  230. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  231. args: [],
  232. source: "codeGeneratorClass\x0a\x09^ CodeGenerator",
  233. messageSends: [],
  234. referencedClasses: ["CodeGenerator"]
  235. }),
  236. smalltalk.CodeGeneratorTest);
  237. smalltalk.addMethod(
  238. smalltalk.method({
  239. selector: "compiler",
  240. category: 'factory',
  241. fn: function (){
  242. var self=this;
  243. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  244. return smalltalk.withContext(function($ctx1) {
  245. var $2,$3,$1;
  246. $2=_st($Compiler())._new();
  247. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  248. $3=_st($2)._yourself();
  249. $1=$3;
  250. return $1;
  251. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  252. args: [],
  253. source: "compiler\x0a\x09^ Compiler new\x0a\x09\x09codeGeneratorClass: self codeGeneratorClass;\x0a\x09\x09yourself",
  254. messageSends: ["codeGeneratorClass:", "new", "codeGeneratorClass", "yourself"],
  255. referencedClasses: ["Compiler"]
  256. }),
  257. smalltalk.CodeGeneratorTest);
  258. smalltalk.addMethod(
  259. smalltalk.method({
  260. selector: "setUp",
  261. category: 'initialization',
  262. fn: function (){
  263. var self=this;
  264. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  265. return smalltalk.withContext(function($ctx1) {
  266. self["@receiver"]=_st($DoIt())._new();
  267. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  268. args: [],
  269. source: "setUp\x0a\x09receiver := DoIt new",
  270. messageSends: ["new"],
  271. referencedClasses: ["DoIt"]
  272. }),
  273. smalltalk.CodeGeneratorTest);
  274. smalltalk.addMethod(
  275. smalltalk.method({
  276. selector: "should:receiver:return:",
  277. category: 'testing',
  278. fn: function (aString,anObject,aResult){
  279. var self=this;
  280. var method,result;
  281. return smalltalk.withContext(function($ctx1) {
  282. self["@receiver"]=anObject;
  283. method=_st(self._compiler())._install_forClass_category_(aString,_st(anObject)._class(),"tests");
  284. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  285. _st(_st(anObject)._class())._removeCompiledMethod_(method);
  286. self._assert_equals_(aResult,result);
  287. return self}, function($ctx1) {$ctx1.fill(self,"should:receiver:return:",{aString:aString,anObject:anObject,aResult:aResult,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  288. args: ["aString", "anObject", "aResult"],
  289. source: "should: aString receiver: anObject return: aResult\x0a\x09| method result |\x0a\x0a\x09receiver := anObject.\x0a\x09method := self compiler install: aString forClass: anObject class category: 'tests'.\x0a\x09result := receiver perform: method selector.\x0a\x09anObject class removeCompiledMethod: method.\x0a\x09self assert: aResult equals: result",
  290. messageSends: ["install:forClass:category:", "compiler", "class", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"],
  291. referencedClasses: []
  292. }),
  293. smalltalk.CodeGeneratorTest);
  294. smalltalk.addMethod(
  295. smalltalk.method({
  296. selector: "should:return:",
  297. category: 'testing',
  298. fn: function (aString,anObject){
  299. var self=this;
  300. return smalltalk.withContext(function($ctx1) {
  301. var $1;
  302. $1=self._should_receiver_return_(aString,self["@receiver"],anObject);
  303. return $1;
  304. }, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject},smalltalk.CodeGeneratorTest)})},
  305. args: ["aString", "anObject"],
  306. source: "should: aString return: anObject\x0a\x09^ self \x0a\x09\x09should: aString \x0a\x09\x09receiver: receiver \x0a\x09\x09return: anObject",
  307. messageSends: ["should:receiver:return:"],
  308. referencedClasses: []
  309. }),
  310. smalltalk.CodeGeneratorTest);
  311. smalltalk.addMethod(
  312. smalltalk.method({
  313. selector: "tearDown",
  314. category: 'initialization',
  315. fn: function (){
  316. var self=this;
  317. return smalltalk.withContext(function($ctx1) {
  318. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  319. args: [],
  320. source: "tearDown\x0a\x09\x22receiver := nil\x22",
  321. messageSends: [],
  322. referencedClasses: []
  323. }),
  324. smalltalk.CodeGeneratorTest);
  325. smalltalk.addMethod(
  326. smalltalk.method({
  327. selector: "testAssignment",
  328. category: 'tests',
  329. fn: function (){
  330. var self=this;
  331. return smalltalk.withContext(function($ctx1) {
  332. self._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  333. self._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  334. self._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  335. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  336. args: [],
  337. 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",
  338. messageSends: ["should:return:"],
  339. referencedClasses: []
  340. }),
  341. smalltalk.CodeGeneratorTest);
  342. smalltalk.addMethod(
  343. smalltalk.method({
  344. selector: "testBackslashSelectors",
  345. category: 'tests',
  346. fn: function (){
  347. var self=this;
  348. return smalltalk.withContext(function($ctx1) {
  349. self._should_return_("\x5c arg ^ 4",(4));
  350. self._should_return_("\x5c\x5c arg ^ 42",(42));
  351. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  352. args: [],
  353. source: "testBackslashSelectors\x0a\x09\x0a\x09self should: '\x5c arg ^ 4' return: 4.\x0a\x09self should: '\x5c\x5c arg ^ 42' return: 42",
  354. messageSends: ["should:return:"],
  355. referencedClasses: []
  356. }),
  357. smalltalk.CodeGeneratorTest);
  358. smalltalk.addMethod(
  359. smalltalk.method({
  360. selector: "testBlockReturn",
  361. category: 'tests',
  362. fn: function (){
  363. var self=this;
  364. return smalltalk.withContext(function($ctx1) {
  365. self._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  366. self._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  367. self._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  368. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  369. args: [],
  370. 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).",
  371. messageSends: ["should:return:"],
  372. referencedClasses: []
  373. }),
  374. smalltalk.CodeGeneratorTest);
  375. smalltalk.addMethod(
  376. smalltalk.method({
  377. selector: "testCascades",
  378. category: 'tests',
  379. fn: function (){
  380. var self=this;
  381. return smalltalk.withContext(function($ctx1) {
  382. self._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  383. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  384. args: [],
  385. source: "testCascades\x0a\x09\x0a\x09self should: 'foo ^ Array new add: 3; add: 4; yourself' return: #(3 4)",
  386. messageSends: ["should:return:"],
  387. referencedClasses: []
  388. }),
  389. smalltalk.CodeGeneratorTest);
  390. smalltalk.addMethod(
  391. smalltalk.method({
  392. selector: "testDynamicArrayElementsOrdered",
  393. category: 'tests',
  394. fn: function (){
  395. var self=this;
  396. return smalltalk.withContext(function($ctx1) {
  397. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  398. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  399. args: [],
  400. source: "testDynamicArrayElementsOrdered\x0a\x09self should: 'foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a' return: #(1 2).",
  401. messageSends: ["should:return:"],
  402. referencedClasses: []
  403. }),
  404. smalltalk.CodeGeneratorTest);
  405. smalltalk.addMethod(
  406. smalltalk.method({
  407. selector: "testDynamicDictionaryElementsOrdered",
  408. category: 'tests',
  409. fn: function (){
  410. var self=this;
  411. return smalltalk.withContext(function($ctx1) {
  412. 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))]));
  413. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  414. args: [],
  415. 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}.",
  416. messageSends: ["should:return:", "->"],
  417. referencedClasses: []
  418. }),
  419. smalltalk.CodeGeneratorTest);
  420. smalltalk.addMethod(
  421. smalltalk.method({
  422. selector: "testGlobalVar",
  423. category: 'tests',
  424. fn: function (){
  425. var self=this;
  426. function $BlockClosure(){return smalltalk.BlockClosure||(typeof BlockClosure=="undefined"?nil:BlockClosure)}
  427. return smalltalk.withContext(function($ctx1) {
  428. self._should_return_("foo ^ eval class",$BlockClosure());
  429. self._should_return_("foo ^ Math cos: 0",(1));
  430. self._should_return_("foo ^ NonExistingVar",nil);
  431. return self}, function($ctx1) {$ctx1.fill(self,"testGlobalVar",{},smalltalk.CodeGeneratorTest)})},
  432. args: [],
  433. source: "testGlobalVar\x0a\x09self should: 'foo ^ eval class' return: BlockClosure.\x0a\x09self should: 'foo ^ Math cos: 0' return: 1.\x0a\x09self should: 'foo ^ NonExistingVar' return: nil",
  434. messageSends: ["should:return:"],
  435. referencedClasses: ["BlockClosure"]
  436. }),
  437. smalltalk.CodeGeneratorTest);
  438. smalltalk.addMethod(
  439. smalltalk.method({
  440. selector: "testInnerTemporalDependentElementsOrdered",
  441. category: 'tests',
  442. fn: function (){
  443. var self=this;
  444. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  445. return smalltalk.withContext(function($ctx1) {
  446. 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))]);
  447. 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))]);
  448. 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))]);
  449. 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))]));
  450. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  451. args: [],
  452. 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}.",
  453. messageSends: ["should:return:", "->"],
  454. referencedClasses: ["Array"]
  455. }),
  456. smalltalk.CodeGeneratorTest);
  457. smalltalk.addMethod(
  458. smalltalk.method({
  459. selector: "testJSStatement",
  460. category: 'tests',
  461. fn: function (){
  462. var self=this;
  463. return smalltalk.withContext(function($ctx1) {
  464. self._should_return_("foo <return 2+3>",(5));
  465. return self}, function($ctx1) {$ctx1.fill(self,"testJSStatement",{},smalltalk.CodeGeneratorTest)})},
  466. args: [],
  467. source: "testJSStatement\x0a\x09self should: 'foo <return 2+3>' return: 5",
  468. messageSends: ["should:return:"],
  469. referencedClasses: []
  470. }),
  471. smalltalk.CodeGeneratorTest);
  472. smalltalk.addMethod(
  473. smalltalk.method({
  474. selector: "testLiterals",
  475. category: 'tests',
  476. fn: function (){
  477. var self=this;
  478. return smalltalk.withContext(function($ctx1) {
  479. self._should_return_("foo ^ 1",(1));
  480. self._should_return_("foo ^ 'hello'","hello");
  481. self._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  482. self._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  483. self._should_return_("foo ^ true",true);
  484. self._should_return_("foo ^ false",false);
  485. self._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._from_([(1).__minus_gt((2)),(3).__minus_gt((4))]));
  486. self._should_return_("foo ^ #hello","hello");
  487. self._should_return_("foo ^ -123.456",(-123.456));
  488. self._should_return_("foo ^ -2.5e4",(-25000));
  489. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  490. args: [],
  491. 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.\x0a\x09self should: 'foo ^ -2.5e4' return: -25000.",
  492. messageSends: ["should:return:", "->"],
  493. referencedClasses: []
  494. }),
  495. smalltalk.CodeGeneratorTest);
  496. smalltalk.addMethod(
  497. smalltalk.method({
  498. selector: "testLocalReturn",
  499. category: 'tests',
  500. fn: function (){
  501. var self=this;
  502. return smalltalk.withContext(function($ctx1) {
  503. self._should_return_("foo ^ 1",(1));
  504. self._should_return_("foo ^ 1 + 1",(2));
  505. self._should_return_("foo ",self["@receiver"]);
  506. self._should_return_("foo self asString",self["@receiver"]);
  507. self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  508. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  509. args: [],
  510. 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",
  511. messageSends: ["should:return:"],
  512. referencedClasses: []
  513. }),
  514. smalltalk.CodeGeneratorTest);
  515. smalltalk.addMethod(
  516. smalltalk.method({
  517. selector: "testMessageSends",
  518. category: 'tests',
  519. fn: function (){
  520. var self=this;
  521. return smalltalk.withContext(function($ctx1) {
  522. self._should_return_("foo ^ 1 asString","1");
  523. self._should_return_("foo ^ 1 + 1",(2));
  524. self._should_return_("foo ^ 1 + 2 * 3",(9));
  525. self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  526. self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  527. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  528. args: [],
  529. 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)",
  530. messageSends: ["should:return:"],
  531. referencedClasses: []
  532. }),
  533. smalltalk.CodeGeneratorTest);
  534. smalltalk.addMethod(
  535. smalltalk.method({
  536. selector: "testMultipleSequences",
  537. category: 'tests',
  538. fn: function (){
  539. var self=this;
  540. return smalltalk.withContext(function($ctx1) {
  541. self._should_return_("foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6",(30));
  542. return self}, function($ctx1) {$ctx1.fill(self,"testMultipleSequences",{},smalltalk.CodeGeneratorTest)})},
  543. args: [],
  544. source: "testMultipleSequences\x0a\x09self should: 'foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6' return: 30",
  545. messageSends: ["should:return:"],
  546. referencedClasses: []
  547. }),
  548. smalltalk.CodeGeneratorTest);
  549. smalltalk.addMethod(
  550. smalltalk.method({
  551. selector: "testMutableLiterals",
  552. category: 'tests',
  553. fn: function (){
  554. var self=this;
  555. return smalltalk.withContext(function($ctx1) {
  556. self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  557. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  558. args: [],
  559. 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)",
  560. messageSends: ["should:return:"],
  561. referencedClasses: []
  562. }),
  563. smalltalk.CodeGeneratorTest);
  564. smalltalk.addMethod(
  565. smalltalk.method({
  566. selector: "testNestedIfTrue",
  567. category: 'tests',
  568. fn: function (){
  569. var self=this;
  570. return smalltalk.withContext(function($ctx1) {
  571. self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  572. self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  573. self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  574. self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  575. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  576. args: [],
  577. 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.",
  578. messageSends: ["should:return:"],
  579. referencedClasses: []
  580. }),
  581. smalltalk.CodeGeneratorTest);
  582. smalltalk.addMethod(
  583. smalltalk.method({
  584. selector: "testNestedSends",
  585. category: 'tests',
  586. fn: function (){
  587. var self=this;
  588. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  589. return smalltalk.withContext(function($ctx1) {
  590. self._should_return_("foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString",_st(_st($Point())._x_y_((2).__at((3)),(4)))._asString());
  591. return self}, function($ctx1) {$ctx1.fill(self,"testNestedSends",{},smalltalk.CodeGeneratorTest)})},
  592. args: [],
  593. source: "testNestedSends\x0a\x09self should: 'foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString' return: (Point x: (2@3) y: 4) asString",
  594. messageSends: ["should:return:", "asString", "x:y:", "@"],
  595. referencedClasses: ["Point"]
  596. }),
  597. smalltalk.CodeGeneratorTest);
  598. smalltalk.addMethod(
  599. smalltalk.method({
  600. selector: "testNonLocalReturn",
  601. category: 'tests',
  602. fn: function (){
  603. var self=this;
  604. return smalltalk.withContext(function($ctx1) {
  605. self._should_return_("foo [ ^ 1 ] value",(1));
  606. self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  607. self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  608. self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  609. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  610. args: [],
  611. 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",
  612. messageSends: ["should:return:"],
  613. referencedClasses: []
  614. }),
  615. smalltalk.CodeGeneratorTest);
  616. smalltalk.addMethod(
  617. smalltalk.method({
  618. selector: "testPascalCaseGlobal",
  619. category: 'tests',
  620. fn: function (){
  621. var self=this;
  622. return smalltalk.withContext(function($ctx1) {
  623. self._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  624. self._should_return_("foo ^NonExistent",nil);
  625. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  626. args: [],
  627. source: "testPascalCaseGlobal\x0a\x09self should: 'foo ^Object' return: (smalltalk at: 'Object').\x0a\x09self should: 'foo ^NonExistent' return: nil",
  628. messageSends: ["should:return:", "at:"],
  629. referencedClasses: []
  630. }),
  631. smalltalk.CodeGeneratorTest);
  632. smalltalk.addMethod(
  633. smalltalk.method({
  634. selector: "testSendReceiverAndArgumentsOrdered",
  635. category: 'tests',
  636. fn: function (){
  637. var self=this;
  638. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  639. return smalltalk.withContext(function($ctx1) {
  640. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  641. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  642. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  643. args: [],
  644. 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}.",
  645. messageSends: ["should:return:"],
  646. referencedClasses: ["Array"]
  647. }),
  648. smalltalk.CodeGeneratorTest);
  649. smalltalk.addMethod(
  650. smalltalk.method({
  651. selector: "testSuperSend",
  652. category: 'tests',
  653. fn: function (){
  654. var self=this;
  655. return smalltalk.withContext(function($ctx1) {
  656. self._should_receiver_return_("foo ^ super isBoolean",true,false);
  657. return self}, function($ctx1) {$ctx1.fill(self,"testSuperSend",{},smalltalk.CodeGeneratorTest)})},
  658. args: [],
  659. source: "testSuperSend\x0a\x09self \x0a\x09\x09should: 'foo ^ super isBoolean' \x0a\x09\x09receiver: true\x0a\x09\x09return: false",
  660. messageSends: ["should:receiver:return:"],
  661. referencedClasses: []
  662. }),
  663. smalltalk.CodeGeneratorTest);
  664. smalltalk.addMethod(
  665. smalltalk.method({
  666. selector: "testThisContext",
  667. category: 'tests',
  668. fn: function (){
  669. var self=this;
  670. return smalltalk.withContext(function($ctx1) {
  671. self._should_return_("foo ^ [ thisContext ] value outerContext == thisContext",true);
  672. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.CodeGeneratorTest)})},
  673. args: [],
  674. source: "testThisContext\x0a\x09self should: 'foo ^ [ thisContext ] value outerContext == thisContext' return: true",
  675. messageSends: ["should:return:"],
  676. referencedClasses: []
  677. }),
  678. smalltalk.CodeGeneratorTest);
  679. smalltalk.addMethod(
  680. smalltalk.method({
  681. selector: "testifFalse",
  682. category: 'tests',
  683. fn: function (){
  684. var self=this;
  685. return smalltalk.withContext(function($ctx1) {
  686. self._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  687. self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  688. self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  689. self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  690. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  691. args: [],
  692. 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.",
  693. messageSends: ["should:return:"],
  694. referencedClasses: []
  695. }),
  696. smalltalk.CodeGeneratorTest);
  697. smalltalk.addMethod(
  698. smalltalk.method({
  699. selector: "testifFalseIfTrue",
  700. category: 'tests',
  701. fn: function (){
  702. var self=this;
  703. return smalltalk.withContext(function($ctx1) {
  704. self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  705. self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  706. self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  707. self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  708. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  709. args: [],
  710. 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.",
  711. messageSends: ["should:return:"],
  712. referencedClasses: []
  713. }),
  714. smalltalk.CodeGeneratorTest);
  715. smalltalk.addMethod(
  716. smalltalk.method({
  717. selector: "testifNil",
  718. category: 'tests',
  719. fn: function (){
  720. var self=this;
  721. return smalltalk.withContext(function($ctx1) {
  722. self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  723. self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  724. self._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  725. self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  726. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  727. args: [],
  728. 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.",
  729. messageSends: ["should:return:"],
  730. referencedClasses: []
  731. }),
  732. smalltalk.CodeGeneratorTest);
  733. smalltalk.addMethod(
  734. smalltalk.method({
  735. selector: "testifNilIfNotNil",
  736. category: 'tests',
  737. fn: function (){
  738. var self=this;
  739. return smalltalk.withContext(function($ctx1) {
  740. self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  741. self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  742. self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  743. self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  744. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  745. args: [],
  746. 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.",
  747. messageSends: ["should:return:"],
  748. referencedClasses: []
  749. }),
  750. smalltalk.CodeGeneratorTest);
  751. smalltalk.addMethod(
  752. smalltalk.method({
  753. selector: "testifNotNil",
  754. category: 'tests',
  755. fn: function (){
  756. var self=this;
  757. return smalltalk.withContext(function($ctx1) {
  758. self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  759. self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  760. self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  761. self._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  762. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  763. args: [],
  764. 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.",
  765. messageSends: ["should:return:"],
  766. referencedClasses: []
  767. }),
  768. smalltalk.CodeGeneratorTest);
  769. smalltalk.addMethod(
  770. smalltalk.method({
  771. selector: "testifNotNilWithArgument",
  772. category: 'tests',
  773. fn: function (){
  774. var self=this;
  775. return smalltalk.withContext(function($ctx1) {
  776. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  777. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  778. self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  779. self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  780. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  781. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  782. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  783. args: [],
  784. 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",
  785. messageSends: ["should:return:"],
  786. referencedClasses: []
  787. }),
  788. smalltalk.CodeGeneratorTest);
  789. smalltalk.addMethod(
  790. smalltalk.method({
  791. selector: "testifTrue",
  792. category: 'tests',
  793. fn: function (){
  794. var self=this;
  795. return smalltalk.withContext(function($ctx1) {
  796. self._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  797. self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  798. self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  799. self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  800. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  801. args: [],
  802. 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.",
  803. messageSends: ["should:return:"],
  804. referencedClasses: []
  805. }),
  806. smalltalk.CodeGeneratorTest);
  807. smalltalk.addMethod(
  808. smalltalk.method({
  809. selector: "testifTrueIfFalse",
  810. category: 'tests',
  811. fn: function (){
  812. var self=this;
  813. return smalltalk.withContext(function($ctx1) {
  814. self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  815. self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  816. self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  817. self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  818. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  819. args: [],
  820. 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.",
  821. messageSends: ["should:return:"],
  822. referencedClasses: []
  823. }),
  824. smalltalk.CodeGeneratorTest);
  825. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  826. smalltalk.addMethod(
  827. smalltalk.method({
  828. selector: "codeGeneratorClass",
  829. category: 'accessing',
  830. fn: function (){
  831. var self=this;
  832. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  833. return smalltalk.withContext(function($ctx1) {
  834. var $1;
  835. $1=$InliningCodeGenerator();
  836. return $1;
  837. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  838. args: [],
  839. source: "codeGeneratorClass\x0a\x09^ InliningCodeGenerator",
  840. messageSends: [],
  841. referencedClasses: ["InliningCodeGenerator"]
  842. }),
  843. smalltalk.InliningCodeGeneratorTest);
  844. smalltalk.addClass('InterpreterTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  845. smalltalk.addMethod(
  846. smalltalk.method({
  847. selector: "analyze:forClass:",
  848. category: 'parsing',
  849. fn: function (aNode,aClass){
  850. var self=this;
  851. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  852. return smalltalk.withContext(function($ctx1) {
  853. var $1;
  854. _st(_st($SemanticAnalyzer())._on_(aClass))._visit_(aNode);
  855. $1=aNode;
  856. return $1;
  857. }, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},smalltalk.InterpreterTest)})},
  858. args: ["aNode", "aClass"],
  859. source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a\x09^ aNode",
  860. messageSends: ["visit:", "on:"],
  861. referencedClasses: ["SemanticAnalyzer"]
  862. }),
  863. smalltalk.InterpreterTest);
  864. smalltalk.addMethod(
  865. smalltalk.method({
  866. selector: "interpret:receiver:withArguments:",
  867. category: 'private',
  868. fn: function (aString,anObject,aDictionary){
  869. var self=this;
  870. var ctx,interpreter;
  871. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  872. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  873. return smalltalk.withContext(function($ctx1) {
  874. var $1,$2,$4,$5,$3;
  875. interpreter=_st($ASTInterpreter())._new();
  876. $1=_st($AIContext())._new();
  877. _st($1)._receiver_(anObject);
  878. _st($1)._interpreter_(interpreter);
  879. $2=_st($1)._yourself();
  880. ctx=$2;
  881. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  882. return smalltalk.withContext(function($ctx2) {
  883. return _st(ctx)._localAt_put_(key,value);
  884. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  885. $4=interpreter;
  886. _st($4)._context_(ctx);
  887. _st($4)._interpret_(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nextChild());
  888. _st($4)._proceed();
  889. $5=_st($4)._result();
  890. $3=$5;
  891. return $3;
  892. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx,interpreter:interpreter},smalltalk.InterpreterTest)})},
  893. args: ["aString", "anObject", "aDictionary"],
  894. 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 := ASTInterpreter new.\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",
  895. messageSends: ["new", "receiver:", "interpreter:", "yourself", "keysAndValuesDo:", "localAt:put:", "context:", "interpret:", "nextChild", "parse:forClass:", "class", "proceed", "result"],
  896. referencedClasses: ["ASTInterpreter", "AIContext"]
  897. }),
  898. smalltalk.InterpreterTest);
  899. smalltalk.addMethod(
  900. smalltalk.method({
  901. selector: "parse:",
  902. category: 'parsing',
  903. fn: function (aString){
  904. var self=this;
  905. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  906. return smalltalk.withContext(function($ctx1) {
  907. var $1;
  908. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  909. return $1;
  910. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.InterpreterTest)})},
  911. args: ["aString"],
  912. source: "parse: aString\x0a\x09^ Smalltalk current parse: aString",
  913. messageSends: ["parse:", "current"],
  914. referencedClasses: ["Smalltalk"]
  915. }),
  916. smalltalk.InterpreterTest);
  917. smalltalk.addMethod(
  918. smalltalk.method({
  919. selector: "parse:forClass:",
  920. category: 'parsing',
  921. fn: function (aString,aClass){
  922. var self=this;
  923. return smalltalk.withContext(function($ctx1) {
  924. var $1;
  925. $1=self._analyze_forClass_(self._parse_(aString),aClass);
  926. return $1;
  927. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.InterpreterTest)})},
  928. args: ["aString", "aClass"],
  929. source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
  930. messageSends: ["analyze:forClass:", "parse:"],
  931. referencedClasses: []
  932. }),
  933. smalltalk.InterpreterTest);
  934. smalltalk.addMethod(
  935. smalltalk.method({
  936. selector: "should:receiver:return:",
  937. category: 'testing',
  938. fn: function (aString,anObject,aResult){
  939. var self=this;
  940. return smalltalk.withContext(function($ctx1) {
  941. var $1;
  942. self["@receiver"]=anObject;
  943. $1=self._assert_equals_(self._interpret_receiver_withArguments_(aString,self["@receiver"],smalltalk.HashedCollection._from_([])),aResult);
  944. return $1;
  945. }, function($ctx1) {$ctx1.fill(self,"should:receiver:return:",{aString:aString,anObject:anObject,aResult:aResult},smalltalk.InterpreterTest)})},
  946. args: ["aString", "anObject", "aResult"],
  947. source: "should: aString receiver: anObject return: aResult\x0a\x09receiver := anObject.\x0a\x09\x0a\x09^ self \x0a\x09\x09assert: (self interpret: aString receiver: receiver withArguments: #{})\x0a\x09\x09equals: aResult",
  948. messageSends: ["assert:equals:", "interpret:receiver:withArguments:"],
  949. referencedClasses: []
  950. }),
  951. smalltalk.InterpreterTest);
  952. smalltalk.addMethod(
  953. smalltalk.method({
  954. selector: "should:return:",
  955. category: 'testing',
  956. fn: function (aString,anObject){
  957. var self=this;
  958. return smalltalk.withContext(function($ctx1) {
  959. var $1;
  960. $1=self._should_receiver_return_(aString,self["@receiver"],anObject);
  961. return $1;
  962. }, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject},smalltalk.InterpreterTest)})},
  963. args: ["aString", "anObject"],
  964. source: "should: aString return: anObject\x0a\x09^ self \x0a\x09\x09should: aString\x0a\x09\x09receiver: receiver\x0a\x09\x09return: anObject",
  965. messageSends: ["should:receiver:return:"],
  966. referencedClasses: []
  967. }),
  968. smalltalk.InterpreterTest);
  969. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  970. smalltalk.addMethod(
  971. smalltalk.method({
  972. selector: "testClassRefVar",
  973. category: 'tests',
  974. fn: function (){
  975. var self=this;
  976. var node;
  977. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  978. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  979. return smalltalk.withContext(function($ctx1) {
  980. var $1,$2;
  981. $1=_st($ClassReferenceNode())._new();
  982. _st($1)._value_("Object");
  983. $2=_st($1)._yourself();
  984. node=$2;
  985. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  986. self._assert_(_st(_st(node)._binding())._isClassRefVar());
  987. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  988. args: [],
  989. 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",
  990. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"],
  991. referencedClasses: ["ClassReferenceNode", "SemanticAnalyzer"]
  992. }),
  993. smalltalk.ScopeVarTest);
  994. smalltalk.addMethod(
  995. smalltalk.method({
  996. selector: "testInstanceVar",
  997. category: 'tests',
  998. fn: function (){
  999. var self=this;
  1000. var node,scope;
  1001. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1002. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1003. return smalltalk.withContext(function($ctx1) {
  1004. var $1,$2;
  1005. $1=_st($VariableNode())._new();
  1006. _st($1)._value_("bzzz");
  1007. $2=_st($1)._yourself();
  1008. node=$2;
  1009. scope=_st($MethodLexicalScope())._new();
  1010. _st(scope)._addIVar_("bzzz");
  1011. self._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  1012. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1013. args: [],
  1014. 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",
  1015. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"],
  1016. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1017. }),
  1018. smalltalk.ScopeVarTest);
  1019. smalltalk.addMethod(
  1020. smalltalk.method({
  1021. selector: "testPseudoVar",
  1022. category: 'tests',
  1023. fn: function (){
  1024. var self=this;
  1025. var node,pseudoVars;
  1026. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1027. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1028. return smalltalk.withContext(function($ctx1) {
  1029. var $1,$2;
  1030. pseudoVars=["self", "super", "true", "false", "nil"];
  1031. _st(pseudoVars)._do_((function(each){
  1032. return smalltalk.withContext(function($ctx2) {
  1033. $1=_st($VariableNode())._new();
  1034. _st($1)._value_(each);
  1035. $2=_st($1)._yourself();
  1036. node=$2;
  1037. node;
  1038. return self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  1039. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1040. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  1041. args: [],
  1042. 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 ]",
  1043. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"],
  1044. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1045. }),
  1046. smalltalk.ScopeVarTest);
  1047. smalltalk.addMethod(
  1048. smalltalk.method({
  1049. selector: "testTempVar",
  1050. category: 'tests',
  1051. fn: function (){
  1052. var self=this;
  1053. var node,scope;
  1054. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1055. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1056. return smalltalk.withContext(function($ctx1) {
  1057. var $1,$2;
  1058. $1=_st($VariableNode())._new();
  1059. _st($1)._value_("bzzz");
  1060. $2=_st($1)._yourself();
  1061. node=$2;
  1062. scope=_st($MethodLexicalScope())._new();
  1063. _st(scope)._addTemp_("bzzz");
  1064. self._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  1065. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1066. args: [],
  1067. 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",
  1068. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"],
  1069. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1070. }),
  1071. smalltalk.ScopeVarTest);
  1072. smalltalk.addMethod(
  1073. smalltalk.method({
  1074. selector: "testUnknownVar",
  1075. category: 'tests',
  1076. fn: function (){
  1077. var self=this;
  1078. var node;
  1079. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1080. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1081. return smalltalk.withContext(function($ctx1) {
  1082. var $1,$2;
  1083. $1=_st($VariableNode())._new();
  1084. _st($1)._value_("bzzz");
  1085. $2=_st($1)._yourself();
  1086. node=$2;
  1087. self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  1088. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  1089. args: [],
  1090. source: "testUnknownVar\x0a\x09| node |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09self assert: (MethodLexicalScope new bindingFor: node) isNil",
  1091. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"],
  1092. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1093. }),
  1094. smalltalk.ScopeVarTest);
  1095. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  1096. smalltalk.addMethod(
  1097. smalltalk.method({
  1098. selector: "setUp",
  1099. category: 'running',
  1100. fn: function (){
  1101. var self=this;
  1102. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1103. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1104. return smalltalk.withContext(function($ctx1) {
  1105. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  1106. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  1107. args: [],
  1108. source: "setUp\x0a\x09analyzer := SemanticAnalyzer on: Object",
  1109. messageSends: ["on:"],
  1110. referencedClasses: ["SemanticAnalyzer", "Object"]
  1111. }),
  1112. smalltalk.SemanticAnalyzerTest);
  1113. smalltalk.addMethod(
  1114. smalltalk.method({
  1115. selector: "testAssignment",
  1116. category: 'tests',
  1117. fn: function (){
  1118. var self=this;
  1119. var src,ast;
  1120. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  1121. return smalltalk.withContext(function($ctx1) {
  1122. src="foo self := 1";
  1123. ast=_st(smalltalk)._parse_(src);
  1124. self._should_raise_((function(){
  1125. return smalltalk.withContext(function($ctx2) {
  1126. return _st(self["@analyzer"])._visit_(ast);
  1127. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$InvalidAssignmentError());
  1128. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1129. args: [],
  1130. 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",
  1131. messageSends: ["parse:", "should:raise:", "visit:"],
  1132. referencedClasses: ["InvalidAssignmentError"]
  1133. }),
  1134. smalltalk.SemanticAnalyzerTest);
  1135. smalltalk.addMethod(
  1136. smalltalk.method({
  1137. selector: "testNonLocalReturn",
  1138. category: 'tests',
  1139. fn: function (){
  1140. var self=this;
  1141. var src,ast;
  1142. return smalltalk.withContext(function($ctx1) {
  1143. src="foo | a | a + 1. ^ a";
  1144. ast=_st(smalltalk)._parse_(src);
  1145. _st(self["@analyzer"])._visit_(ast);
  1146. self._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1147. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1148. args: [],
  1149. 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",
  1150. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"],
  1151. referencedClasses: []
  1152. }),
  1153. smalltalk.SemanticAnalyzerTest);
  1154. smalltalk.addMethod(
  1155. smalltalk.method({
  1156. selector: "testNonLocalReturn2",
  1157. category: 'tests',
  1158. fn: function (){
  1159. var self=this;
  1160. var src,ast;
  1161. return smalltalk.withContext(function($ctx1) {
  1162. src="foo | a | a + 1. [ [ ^ a] ]";
  1163. ast=_st(smalltalk)._parse_(src);
  1164. _st(self["@analyzer"])._visit_(ast);
  1165. self._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1166. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1167. args: [],
  1168. 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",
  1169. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"],
  1170. referencedClasses: []
  1171. }),
  1172. smalltalk.SemanticAnalyzerTest);
  1173. smalltalk.addMethod(
  1174. smalltalk.method({
  1175. selector: "testScope",
  1176. category: 'tests',
  1177. fn: function (){
  1178. var self=this;
  1179. var src,ast;
  1180. return smalltalk.withContext(function($ctx1) {
  1181. src="foo | a | a + 1. [ | b | b := a ]";
  1182. ast=_st(smalltalk)._parse_(src);
  1183. _st(self["@analyzer"])._visit_(ast);
  1184. self._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  1185. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1186. args: [],
  1187. 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.",
  1188. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"],
  1189. referencedClasses: []
  1190. }),
  1191. smalltalk.SemanticAnalyzerTest);
  1192. smalltalk.addMethod(
  1193. smalltalk.method({
  1194. selector: "testScope2",
  1195. category: 'tests',
  1196. fn: function (){
  1197. var self=this;
  1198. var src,ast;
  1199. return smalltalk.withContext(function($ctx1) {
  1200. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1201. ast=_st(smalltalk)._parse_(src);
  1202. _st(self["@analyzer"])._visit_(ast);
  1203. 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()));
  1204. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1205. args: [],
  1206. 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.",
  1207. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"],
  1208. referencedClasses: []
  1209. }),
  1210. smalltalk.SemanticAnalyzerTest);
  1211. smalltalk.addMethod(
  1212. smalltalk.method({
  1213. selector: "testScopeLevel",
  1214. category: 'tests',
  1215. fn: function (){
  1216. var self=this;
  1217. var src,ast;
  1218. return smalltalk.withContext(function($ctx1) {
  1219. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1220. ast=_st(smalltalk)._parse_(src);
  1221. _st(self["@analyzer"])._visit_(ast);
  1222. self._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  1223. 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));
  1224. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1225. args: [],
  1226. 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",
  1227. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"],
  1228. referencedClasses: []
  1229. }),
  1230. smalltalk.SemanticAnalyzerTest);
  1231. smalltalk.addMethod(
  1232. smalltalk.method({
  1233. selector: "testUnknownVariables",
  1234. category: 'tests',
  1235. fn: function (){
  1236. var self=this;
  1237. var src,ast;
  1238. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1239. return smalltalk.withContext(function($ctx1) {
  1240. src="foo | a | b + a";
  1241. ast=_st(smalltalk)._parse_(src);
  1242. self._should_raise_((function(){
  1243. return smalltalk.withContext(function($ctx2) {
  1244. return _st(self["@analyzer"])._visit_(ast);
  1245. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1246. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1247. args: [],
  1248. 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",
  1249. messageSends: ["parse:", "should:raise:", "visit:"],
  1250. referencedClasses: ["UnknownVariableError"]
  1251. }),
  1252. smalltalk.SemanticAnalyzerTest);
  1253. smalltalk.addMethod(
  1254. smalltalk.method({
  1255. selector: "testUnknownVariablesWithScope",
  1256. category: 'tests',
  1257. fn: function (){
  1258. var self=this;
  1259. var src,ast;
  1260. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1261. return smalltalk.withContext(function($ctx1) {
  1262. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  1263. ast=_st(smalltalk)._parse_(src);
  1264. self._should_raise_((function(){
  1265. return smalltalk.withContext(function($ctx2) {
  1266. return _st(self["@analyzer"])._visit_(ast);
  1267. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1268. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1269. args: [],
  1270. 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",
  1271. messageSends: ["parse:", "should:raise:", "visit:"],
  1272. referencedClasses: ["UnknownVariableError"]
  1273. }),
  1274. smalltalk.SemanticAnalyzerTest);
  1275. smalltalk.addMethod(
  1276. smalltalk.method({
  1277. selector: "testVariableShadowing",
  1278. category: 'tests',
  1279. fn: function (){
  1280. var self=this;
  1281. var src,ast;
  1282. return smalltalk.withContext(function($ctx1) {
  1283. src="foo | a | a + 1";
  1284. ast=_st(smalltalk)._parse_(src);
  1285. _st(self["@analyzer"])._visit_(ast);
  1286. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1287. args: [],
  1288. source: "testVariableShadowing\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1289. messageSends: ["parse:", "visit:"],
  1290. referencedClasses: []
  1291. }),
  1292. smalltalk.SemanticAnalyzerTest);
  1293. smalltalk.addMethod(
  1294. smalltalk.method({
  1295. selector: "testVariableShadowing2",
  1296. category: 'tests',
  1297. fn: function (){
  1298. var self=this;
  1299. var src,ast;
  1300. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1301. return smalltalk.withContext(function($ctx1) {
  1302. src="foo | a | a + 1. [ | a | a := 2 ]";
  1303. ast=_st(smalltalk)._parse_(src);
  1304. self._should_raise_((function(){
  1305. return smalltalk.withContext(function($ctx2) {
  1306. return _st(self["@analyzer"])._visit_(ast);
  1307. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1308. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1309. args: [],
  1310. 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",
  1311. messageSends: ["parse:", "should:raise:", "visit:"],
  1312. referencedClasses: ["ShadowingVariableError"]
  1313. }),
  1314. smalltalk.SemanticAnalyzerTest);
  1315. smalltalk.addMethod(
  1316. smalltalk.method({
  1317. selector: "testVariableShadowing3",
  1318. category: 'tests',
  1319. fn: function (){
  1320. var self=this;
  1321. var src,ast;
  1322. return smalltalk.withContext(function($ctx1) {
  1323. src="foo | a | a + 1. [ | b | b := 2 ]";
  1324. ast=_st(smalltalk)._parse_(src);
  1325. _st(self["@analyzer"])._visit_(ast);
  1326. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1327. args: [],
  1328. source: "testVariableShadowing3\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | b | b := 2 ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1329. messageSends: ["parse:", "visit:"],
  1330. referencedClasses: []
  1331. }),
  1332. smalltalk.SemanticAnalyzerTest);
  1333. smalltalk.addMethod(
  1334. smalltalk.method({
  1335. selector: "testVariableShadowing4",
  1336. category: 'tests',
  1337. fn: function (){
  1338. var self=this;
  1339. var src,ast;
  1340. return smalltalk.withContext(function($ctx1) {
  1341. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1342. ast=_st(smalltalk)._parse_(src);
  1343. _st(self["@analyzer"])._visit_(ast);
  1344. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1345. args: [],
  1346. source: "testVariableShadowing4\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1347. messageSends: ["parse:", "visit:"],
  1348. referencedClasses: []
  1349. }),
  1350. smalltalk.SemanticAnalyzerTest);
  1351. smalltalk.addMethod(
  1352. smalltalk.method({
  1353. selector: "testVariableShadowing5",
  1354. category: 'tests',
  1355. fn: function (){
  1356. var self=this;
  1357. var src,ast;
  1358. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1359. return smalltalk.withContext(function($ctx1) {
  1360. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1361. ast=_st(smalltalk)._parse_(src);
  1362. self._should_raise_((function(){
  1363. return smalltalk.withContext(function($ctx2) {
  1364. return _st(self["@analyzer"])._visit_(ast);
  1365. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1366. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1367. args: [],
  1368. 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",
  1369. messageSends: ["parse:", "should:raise:", "visit:"],
  1370. referencedClasses: ["ShadowingVariableError"]
  1371. }),
  1372. smalltalk.SemanticAnalyzerTest);
  1373. smalltalk.addMethod(
  1374. smalltalk.method({
  1375. selector: "testVariablesLookup",
  1376. category: 'tests',
  1377. fn: function (){
  1378. var self=this;
  1379. var src,ast;
  1380. return smalltalk.withContext(function($ctx1) {
  1381. src="foo | a | a + 1. [ | b | b := a ]";
  1382. ast=_st(smalltalk)._parse_(src);
  1383. _st(self["@analyzer"])._visit_(ast);
  1384. self._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1385. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1386. 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());
  1387. 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()));
  1388. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1389. args: [],
  1390. 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.",
  1391. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"],
  1392. referencedClasses: []
  1393. }),
  1394. smalltalk.SemanticAnalyzerTest);
  1395. });