2
0

Compiler-Tests.js 75 KB

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