Compiler-Tests.js 78 KB

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