Compiler-Tests.js 75 KB

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