1
0

Compiler-Tests.js 74 KB

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