Compiler-Tests.js 74 KB

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