Compiler-Tests.js 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480
  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. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  489. args: [],
  490. 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",
  491. messageSends: ["should:return:", "->"],
  492. referencedClasses: []
  493. }),
  494. smalltalk.CodeGeneratorTest);
  495. smalltalk.addMethod(
  496. smalltalk.method({
  497. selector: "testLocalReturn",
  498. category: 'tests',
  499. fn: function (){
  500. var self=this;
  501. return smalltalk.withContext(function($ctx1) {
  502. self._should_return_("foo ^ 1",(1));
  503. self._should_return_("foo ^ 1 + 1",(2));
  504. self._should_return_("foo ",self["@receiver"]);
  505. self._should_return_("foo self asString",self["@receiver"]);
  506. self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  507. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  508. args: [],
  509. 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",
  510. messageSends: ["should:return:"],
  511. referencedClasses: []
  512. }),
  513. smalltalk.CodeGeneratorTest);
  514. smalltalk.addMethod(
  515. smalltalk.method({
  516. selector: "testMessageSends",
  517. category: 'tests',
  518. fn: function (){
  519. var self=this;
  520. return smalltalk.withContext(function($ctx1) {
  521. self._should_return_("foo ^ 1 asString","1");
  522. self._should_return_("foo ^ 1 + 1",(2));
  523. self._should_return_("foo ^ 1 + 2 * 3",(9));
  524. self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  525. self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  526. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  527. args: [],
  528. 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)",
  529. messageSends: ["should:return:"],
  530. referencedClasses: []
  531. }),
  532. smalltalk.CodeGeneratorTest);
  533. smalltalk.addMethod(
  534. smalltalk.method({
  535. selector: "testMultipleSequences",
  536. category: 'tests',
  537. fn: function (){
  538. var self=this;
  539. return smalltalk.withContext(function($ctx1) {
  540. self._should_return_("foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6",(30));
  541. return self}, function($ctx1) {$ctx1.fill(self,"testMultipleSequences",{},smalltalk.CodeGeneratorTest)})},
  542. args: [],
  543. source: "testMultipleSequences\x0a\x09self should: 'foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6' return: 30",
  544. messageSends: ["should:return:"],
  545. referencedClasses: []
  546. }),
  547. smalltalk.CodeGeneratorTest);
  548. smalltalk.addMethod(
  549. smalltalk.method({
  550. selector: "testMutableLiterals",
  551. category: 'tests',
  552. fn: function (){
  553. var self=this;
  554. return smalltalk.withContext(function($ctx1) {
  555. self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  556. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  557. args: [],
  558. 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)",
  559. messageSends: ["should:return:"],
  560. referencedClasses: []
  561. }),
  562. smalltalk.CodeGeneratorTest);
  563. smalltalk.addMethod(
  564. smalltalk.method({
  565. selector: "testNestedIfTrue",
  566. category: 'tests',
  567. fn: function (){
  568. var self=this;
  569. return smalltalk.withContext(function($ctx1) {
  570. self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  571. self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  572. self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  573. self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  574. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  575. args: [],
  576. 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.",
  577. messageSends: ["should:return:"],
  578. referencedClasses: []
  579. }),
  580. smalltalk.CodeGeneratorTest);
  581. smalltalk.addMethod(
  582. smalltalk.method({
  583. selector: "testNestedSends",
  584. category: 'tests',
  585. fn: function (){
  586. var self=this;
  587. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  588. return smalltalk.withContext(function($ctx1) {
  589. self._should_return_("foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString",_st(_st($Point())._x_y_((2).__at((3)),(4)))._asString());
  590. return self}, function($ctx1) {$ctx1.fill(self,"testNestedSends",{},smalltalk.CodeGeneratorTest)})},
  591. args: [],
  592. source: "testNestedSends\x0a\x09self should: 'foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString' return: (Point x: (2@3) y: 4) asString",
  593. messageSends: ["should:return:", "asString", "x:y:", "@"],
  594. referencedClasses: ["Point"]
  595. }),
  596. smalltalk.CodeGeneratorTest);
  597. smalltalk.addMethod(
  598. smalltalk.method({
  599. selector: "testNonLocalReturn",
  600. category: 'tests',
  601. fn: function (){
  602. var self=this;
  603. return smalltalk.withContext(function($ctx1) {
  604. self._should_return_("foo [ ^ 1 ] value",(1));
  605. self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  606. self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  607. self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  608. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  609. args: [],
  610. 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",
  611. messageSends: ["should:return:"],
  612. referencedClasses: []
  613. }),
  614. smalltalk.CodeGeneratorTest);
  615. smalltalk.addMethod(
  616. smalltalk.method({
  617. selector: "testPascalCaseGlobal",
  618. category: 'tests',
  619. fn: function (){
  620. var self=this;
  621. return smalltalk.withContext(function($ctx1) {
  622. self._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  623. self._should_return_("foo ^NonExistent",nil);
  624. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  625. args: [],
  626. source: "testPascalCaseGlobal\x0a\x09self should: 'foo ^Object' return: (smalltalk at: 'Object').\x0a\x09self should: 'foo ^NonExistent' return: nil",
  627. messageSends: ["should:return:", "at:"],
  628. referencedClasses: []
  629. }),
  630. smalltalk.CodeGeneratorTest);
  631. smalltalk.addMethod(
  632. smalltalk.method({
  633. selector: "testSendReceiverAndArgumentsOrdered",
  634. category: 'tests',
  635. fn: function (){
  636. var self=this;
  637. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  638. return smalltalk.withContext(function($ctx1) {
  639. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  640. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  641. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  642. args: [],
  643. 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}.",
  644. messageSends: ["should:return:"],
  645. referencedClasses: ["Array"]
  646. }),
  647. smalltalk.CodeGeneratorTest);
  648. smalltalk.addMethod(
  649. smalltalk.method({
  650. selector: "testSuperSend",
  651. category: 'tests',
  652. fn: function (){
  653. var self=this;
  654. return smalltalk.withContext(function($ctx1) {
  655. self._should_receiver_return_("foo ^ super isBoolean",true,false);
  656. return self}, function($ctx1) {$ctx1.fill(self,"testSuperSend",{},smalltalk.CodeGeneratorTest)})},
  657. args: [],
  658. source: "testSuperSend\x0a\x09self \x0a\x09\x09should: 'foo ^ super isBoolean' \x0a\x09\x09receiver: true\x0a\x09\x09return: false",
  659. messageSends: ["should:receiver:return:"],
  660. referencedClasses: []
  661. }),
  662. smalltalk.CodeGeneratorTest);
  663. smalltalk.addMethod(
  664. smalltalk.method({
  665. selector: "testThisContext",
  666. category: 'tests',
  667. fn: function (){
  668. var self=this;
  669. return smalltalk.withContext(function($ctx1) {
  670. self._should_return_("foo ^ [ thisContext ] value outerContext == thisContext",true);
  671. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.CodeGeneratorTest)})},
  672. args: [],
  673. source: "testThisContext\x0a\x09self should: 'foo ^ [ thisContext ] value outerContext == thisContext' return: true",
  674. messageSends: ["should:return:"],
  675. referencedClasses: []
  676. }),
  677. smalltalk.CodeGeneratorTest);
  678. smalltalk.addMethod(
  679. smalltalk.method({
  680. selector: "testifFalse",
  681. category: 'tests',
  682. fn: function (){
  683. var self=this;
  684. return smalltalk.withContext(function($ctx1) {
  685. self._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  686. self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  687. self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  688. self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  689. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  690. args: [],
  691. 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.",
  692. messageSends: ["should:return:"],
  693. referencedClasses: []
  694. }),
  695. smalltalk.CodeGeneratorTest);
  696. smalltalk.addMethod(
  697. smalltalk.method({
  698. selector: "testifFalseIfTrue",
  699. category: 'tests',
  700. fn: function (){
  701. var self=this;
  702. return smalltalk.withContext(function($ctx1) {
  703. self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  704. self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  705. self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  706. self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  707. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  708. args: [],
  709. 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.",
  710. messageSends: ["should:return:"],
  711. referencedClasses: []
  712. }),
  713. smalltalk.CodeGeneratorTest);
  714. smalltalk.addMethod(
  715. smalltalk.method({
  716. selector: "testifNil",
  717. category: 'tests',
  718. fn: function (){
  719. var self=this;
  720. return smalltalk.withContext(function($ctx1) {
  721. self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  722. self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  723. self._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  724. self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  725. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  726. args: [],
  727. 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.",
  728. messageSends: ["should:return:"],
  729. referencedClasses: []
  730. }),
  731. smalltalk.CodeGeneratorTest);
  732. smalltalk.addMethod(
  733. smalltalk.method({
  734. selector: "testifNilIfNotNil",
  735. category: 'tests',
  736. fn: function (){
  737. var self=this;
  738. return smalltalk.withContext(function($ctx1) {
  739. self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  740. self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  741. self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  742. self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  743. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  744. args: [],
  745. 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.",
  746. messageSends: ["should:return:"],
  747. referencedClasses: []
  748. }),
  749. smalltalk.CodeGeneratorTest);
  750. smalltalk.addMethod(
  751. smalltalk.method({
  752. selector: "testifNotNil",
  753. category: 'tests',
  754. fn: function (){
  755. var self=this;
  756. return smalltalk.withContext(function($ctx1) {
  757. self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  758. self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  759. self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  760. self._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  761. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  762. args: [],
  763. 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.",
  764. messageSends: ["should:return:"],
  765. referencedClasses: []
  766. }),
  767. smalltalk.CodeGeneratorTest);
  768. smalltalk.addMethod(
  769. smalltalk.method({
  770. selector: "testifNotNilWithArgument",
  771. category: 'tests',
  772. fn: function (){
  773. var self=this;
  774. return smalltalk.withContext(function($ctx1) {
  775. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  776. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  777. self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  778. self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  779. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  780. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  781. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  782. args: [],
  783. 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",
  784. messageSends: ["should:return:"],
  785. referencedClasses: []
  786. }),
  787. smalltalk.CodeGeneratorTest);
  788. smalltalk.addMethod(
  789. smalltalk.method({
  790. selector: "testifTrue",
  791. category: 'tests',
  792. fn: function (){
  793. var self=this;
  794. return smalltalk.withContext(function($ctx1) {
  795. self._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  796. self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  797. self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  798. self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  799. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  800. args: [],
  801. 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.",
  802. messageSends: ["should:return:"],
  803. referencedClasses: []
  804. }),
  805. smalltalk.CodeGeneratorTest);
  806. smalltalk.addMethod(
  807. smalltalk.method({
  808. selector: "testifTrueIfFalse",
  809. category: 'tests',
  810. fn: function (){
  811. var self=this;
  812. return smalltalk.withContext(function($ctx1) {
  813. self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  814. self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  815. self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  816. self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  817. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  818. args: [],
  819. 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.",
  820. messageSends: ["should:return:"],
  821. referencedClasses: []
  822. }),
  823. smalltalk.CodeGeneratorTest);
  824. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  825. smalltalk.addMethod(
  826. smalltalk.method({
  827. selector: "codeGeneratorClass",
  828. category: 'accessing',
  829. fn: function (){
  830. var self=this;
  831. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  832. return smalltalk.withContext(function($ctx1) {
  833. var $1;
  834. $1=$InliningCodeGenerator();
  835. return $1;
  836. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  837. args: [],
  838. source: "codeGeneratorClass\x0a\x09^ InliningCodeGenerator",
  839. messageSends: [],
  840. referencedClasses: ["InliningCodeGenerator"]
  841. }),
  842. smalltalk.InliningCodeGeneratorTest);
  843. smalltalk.addClass('InterpreterTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  844. smalltalk.addMethod(
  845. smalltalk.method({
  846. selector: "analyze:forClass:",
  847. category: 'parsing',
  848. fn: function (aNode,aClass){
  849. var self=this;
  850. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  851. return smalltalk.withContext(function($ctx1) {
  852. var $1;
  853. _st(_st($SemanticAnalyzer())._on_(aClass))._visit_(aNode);
  854. $1=aNode;
  855. return $1;
  856. }, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},smalltalk.InterpreterTest)})},
  857. args: ["aNode", "aClass"],
  858. source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a\x09^ aNode",
  859. messageSends: ["visit:", "on:"],
  860. referencedClasses: ["SemanticAnalyzer"]
  861. }),
  862. smalltalk.InterpreterTest);
  863. smalltalk.addMethod(
  864. smalltalk.method({
  865. selector: "interpret:receiver:withArguments:",
  866. category: 'private',
  867. fn: function (aString,anObject,aDictionary){
  868. var self=this;
  869. var ctx,interpreter;
  870. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  871. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  872. return smalltalk.withContext(function($ctx1) {
  873. var $1,$2,$4,$5,$3;
  874. interpreter=_st($ASTInterpreter())._new();
  875. $1=_st($AIContext())._new();
  876. _st($1)._receiver_(anObject);
  877. _st($1)._interpreter_(interpreter);
  878. $2=_st($1)._yourself();
  879. ctx=$2;
  880. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  881. return smalltalk.withContext(function($ctx2) {
  882. return _st(ctx)._localAt_put_(key,value);
  883. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  884. $4=interpreter;
  885. _st($4)._context_(ctx);
  886. _st($4)._interpret_(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nextChild());
  887. _st($4)._proceed();
  888. $5=_st($4)._result();
  889. $3=$5;
  890. return $3;
  891. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx,interpreter:interpreter},smalltalk.InterpreterTest)})},
  892. args: ["aString", "anObject", "aDictionary"],
  893. 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",
  894. messageSends: ["new", "receiver:", "interpreter:", "yourself", "keysAndValuesDo:", "localAt:put:", "context:", "interpret:", "nextChild", "parse:forClass:", "class", "proceed", "result"],
  895. referencedClasses: ["ASTInterpreter", "AIContext"]
  896. }),
  897. smalltalk.InterpreterTest);
  898. smalltalk.addMethod(
  899. smalltalk.method({
  900. selector: "parse:",
  901. category: 'parsing',
  902. fn: function (aString){
  903. var self=this;
  904. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  905. return smalltalk.withContext(function($ctx1) {
  906. var $1;
  907. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  908. return $1;
  909. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.InterpreterTest)})},
  910. args: ["aString"],
  911. source: "parse: aString\x0a\x09^ Smalltalk current parse: aString",
  912. messageSends: ["parse:", "current"],
  913. referencedClasses: ["Smalltalk"]
  914. }),
  915. smalltalk.InterpreterTest);
  916. smalltalk.addMethod(
  917. smalltalk.method({
  918. selector: "parse:forClass:",
  919. category: 'parsing',
  920. fn: function (aString,aClass){
  921. var self=this;
  922. return smalltalk.withContext(function($ctx1) {
  923. var $1;
  924. $1=self._analyze_forClass_(self._parse_(aString),aClass);
  925. return $1;
  926. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.InterpreterTest)})},
  927. args: ["aString", "aClass"],
  928. source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
  929. messageSends: ["analyze:forClass:", "parse:"],
  930. referencedClasses: []
  931. }),
  932. smalltalk.InterpreterTest);
  933. smalltalk.addMethod(
  934. smalltalk.method({
  935. selector: "should:receiver:return:",
  936. category: 'testing',
  937. fn: function (aString,anObject,aResult){
  938. var self=this;
  939. return smalltalk.withContext(function($ctx1) {
  940. var $1;
  941. self["@receiver"]=anObject;
  942. $1=self._assert_equals_(self._interpret_receiver_withArguments_(aString,self["@receiver"],smalltalk.HashedCollection._from_([])),aResult);
  943. return $1;
  944. }, function($ctx1) {$ctx1.fill(self,"should:receiver:return:",{aString:aString,anObject:anObject,aResult:aResult},smalltalk.InterpreterTest)})},
  945. args: ["aString", "anObject", "aResult"],
  946. 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",
  947. messageSends: ["assert:equals:", "interpret:receiver:withArguments:"],
  948. referencedClasses: []
  949. }),
  950. smalltalk.InterpreterTest);
  951. smalltalk.addMethod(
  952. smalltalk.method({
  953. selector: "should:return:",
  954. category: 'testing',
  955. fn: function (aString,anObject){
  956. var self=this;
  957. return smalltalk.withContext(function($ctx1) {
  958. var $1;
  959. $1=self._should_receiver_return_(aString,self["@receiver"],anObject);
  960. return $1;
  961. }, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject},smalltalk.InterpreterTest)})},
  962. args: ["aString", "anObject"],
  963. source: "should: aString return: anObject\x0a\x09^ self \x0a\x09\x09should: aString\x0a\x09\x09receiver: receiver\x0a\x09\x09return: anObject",
  964. messageSends: ["should:receiver:return:"],
  965. referencedClasses: []
  966. }),
  967. smalltalk.InterpreterTest);
  968. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  969. smalltalk.addMethod(
  970. smalltalk.method({
  971. selector: "testClassRefVar",
  972. category: 'tests',
  973. fn: function (){
  974. var self=this;
  975. var node;
  976. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  977. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  978. return smalltalk.withContext(function($ctx1) {
  979. var $1,$2;
  980. $1=_st($ClassReferenceNode())._new();
  981. _st($1)._value_("Object");
  982. $2=_st($1)._yourself();
  983. node=$2;
  984. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  985. self._assert_(_st(_st(node)._binding())._isClassRefVar());
  986. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  987. args: [],
  988. 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",
  989. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"],
  990. referencedClasses: ["ClassReferenceNode", "SemanticAnalyzer"]
  991. }),
  992. smalltalk.ScopeVarTest);
  993. smalltalk.addMethod(
  994. smalltalk.method({
  995. selector: "testInstanceVar",
  996. category: 'tests',
  997. fn: function (){
  998. var self=this;
  999. var node,scope;
  1000. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1001. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1002. return smalltalk.withContext(function($ctx1) {
  1003. var $1,$2;
  1004. $1=_st($VariableNode())._new();
  1005. _st($1)._value_("bzzz");
  1006. $2=_st($1)._yourself();
  1007. node=$2;
  1008. scope=_st($MethodLexicalScope())._new();
  1009. _st(scope)._addIVar_("bzzz");
  1010. self._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  1011. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1012. args: [],
  1013. 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",
  1014. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"],
  1015. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1016. }),
  1017. smalltalk.ScopeVarTest);
  1018. smalltalk.addMethod(
  1019. smalltalk.method({
  1020. selector: "testPseudoVar",
  1021. category: 'tests',
  1022. fn: function (){
  1023. var self=this;
  1024. var node,pseudoVars;
  1025. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1026. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1027. return smalltalk.withContext(function($ctx1) {
  1028. var $1,$2;
  1029. pseudoVars=["self", "super", "true", "false", "nil"];
  1030. _st(pseudoVars)._do_((function(each){
  1031. return smalltalk.withContext(function($ctx2) {
  1032. $1=_st($VariableNode())._new();
  1033. _st($1)._value_(each);
  1034. $2=_st($1)._yourself();
  1035. node=$2;
  1036. node;
  1037. return self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  1038. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1039. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  1040. args: [],
  1041. 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 ]",
  1042. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"],
  1043. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1044. }),
  1045. smalltalk.ScopeVarTest);
  1046. smalltalk.addMethod(
  1047. smalltalk.method({
  1048. selector: "testTempVar",
  1049. category: 'tests',
  1050. fn: function (){
  1051. var self=this;
  1052. var node,scope;
  1053. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1054. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1055. return smalltalk.withContext(function($ctx1) {
  1056. var $1,$2;
  1057. $1=_st($VariableNode())._new();
  1058. _st($1)._value_("bzzz");
  1059. $2=_st($1)._yourself();
  1060. node=$2;
  1061. scope=_st($MethodLexicalScope())._new();
  1062. _st(scope)._addTemp_("bzzz");
  1063. self._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  1064. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1065. args: [],
  1066. 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",
  1067. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"],
  1068. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1069. }),
  1070. smalltalk.ScopeVarTest);
  1071. smalltalk.addMethod(
  1072. smalltalk.method({
  1073. selector: "testUnknownVar",
  1074. category: 'tests',
  1075. fn: function (){
  1076. var self=this;
  1077. var node;
  1078. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1079. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1080. return smalltalk.withContext(function($ctx1) {
  1081. var $1,$2;
  1082. $1=_st($VariableNode())._new();
  1083. _st($1)._value_("bzzz");
  1084. $2=_st($1)._yourself();
  1085. node=$2;
  1086. self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  1087. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  1088. args: [],
  1089. source: "testUnknownVar\x0a\x09| node |\x0a\x09node := VariableNode new\x0a\x09\x09value: 'bzzz';\x0a\x09\x09yourself.\x0a\x09self assert: (MethodLexicalScope new bindingFor: node) isNil",
  1090. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"],
  1091. referencedClasses: ["VariableNode", "MethodLexicalScope"]
  1092. }),
  1093. smalltalk.ScopeVarTest);
  1094. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  1095. smalltalk.addMethod(
  1096. smalltalk.method({
  1097. selector: "setUp",
  1098. category: 'running',
  1099. fn: function (){
  1100. var self=this;
  1101. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1102. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1103. return smalltalk.withContext(function($ctx1) {
  1104. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  1105. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  1106. args: [],
  1107. source: "setUp\x0a\x09analyzer := SemanticAnalyzer on: Object",
  1108. messageSends: ["on:"],
  1109. referencedClasses: ["SemanticAnalyzer", "Object"]
  1110. }),
  1111. smalltalk.SemanticAnalyzerTest);
  1112. smalltalk.addMethod(
  1113. smalltalk.method({
  1114. selector: "testAssignment",
  1115. category: 'tests',
  1116. fn: function (){
  1117. var self=this;
  1118. var src,ast;
  1119. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  1120. return smalltalk.withContext(function($ctx1) {
  1121. src="foo self := 1";
  1122. ast=_st(smalltalk)._parse_(src);
  1123. self._should_raise_((function(){
  1124. return smalltalk.withContext(function($ctx2) {
  1125. return _st(self["@analyzer"])._visit_(ast);
  1126. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$InvalidAssignmentError());
  1127. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1128. args: [],
  1129. 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",
  1130. messageSends: ["parse:", "should:raise:", "visit:"],
  1131. referencedClasses: ["InvalidAssignmentError"]
  1132. }),
  1133. smalltalk.SemanticAnalyzerTest);
  1134. smalltalk.addMethod(
  1135. smalltalk.method({
  1136. selector: "testNonLocalReturn",
  1137. category: 'tests',
  1138. fn: function (){
  1139. var self=this;
  1140. var src,ast;
  1141. return smalltalk.withContext(function($ctx1) {
  1142. src="foo | a | a + 1. ^ a";
  1143. ast=_st(smalltalk)._parse_(src);
  1144. _st(self["@analyzer"])._visit_(ast);
  1145. self._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1146. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1147. args: [],
  1148. 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",
  1149. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"],
  1150. referencedClasses: []
  1151. }),
  1152. smalltalk.SemanticAnalyzerTest);
  1153. smalltalk.addMethod(
  1154. smalltalk.method({
  1155. selector: "testNonLocalReturn2",
  1156. category: 'tests',
  1157. fn: function (){
  1158. var self=this;
  1159. var src,ast;
  1160. return smalltalk.withContext(function($ctx1) {
  1161. src="foo | a | a + 1. [ [ ^ a] ]";
  1162. ast=_st(smalltalk)._parse_(src);
  1163. _st(self["@analyzer"])._visit_(ast);
  1164. self._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1165. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1166. args: [],
  1167. 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",
  1168. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"],
  1169. referencedClasses: []
  1170. }),
  1171. smalltalk.SemanticAnalyzerTest);
  1172. smalltalk.addMethod(
  1173. smalltalk.method({
  1174. selector: "testScope",
  1175. category: 'tests',
  1176. fn: function (){
  1177. var self=this;
  1178. var src,ast;
  1179. return smalltalk.withContext(function($ctx1) {
  1180. src="foo | a | a + 1. [ | b | b := a ]";
  1181. ast=_st(smalltalk)._parse_(src);
  1182. _st(self["@analyzer"])._visit_(ast);
  1183. self._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  1184. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1185. args: [],
  1186. 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.",
  1187. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"],
  1188. referencedClasses: []
  1189. }),
  1190. smalltalk.SemanticAnalyzerTest);
  1191. smalltalk.addMethod(
  1192. smalltalk.method({
  1193. selector: "testScope2",
  1194. category: 'tests',
  1195. fn: function (){
  1196. var self=this;
  1197. var src,ast;
  1198. return smalltalk.withContext(function($ctx1) {
  1199. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1200. ast=_st(smalltalk)._parse_(src);
  1201. _st(self["@analyzer"])._visit_(ast);
  1202. 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()));
  1203. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1204. args: [],
  1205. 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.",
  1206. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"],
  1207. referencedClasses: []
  1208. }),
  1209. smalltalk.SemanticAnalyzerTest);
  1210. smalltalk.addMethod(
  1211. smalltalk.method({
  1212. selector: "testScopeLevel",
  1213. category: 'tests',
  1214. fn: function (){
  1215. var self=this;
  1216. var src,ast;
  1217. return smalltalk.withContext(function($ctx1) {
  1218. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1219. ast=_st(smalltalk)._parse_(src);
  1220. _st(self["@analyzer"])._visit_(ast);
  1221. self._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  1222. 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));
  1223. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1224. args: [],
  1225. 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",
  1226. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"],
  1227. referencedClasses: []
  1228. }),
  1229. smalltalk.SemanticAnalyzerTest);
  1230. smalltalk.addMethod(
  1231. smalltalk.method({
  1232. selector: "testUnknownVariables",
  1233. category: 'tests',
  1234. fn: function (){
  1235. var self=this;
  1236. var src,ast;
  1237. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1238. return smalltalk.withContext(function($ctx1) {
  1239. src="foo | a | b + a";
  1240. ast=_st(smalltalk)._parse_(src);
  1241. self._should_raise_((function(){
  1242. return smalltalk.withContext(function($ctx2) {
  1243. return _st(self["@analyzer"])._visit_(ast);
  1244. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1245. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1246. args: [],
  1247. 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",
  1248. messageSends: ["parse:", "should:raise:", "visit:"],
  1249. referencedClasses: ["UnknownVariableError"]
  1250. }),
  1251. smalltalk.SemanticAnalyzerTest);
  1252. smalltalk.addMethod(
  1253. smalltalk.method({
  1254. selector: "testUnknownVariablesWithScope",
  1255. category: 'tests',
  1256. fn: function (){
  1257. var self=this;
  1258. var src,ast;
  1259. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1260. return smalltalk.withContext(function($ctx1) {
  1261. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  1262. ast=_st(smalltalk)._parse_(src);
  1263. self._should_raise_((function(){
  1264. return smalltalk.withContext(function($ctx2) {
  1265. return _st(self["@analyzer"])._visit_(ast);
  1266. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1267. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1268. args: [],
  1269. 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",
  1270. messageSends: ["parse:", "should:raise:", "visit:"],
  1271. referencedClasses: ["UnknownVariableError"]
  1272. }),
  1273. smalltalk.SemanticAnalyzerTest);
  1274. smalltalk.addMethod(
  1275. smalltalk.method({
  1276. selector: "testVariableShadowing",
  1277. category: 'tests',
  1278. fn: function (){
  1279. var self=this;
  1280. var src,ast;
  1281. return smalltalk.withContext(function($ctx1) {
  1282. src="foo | a | a + 1";
  1283. ast=_st(smalltalk)._parse_(src);
  1284. _st(self["@analyzer"])._visit_(ast);
  1285. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1286. args: [],
  1287. source: "testVariableShadowing\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1288. messageSends: ["parse:", "visit:"],
  1289. referencedClasses: []
  1290. }),
  1291. smalltalk.SemanticAnalyzerTest);
  1292. smalltalk.addMethod(
  1293. smalltalk.method({
  1294. selector: "testVariableShadowing2",
  1295. category: 'tests',
  1296. fn: function (){
  1297. var self=this;
  1298. var src,ast;
  1299. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1300. return smalltalk.withContext(function($ctx1) {
  1301. src="foo | a | a + 1. [ | a | a := 2 ]";
  1302. ast=_st(smalltalk)._parse_(src);
  1303. self._should_raise_((function(){
  1304. return smalltalk.withContext(function($ctx2) {
  1305. return _st(self["@analyzer"])._visit_(ast);
  1306. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1307. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1308. args: [],
  1309. 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",
  1310. messageSends: ["parse:", "should:raise:", "visit:"],
  1311. referencedClasses: ["ShadowingVariableError"]
  1312. }),
  1313. smalltalk.SemanticAnalyzerTest);
  1314. smalltalk.addMethod(
  1315. smalltalk.method({
  1316. selector: "testVariableShadowing3",
  1317. category: 'tests',
  1318. fn: function (){
  1319. var self=this;
  1320. var src,ast;
  1321. return smalltalk.withContext(function($ctx1) {
  1322. src="foo | a | a + 1. [ | b | b := 2 ]";
  1323. ast=_st(smalltalk)._parse_(src);
  1324. _st(self["@analyzer"])._visit_(ast);
  1325. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1326. args: [],
  1327. source: "testVariableShadowing3\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ | b | b := 2 ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1328. messageSends: ["parse:", "visit:"],
  1329. referencedClasses: []
  1330. }),
  1331. smalltalk.SemanticAnalyzerTest);
  1332. smalltalk.addMethod(
  1333. smalltalk.method({
  1334. selector: "testVariableShadowing4",
  1335. category: 'tests',
  1336. fn: function (){
  1337. var self=this;
  1338. var src,ast;
  1339. return smalltalk.withContext(function($ctx1) {
  1340. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1341. ast=_st(smalltalk)._parse_(src);
  1342. _st(self["@analyzer"])._visit_(ast);
  1343. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1344. args: [],
  1345. source: "testVariableShadowing4\x0a\x09| src ast |\x0a\x09src := 'foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]'.\x0a\x09ast := smalltalk parse: src.\x0a\x09analyzer visit: ast",
  1346. messageSends: ["parse:", "visit:"],
  1347. referencedClasses: []
  1348. }),
  1349. smalltalk.SemanticAnalyzerTest);
  1350. smalltalk.addMethod(
  1351. smalltalk.method({
  1352. selector: "testVariableShadowing5",
  1353. category: 'tests',
  1354. fn: function (){
  1355. var self=this;
  1356. var src,ast;
  1357. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1358. return smalltalk.withContext(function($ctx1) {
  1359. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1360. ast=_st(smalltalk)._parse_(src);
  1361. self._should_raise_((function(){
  1362. return smalltalk.withContext(function($ctx2) {
  1363. return _st(self["@analyzer"])._visit_(ast);
  1364. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1365. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1366. args: [],
  1367. 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",
  1368. messageSends: ["parse:", "should:raise:", "visit:"],
  1369. referencedClasses: ["ShadowingVariableError"]
  1370. }),
  1371. smalltalk.SemanticAnalyzerTest);
  1372. smalltalk.addMethod(
  1373. smalltalk.method({
  1374. selector: "testVariablesLookup",
  1375. category: 'tests',
  1376. fn: function (){
  1377. var self=this;
  1378. var src,ast;
  1379. return smalltalk.withContext(function($ctx1) {
  1380. src="foo | a | a + 1. [ | b | b := a ]";
  1381. ast=_st(smalltalk)._parse_(src);
  1382. _st(self["@analyzer"])._visit_(ast);
  1383. self._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1384. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1385. 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());
  1386. 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()));
  1387. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1388. args: [],
  1389. 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.",
  1390. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"],
  1391. referencedClasses: []
  1392. }),
  1393. smalltalk.SemanticAnalyzerTest);
  1394. });