Compiler-Tests.deploy.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. define("amber/Compiler-Tests", ["amber_vm/smalltalk","amber_vm/nil","amber_vm/_st"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Tests');
  3. smalltalk.packages["Compiler-Tests"].transport = {"type":"amd","amdNamespace":"amber"};
  4. smalltalk.addClass('ASTVisitorTest', smalltalk.TestCase, [], 'Compiler-Tests');
  5. smalltalk.addMethod(
  6. smalltalk.method({
  7. selector: "analyze:forClass:",
  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. messageSends: ["visit:", "on:"]}),
  18. smalltalk.ASTVisitorTest);
  19. smalltalk.addMethod(
  20. smalltalk.method({
  21. selector: "parse:",
  22. fn: function (aString){
  23. var self=this;
  24. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  25. return smalltalk.withContext(function($ctx1) {
  26. var $1;
  27. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  28. return $1;
  29. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.ASTVisitorTest)})},
  30. messageSends: ["parse:", "current"]}),
  31. smalltalk.ASTVisitorTest);
  32. smalltalk.addMethod(
  33. smalltalk.method({
  34. selector: "parse:forClass:",
  35. fn: function (aString,aClass){
  36. var self=this;
  37. return smalltalk.withContext(function($ctx1) {
  38. var $1;
  39. $1=self._analyze_forClass_(self._parse_(aString),aClass);
  40. return $1;
  41. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.ASTVisitorTest)})},
  42. messageSends: ["analyze:forClass:", "parse:"]}),
  43. smalltalk.ASTVisitorTest);
  44. smalltalk.addClass('ASTPCNodeVisitorTest', smalltalk.ASTVisitorTest, [], 'Compiler-Tests');
  45. smalltalk.addMethod(
  46. smalltalk.method({
  47. selector: "astPCNodeVisitor",
  48. fn: function (){
  49. var self=this;
  50. return smalltalk.withContext(function($ctx1) {
  51. var $1;
  52. $1=self._astPCNodeVisitorForPC_((0));
  53. return $1;
  54. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitor",{},smalltalk.ASTPCNodeVisitorTest)})},
  55. messageSends: ["astPCNodeVisitorForPC:"]}),
  56. smalltalk.ASTPCNodeVisitorTest);
  57. smalltalk.addMethod(
  58. smalltalk.method({
  59. selector: "astPCNodeVisitorForPC:",
  60. fn: function (anInteger){
  61. var self=this;
  62. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  63. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  64. return smalltalk.withContext(function($ctx1) {
  65. var $2,$3,$4,$5,$1;
  66. $2=_st($ASTPCNodeVisitor())._new();
  67. _st($2)._pc_((0));
  68. $3=_st($AIContext())._new();
  69. _st($3)._pc_(anInteger);
  70. $4=_st($3)._yourself();
  71. _st($2)._context_($4);
  72. $5=_st($2)._yourself();
  73. $1=$5;
  74. return $1;
  75. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitorForPC:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitorTest)})},
  76. messageSends: ["pc:", "new", "context:", "yourself"]}),
  77. smalltalk.ASTPCNodeVisitorTest);
  78. smalltalk.addMethod(
  79. smalltalk.method({
  80. selector: "testJSStatementNode",
  81. fn: function (){
  82. var self=this;
  83. var ast,visitor;
  84. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  85. return smalltalk.withContext(function($ctx1) {
  86. var $1,$2;
  87. ast=self._parse_forClass_("foo <consolee.log(1)>",$Object());
  88. $1=self._astPCNodeVisitor();
  89. _st($1)._visit_(ast);
  90. $2=_st($1)._currentNode();
  91. self._assert_(_st($2)._isJSStatementNode());
  92. return self}, function($ctx1) {$ctx1.fill(self,"testJSStatementNode",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  93. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"]}),
  94. smalltalk.ASTPCNodeVisitorTest);
  95. smalltalk.addMethod(
  96. smalltalk.method({
  97. selector: "testMessageSend",
  98. fn: function (){
  99. var self=this;
  100. var ast;
  101. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  102. return smalltalk.withContext(function($ctx1) {
  103. var $1,$2;
  104. ast=self._parse_forClass_("foo self asString yourself. ^ self asBoolean",$Object());
  105. $1=self._astPCNodeVisitorForPC_((2));
  106. _st($1)._visit_(ast);
  107. $2=_st($1)._currentNode();
  108. self._assert_equals_(_st($2)._selector(),"yourself");
  109. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  110. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"]}),
  111. smalltalk.ASTPCNodeVisitorTest);
  112. smalltalk.addMethod(
  113. smalltalk.method({
  114. selector: "testMessageSendWithInlining",
  115. fn: function (){
  116. var self=this;
  117. var ast;
  118. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  119. return smalltalk.withContext(function($ctx1) {
  120. var $1,$2,$3,$4;
  121. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  122. $1=self._astPCNodeVisitorForPC_((2));
  123. _st($1)._visit_(ast);
  124. $2=_st($1)._currentNode();
  125. self._assert_equals_(_st($2)._selector(),"yourself");
  126. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  127. $3=self._astPCNodeVisitorForPC_((3));
  128. _st($3)._visit_(ast);
  129. $4=_st($3)._currentNode();
  130. self._assert_equals_(_st($4)._selector(),"asBoolean");
  131. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSendWithInlining",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  132. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"]}),
  133. smalltalk.ASTPCNodeVisitorTest);
  134. smalltalk.addMethod(
  135. smalltalk.method({
  136. selector: "testNoMessageSend",
  137. fn: function (){
  138. var self=this;
  139. var ast;
  140. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  141. return smalltalk.withContext(function($ctx1) {
  142. var $1,$2;
  143. ast=self._parse_forClass_("foo ^ self",$Object());
  144. $1=self._astPCNodeVisitor();
  145. _st($1)._visit_(ast);
  146. $2=_st($1)._currentNode();
  147. self._assert_(_st($2)._isNil());
  148. return self}, function($ctx1) {$ctx1.fill(self,"testNoMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  149. messageSends: ["parse:forClass:", "assert:", "isNil", "visit:", "astPCNodeVisitor", "currentNode"]}),
  150. smalltalk.ASTPCNodeVisitorTest);
  151. smalltalk.addMethod(
  152. smalltalk.method({
  153. selector: "testPC",
  154. fn: function (){
  155. var self=this;
  156. var ast,visitor;
  157. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  158. return smalltalk.withContext(function($ctx1) {
  159. var $1,$2;
  160. ast=self._parse_forClass_("foo <console.log(1)>",$Object());
  161. $1=self._astPCNodeVisitor();
  162. _st($1)._visit_(ast);
  163. $2=_st($1)._currentNode();
  164. self._assert_(_st($2)._isJSStatementNode());
  165. return self}, function($ctx1) {$ctx1.fill(self,"testPC",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  166. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"]}),
  167. smalltalk.ASTPCNodeVisitorTest);
  168. smalltalk.addClass('AbstractASTInterpreterTest', smalltalk.ASTVisitorTest, [], 'Compiler-Tests');
  169. smalltalk.addMethod(
  170. smalltalk.method({
  171. selector: "interpret:",
  172. fn: function (aString){
  173. var self=this;
  174. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  175. return smalltalk.withContext(function($ctx1) {
  176. var $1;
  177. $1=self._interpret_withArguments_(aString,_st($Dictionary())._new());
  178. return $1;
  179. }, function($ctx1) {$ctx1.fill(self,"interpret:",{aString:aString},smalltalk.AbstractASTInterpreterTest)})},
  180. messageSends: ["interpret:withArguments:", "new"]}),
  181. smalltalk.AbstractASTInterpreterTest);
  182. smalltalk.addMethod(
  183. smalltalk.method({
  184. selector: "interpret:receiver:withArguments:",
  185. fn: function (aString,anObject,aDictionary){
  186. var self=this;
  187. var ctx;
  188. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  189. return smalltalk.withContext(function($ctx1) {
  190. var $2,$3,$1;
  191. ctx=_st($AIContext())._new();
  192. _st(ctx)._receiver_(anObject);
  193. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  194. return smalltalk.withContext(function($ctx2) {
  195. return _st(ctx)._localAt_put_(key,value);
  196. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  197. $2=self._interpreter();
  198. _st($2)._context_(ctx);
  199. _st($2)._interpret_(_st(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nodes())._first());
  200. $3=_st($2)._result();
  201. $1=$3;
  202. return $1;
  203. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx},smalltalk.AbstractASTInterpreterTest)})},
  204. messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "first", "nodes", "parse:forClass:", "class", "result"]}),
  205. smalltalk.AbstractASTInterpreterTest);
  206. smalltalk.addMethod(
  207. smalltalk.method({
  208. selector: "interpret:withArguments:",
  209. fn: function (aString,aDictionary){
  210. var self=this;
  211. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  212. return smalltalk.withContext(function($ctx1) {
  213. var $1;
  214. $1=self._interpret_receiver_withArguments_(aString,_st($Object())._new(),aDictionary);
  215. return $1;
  216. }, function($ctx1) {$ctx1.fill(self,"interpret:withArguments:",{aString:aString,aDictionary:aDictionary},smalltalk.AbstractASTInterpreterTest)})},
  217. messageSends: ["interpret:receiver:withArguments:", "new"]}),
  218. smalltalk.AbstractASTInterpreterTest);
  219. smalltalk.addMethod(
  220. smalltalk.method({
  221. selector: "interpreter",
  222. fn: function (){
  223. var self=this;
  224. return smalltalk.withContext(function($ctx1) {
  225. var $1;
  226. $1=self._subclassResponsibility();
  227. return $1;
  228. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AbstractASTInterpreterTest)})},
  229. messageSends: ["subclassResponsibility"]}),
  230. smalltalk.AbstractASTInterpreterTest);
  231. smalltalk.addClass('ASTInterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
  232. smalltalk.addMethod(
  233. smalltalk.method({
  234. selector: "interpreter",
  235. fn: function (){
  236. var self=this;
  237. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  238. return smalltalk.withContext(function($ctx1) {
  239. var $1;
  240. $1=_st($ASTInterpreter())._new();
  241. return $1;
  242. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTInterpreterTest)})},
  243. messageSends: ["new"]}),
  244. smalltalk.ASTInterpreterTest);
  245. smalltalk.addMethod(
  246. smalltalk.method({
  247. selector: "testBinarySend",
  248. fn: function (){
  249. var self=this;
  250. return smalltalk.withContext(function($ctx1) {
  251. self._assert_equals_(self._interpret_("foo 2+3+4"),(9));
  252. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.ASTInterpreterTest)})},
  253. messageSends: ["assert:equals:", "interpret:"]}),
  254. smalltalk.ASTInterpreterTest);
  255. smalltalk.addMethod(
  256. smalltalk.method({
  257. selector: "testBlockLiteral",
  258. fn: function (){
  259. var self=this;
  260. return smalltalk.withContext(function($ctx1) {
  261. self._assert_equals_(self._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  262. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  263. self._assert_equals_(self._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  264. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.ASTInterpreterTest)})},
  265. messageSends: ["assert:equals:", "interpret:"]}),
  266. smalltalk.ASTInterpreterTest);
  267. smalltalk.addMethod(
  268. smalltalk.method({
  269. selector: "testCascade",
  270. fn: function (){
  271. var self=this;
  272. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  273. return smalltalk.withContext(function($ctx1) {
  274. self._assert_equals_(self._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  275. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.ASTInterpreterTest)})},
  276. messageSends: ["assert:equals:", "interpret:", "with:with:"]}),
  277. smalltalk.ASTInterpreterTest);
  278. smalltalk.addMethod(
  279. smalltalk.method({
  280. selector: "testDynamicArray",
  281. fn: function (){
  282. var self=this;
  283. return smalltalk.withContext(function($ctx1) {
  284. self._assert_equals_(self._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  285. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.ASTInterpreterTest)})},
  286. messageSends: ["assert:equals:", "interpret:"]}),
  287. smalltalk.ASTInterpreterTest);
  288. smalltalk.addMethod(
  289. smalltalk.method({
  290. selector: "testDynamicDictionary",
  291. fn: function (){
  292. var self=this;
  293. return smalltalk.withContext(function($ctx1) {
  294. self._assert_equals_(self._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._from_([(1).__minus_gt((1)),(2).__minus_gt((3))]));
  295. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.ASTInterpreterTest)})},
  296. messageSends: ["assert:equals:", "interpret:", "->"]}),
  297. smalltalk.ASTInterpreterTest);
  298. smalltalk.addMethod(
  299. smalltalk.method({
  300. selector: "testInlinedJSStatement",
  301. fn: function (){
  302. var self=this;
  303. return smalltalk.withContext(function($ctx1) {
  304. self._assert_equals_(self._interpret_("foo <return 2+3>"),(5));
  305. self._assert_equals_(self._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._from_(["anInteger".__minus_gt((3))])),(5));
  306. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.ASTInterpreterTest)})},
  307. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"]}),
  308. smalltalk.ASTInterpreterTest);
  309. smalltalk.addMethod(
  310. smalltalk.method({
  311. selector: "testInstVarAccess",
  312. fn: function (){
  313. var self=this;
  314. return smalltalk.withContext(function($ctx1) {
  315. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ x",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2));
  316. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.ASTInterpreterTest)})},
  317. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  318. smalltalk.ASTInterpreterTest);
  319. smalltalk.addMethod(
  320. smalltalk.method({
  321. selector: "testInstVarAssignment",
  322. fn: function (){
  323. var self=this;
  324. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  325. return smalltalk.withContext(function($ctx1) {
  326. self._assert_equals_(self._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._from_(["anInteger".__minus_gt((2))])),(2));
  327. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.ASTInterpreterTest)})},
  328. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"]}),
  329. smalltalk.ASTInterpreterTest);
  330. smalltalk.addMethod(
  331. smalltalk.method({
  332. selector: "testNonlocalReturn",
  333. fn: function (){
  334. var self=this;
  335. return smalltalk.withContext(function($ctx1) {
  336. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  337. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.ASTInterpreterTest)})},
  338. messageSends: ["assert:equals:", "interpret:"]}),
  339. smalltalk.ASTInterpreterTest);
  340. smalltalk.addMethod(
  341. smalltalk.method({
  342. selector: "testReceiver",
  343. fn: function (){
  344. var self=this;
  345. return smalltalk.withContext(function($ctx1) {
  346. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ self",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2).__at((3)));
  347. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.ASTInterpreterTest)})},
  348. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  349. smalltalk.ASTInterpreterTest);
  350. smalltalk.addMethod(
  351. smalltalk.method({
  352. selector: "testSuper",
  353. fn: function (){
  354. var self=this;
  355. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  356. return smalltalk.withContext(function($ctx1) {
  357. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ super isBoolean",true,_st($Dictionary())._new()),false);
  358. return self}, function($ctx1) {$ctx1.fill(self,"testSuper",{},smalltalk.ASTInterpreterTest)})},
  359. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new"]}),
  360. smalltalk.ASTInterpreterTest);
  361. smalltalk.addMethod(
  362. smalltalk.method({
  363. selector: "testTempAssignment",
  364. fn: function (){
  365. var self=this;
  366. return smalltalk.withContext(function($ctx1) {
  367. self._assert_equals_(self._interpret_("foo | a | a := 2. ^ a"),(2));
  368. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.ASTInterpreterTest)})},
  369. messageSends: ["assert:equals:", "interpret:"]}),
  370. smalltalk.ASTInterpreterTest);
  371. smalltalk.addMethod(
  372. smalltalk.method({
  373. selector: "testThisContext",
  374. fn: function (){
  375. var self=this;
  376. return smalltalk.withContext(function($ctx1) {
  377. self._assert_(_st(_st(self._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  378. self._assert_(_st(_st(self._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  379. self._assert_(self._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  380. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.ASTInterpreterTest)})},
  381. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
  382. smalltalk.ASTInterpreterTest);
  383. smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');
  384. smalltalk.addMethod(
  385. smalltalk.method({
  386. selector: "interpreter",
  387. fn: function (){
  388. var self=this;
  389. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  390. return smalltalk.withContext(function($ctx1) {
  391. var $2,$1;
  392. $2=self["@interpreter"];
  393. if(($receiver = $2) == nil || $receiver == undefined){
  394. self["@interpreter"]=_st($ASTSteppingInterpreter())._new();
  395. $1=self["@interpreter"];
  396. } else {
  397. $1=$2;
  398. };
  399. return $1;
  400. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTSteppingInterpreterTest)})},
  401. messageSends: ["ifNil:", "new"]}),
  402. smalltalk.ASTSteppingInterpreterTest);
  403. smalltalk.addMethod(
  404. smalltalk.method({
  405. selector: "testAtEnd",
  406. fn: function (){
  407. var self=this;
  408. return smalltalk.withContext(function($ctx1) {
  409. self._interpret_("foo 1 + 2");
  410. self._deny_(_st(self._interpreter())._atEnd());
  411. _st(self._interpreter())._step();
  412. self._deny_(_st(self._interpreter())._atEnd());
  413. _st(self._interpreter())._step();
  414. self._deny_(_st(self._interpreter())._atEnd());
  415. _st(self._interpreter())._step();
  416. self._deny_(_st(self._interpreter())._atEnd());
  417. _st(self._interpreter())._step();
  418. self._assert_(_st(self._interpreter())._atEnd());
  419. return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.ASTSteppingInterpreterTest)})},
  420. messageSends: ["interpret:", "deny:", "atEnd", "interpreter", "step", "assert:"]}),
  421. smalltalk.ASTSteppingInterpreterTest);
  422. smalltalk.addMethod(
  423. smalltalk.method({
  424. selector: "testMessageSend",
  425. fn: function (){
  426. var self=this;
  427. return smalltalk.withContext(function($ctx1) {
  428. self._interpret_("foo 1 + 2");
  429. _st(self._interpreter())._step();
  430. _st(self._interpreter())._step();
  431. _st(self._interpreter())._step();
  432. self._assert_equals_(_st(_st(self._interpreter())._currentNode())._value(),(1));
  433. _st(self._interpreter())._step();
  434. self._assert_equals_(_st(_st(self._interpreter())._currentNode())._value(),(2));
  435. _st(self._interpreter())._step();
  436. self._assert_equals_(_st(self._interpreter())._result(),(3));
  437. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.ASTSteppingInterpreterTest)})},
  438. messageSends: ["interpret:", "step", "interpreter", "assert:equals:", "value", "currentNode", "result"]}),
  439. smalltalk.ASTSteppingInterpreterTest);
  440. smalltalk.addMethod(
  441. smalltalk.method({
  442. selector: "testSimpleStepping",
  443. fn: function (){
  444. var self=this;
  445. return smalltalk.withContext(function($ctx1) {
  446. self._interpret_("foo 1");
  447. _st(self._interpreter())._step();
  448. self._assert_(_st(_st(self._interpreter())._result())._isNil());
  449. _st(self._interpreter())._step();
  450. self._assert_equals_(_st(self._interpreter())._result(),(1));
  451. return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{},smalltalk.ASTSteppingInterpreterTest)})},
  452. messageSends: ["interpret:", "step", "interpreter", "assert:", "isNil", "result", "assert:equals:"]}),
  453. smalltalk.ASTSteppingInterpreterTest);
  454. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  455. smalltalk.addMethod(
  456. smalltalk.method({
  457. selector: "codeGeneratorClass",
  458. fn: function (){
  459. var self=this;
  460. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  461. return smalltalk.withContext(function($ctx1) {
  462. var $1;
  463. $1=$CodeGenerator();
  464. return $1;
  465. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  466. messageSends: []}),
  467. smalltalk.CodeGeneratorTest);
  468. smalltalk.addMethod(
  469. smalltalk.method({
  470. selector: "compiler",
  471. fn: function (){
  472. var self=this;
  473. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  474. return smalltalk.withContext(function($ctx1) {
  475. var $2,$3,$1;
  476. $2=_st($Compiler())._new();
  477. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  478. $3=_st($2)._yourself();
  479. $1=$3;
  480. return $1;
  481. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  482. messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"]}),
  483. smalltalk.CodeGeneratorTest);
  484. smalltalk.addMethod(
  485. smalltalk.method({
  486. selector: "setUp",
  487. fn: function (){
  488. var self=this;
  489. return smalltalk.withContext(function($ctx1) {
  490. self["@receiver"]=_st(self._targetClass())._new();
  491. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  492. messageSends: ["new", "targetClass"]}),
  493. smalltalk.CodeGeneratorTest);
  494. smalltalk.addMethod(
  495. smalltalk.method({
  496. selector: "should:return:",
  497. fn: function (aString,anObject){
  498. var self=this;
  499. var method,result;
  500. return smalltalk.withContext(function($ctx1) {
  501. method=_st(self._compiler())._install_forClass_category_(aString,self._targetClass(),"tests");
  502. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  503. _st(self._targetClass())._removeCompiledMethod_(method);
  504. self._assert_equals_(anObject,result);
  505. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  506. messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"]}),
  507. smalltalk.CodeGeneratorTest);
  508. smalltalk.addMethod(
  509. smalltalk.method({
  510. selector: "targetClass",
  511. fn: function (){
  512. var self=this;
  513. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  514. return smalltalk.withContext(function($ctx1) {
  515. var $1;
  516. $1=$DoIt();
  517. return $1;
  518. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  519. messageSends: []}),
  520. smalltalk.CodeGeneratorTest);
  521. smalltalk.addMethod(
  522. smalltalk.method({
  523. selector: "tearDown",
  524. fn: function (){
  525. var self=this;
  526. return smalltalk.withContext(function($ctx1) {
  527. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  528. messageSends: []}),
  529. smalltalk.CodeGeneratorTest);
  530. smalltalk.addMethod(
  531. smalltalk.method({
  532. selector: "testAssignment",
  533. fn: function (){
  534. var self=this;
  535. return smalltalk.withContext(function($ctx1) {
  536. self._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  537. self._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  538. self._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  539. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  540. messageSends: ["should:return:"]}),
  541. smalltalk.CodeGeneratorTest);
  542. smalltalk.addMethod(
  543. smalltalk.method({
  544. selector: "testBackslashSelectors",
  545. fn: function (){
  546. var self=this;
  547. return smalltalk.withContext(function($ctx1) {
  548. self._should_return_("\x5c arg ^ 4",(4));
  549. self._should_return_("\x5c\x5c arg ^ 42",(42));
  550. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  551. messageSends: ["should:return:"]}),
  552. smalltalk.CodeGeneratorTest);
  553. smalltalk.addMethod(
  554. smalltalk.method({
  555. selector: "testBlockReturn",
  556. fn: function (){
  557. var self=this;
  558. return smalltalk.withContext(function($ctx1) {
  559. self._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  560. self._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  561. self._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  562. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  563. messageSends: ["should:return:"]}),
  564. smalltalk.CodeGeneratorTest);
  565. smalltalk.addMethod(
  566. smalltalk.method({
  567. selector: "testCascades",
  568. fn: function (){
  569. var self=this;
  570. return smalltalk.withContext(function($ctx1) {
  571. self._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  572. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  573. messageSends: ["should:return:"]}),
  574. smalltalk.CodeGeneratorTest);
  575. smalltalk.addMethod(
  576. smalltalk.method({
  577. selector: "testDynamicArrayElementsOrdered",
  578. fn: function (){
  579. var self=this;
  580. return smalltalk.withContext(function($ctx1) {
  581. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  582. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  583. messageSends: ["should:return:"]}),
  584. smalltalk.CodeGeneratorTest);
  585. smalltalk.addMethod(
  586. smalltalk.method({
  587. selector: "testDynamicDictionaryElementsOrdered",
  588. fn: function (){
  589. var self=this;
  590. return smalltalk.withContext(function($ctx1) {
  591. 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))]));
  592. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  593. messageSends: ["should:return:", "->"]}),
  594. smalltalk.CodeGeneratorTest);
  595. smalltalk.addMethod(
  596. smalltalk.method({
  597. selector: "testInnerTemporalDependentElementsOrdered",
  598. fn: function (){
  599. var self=this;
  600. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  601. return smalltalk.withContext(function($ctx1) {
  602. 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))]);
  603. 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))]);
  604. 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))]);
  605. 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))]));
  606. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  607. messageSends: ["should:return:", "->"]}),
  608. smalltalk.CodeGeneratorTest);
  609. smalltalk.addMethod(
  610. smalltalk.method({
  611. selector: "testLiterals",
  612. fn: function (){
  613. var self=this;
  614. return smalltalk.withContext(function($ctx1) {
  615. self._should_return_("foo ^ 1",(1));
  616. self._should_return_("foo ^ 'hello'","hello");
  617. self._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  618. self._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  619. self._should_return_("foo ^ true",true);
  620. self._should_return_("foo ^ false",false);
  621. self._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._from_([(1).__minus_gt((2)),(3).__minus_gt((4))]));
  622. self._should_return_("foo ^ #hello","hello");
  623. self._should_return_("foo ^ -123.456",(-123.456));
  624. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  625. messageSends: ["should:return:", "->"]}),
  626. smalltalk.CodeGeneratorTest);
  627. smalltalk.addMethod(
  628. smalltalk.method({
  629. selector: "testLocalReturn",
  630. fn: function (){
  631. var self=this;
  632. return smalltalk.withContext(function($ctx1) {
  633. self._should_return_("foo ^ 1",(1));
  634. self._should_return_("foo ^ 1 + 1",(2));
  635. self._should_return_("foo ",self["@receiver"]);
  636. self._should_return_("foo self asString",self["@receiver"]);
  637. self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  638. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  639. messageSends: ["should:return:"]}),
  640. smalltalk.CodeGeneratorTest);
  641. smalltalk.addMethod(
  642. smalltalk.method({
  643. selector: "testMessageSends",
  644. fn: function (){
  645. var self=this;
  646. return smalltalk.withContext(function($ctx1) {
  647. self._should_return_("foo ^ 1 asString","1");
  648. self._should_return_("foo ^ 1 + 1",(2));
  649. self._should_return_("foo ^ 1 + 2 * 3",(9));
  650. self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  651. self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  652. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  653. messageSends: ["should:return:"]}),
  654. smalltalk.CodeGeneratorTest);
  655. smalltalk.addMethod(
  656. smalltalk.method({
  657. selector: "testMutableLiterals",
  658. fn: function (){
  659. var self=this;
  660. return smalltalk.withContext(function($ctx1) {
  661. self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  662. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  663. messageSends: ["should:return:"]}),
  664. smalltalk.CodeGeneratorTest);
  665. smalltalk.addMethod(
  666. smalltalk.method({
  667. selector: "testNestedIfTrue",
  668. fn: function (){
  669. var self=this;
  670. return smalltalk.withContext(function($ctx1) {
  671. self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  672. self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  673. self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  674. self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  675. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  676. messageSends: ["should:return:"]}),
  677. smalltalk.CodeGeneratorTest);
  678. smalltalk.addMethod(
  679. smalltalk.method({
  680. selector: "testNonLocalReturn",
  681. fn: function (){
  682. var self=this;
  683. return smalltalk.withContext(function($ctx1) {
  684. self._should_return_("foo [ ^ 1 ] value",(1));
  685. self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  686. self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  687. self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  688. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  689. messageSends: ["should:return:"]}),
  690. smalltalk.CodeGeneratorTest);
  691. smalltalk.addMethod(
  692. smalltalk.method({
  693. selector: "testPascalCaseGlobal",
  694. fn: function (){
  695. var self=this;
  696. return smalltalk.withContext(function($ctx1) {
  697. self._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  698. self._should_return_("foo ^NonExistent",nil);
  699. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  700. messageSends: ["should:return:", "at:"]}),
  701. smalltalk.CodeGeneratorTest);
  702. smalltalk.addMethod(
  703. smalltalk.method({
  704. selector: "testSendReceiverAndArgumentsOrdered",
  705. fn: function (){
  706. var self=this;
  707. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  708. return smalltalk.withContext(function($ctx1) {
  709. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  710. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  711. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  712. messageSends: ["should:return:"]}),
  713. smalltalk.CodeGeneratorTest);
  714. smalltalk.addMethod(
  715. smalltalk.method({
  716. selector: "testifFalse",
  717. fn: function (){
  718. var self=this;
  719. return smalltalk.withContext(function($ctx1) {
  720. self._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  721. self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  722. self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  723. self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  724. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  725. messageSends: ["should:return:"]}),
  726. smalltalk.CodeGeneratorTest);
  727. smalltalk.addMethod(
  728. smalltalk.method({
  729. selector: "testifFalseIfTrue",
  730. fn: function (){
  731. var self=this;
  732. return smalltalk.withContext(function($ctx1) {
  733. self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  734. self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  735. self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  736. self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  737. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  738. messageSends: ["should:return:"]}),
  739. smalltalk.CodeGeneratorTest);
  740. smalltalk.addMethod(
  741. smalltalk.method({
  742. selector: "testifNil",
  743. fn: function (){
  744. var self=this;
  745. return smalltalk.withContext(function($ctx1) {
  746. self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  747. self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  748. self._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  749. self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  750. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  751. messageSends: ["should:return:"]}),
  752. smalltalk.CodeGeneratorTest);
  753. smalltalk.addMethod(
  754. smalltalk.method({
  755. selector: "testifNilIfNotNil",
  756. fn: function (){
  757. var self=this;
  758. return smalltalk.withContext(function($ctx1) {
  759. self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  760. self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  761. self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  762. self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  763. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  764. messageSends: ["should:return:"]}),
  765. smalltalk.CodeGeneratorTest);
  766. smalltalk.addMethod(
  767. smalltalk.method({
  768. selector: "testifNotNil",
  769. fn: function (){
  770. var self=this;
  771. return smalltalk.withContext(function($ctx1) {
  772. self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  773. self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  774. self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  775. self._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  776. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  777. messageSends: ["should:return:"]}),
  778. smalltalk.CodeGeneratorTest);
  779. smalltalk.addMethod(
  780. smalltalk.method({
  781. selector: "testifNotNilWithArgument",
  782. fn: function (){
  783. var self=this;
  784. return smalltalk.withContext(function($ctx1) {
  785. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  786. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  787. self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  788. self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  789. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  790. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  791. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  792. messageSends: ["should:return:"]}),
  793. smalltalk.CodeGeneratorTest);
  794. smalltalk.addMethod(
  795. smalltalk.method({
  796. selector: "testifTrue",
  797. fn: function (){
  798. var self=this;
  799. return smalltalk.withContext(function($ctx1) {
  800. self._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  801. self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  802. self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  803. self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  804. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  805. messageSends: ["should:return:"]}),
  806. smalltalk.CodeGeneratorTest);
  807. smalltalk.addMethod(
  808. smalltalk.method({
  809. selector: "testifTrueIfFalse",
  810. fn: function (){
  811. var self=this;
  812. return smalltalk.withContext(function($ctx1) {
  813. self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  814. self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  815. self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  816. self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  817. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  818. messageSends: ["should:return:"]}),
  819. smalltalk.CodeGeneratorTest);
  820. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  821. smalltalk.addMethod(
  822. smalltalk.method({
  823. selector: "codeGeneratorClass",
  824. fn: function (){
  825. var self=this;
  826. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  827. return smalltalk.withContext(function($ctx1) {
  828. var $1;
  829. $1=$InliningCodeGenerator();
  830. return $1;
  831. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  832. messageSends: []}),
  833. smalltalk.InliningCodeGeneratorTest);
  834. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  835. smalltalk.addMethod(
  836. smalltalk.method({
  837. selector: "testClassRefVar",
  838. fn: function (){
  839. var self=this;
  840. var node;
  841. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  842. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  843. return smalltalk.withContext(function($ctx1) {
  844. var $1,$2;
  845. $1=_st($ClassReferenceNode())._new();
  846. _st($1)._value_("Object");
  847. $2=_st($1)._yourself();
  848. node=$2;
  849. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  850. self._assert_(_st(_st(node)._binding())._isClassRefVar());
  851. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  852. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  853. smalltalk.ScopeVarTest);
  854. smalltalk.addMethod(
  855. smalltalk.method({
  856. selector: "testInstanceVar",
  857. fn: function (){
  858. var self=this;
  859. var node,scope;
  860. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  861. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  862. return smalltalk.withContext(function($ctx1) {
  863. var $1,$2;
  864. $1=_st($VariableNode())._new();
  865. _st($1)._value_("bzzz");
  866. $2=_st($1)._yourself();
  867. node=$2;
  868. scope=_st($MethodLexicalScope())._new();
  869. _st(scope)._addIVar_("bzzz");
  870. self._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  871. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  872. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  873. smalltalk.ScopeVarTest);
  874. smalltalk.addMethod(
  875. smalltalk.method({
  876. selector: "testPseudoVar",
  877. fn: function (){
  878. var self=this;
  879. var node,pseudoVars;
  880. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  881. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  882. return smalltalk.withContext(function($ctx1) {
  883. var $1,$2;
  884. pseudoVars=["self", "super", "true", "false", "nil"];
  885. _st(pseudoVars)._do_((function(each){
  886. return smalltalk.withContext(function($ctx2) {
  887. $1=_st($VariableNode())._new();
  888. _st($1)._value_(each);
  889. $2=_st($1)._yourself();
  890. node=$2;
  891. node;
  892. return self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  893. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  894. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  895. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  896. smalltalk.ScopeVarTest);
  897. smalltalk.addMethod(
  898. smalltalk.method({
  899. selector: "testTempVar",
  900. fn: function (){
  901. var self=this;
  902. var node,scope;
  903. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  904. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  905. return smalltalk.withContext(function($ctx1) {
  906. var $1,$2;
  907. $1=_st($VariableNode())._new();
  908. _st($1)._value_("bzzz");
  909. $2=_st($1)._yourself();
  910. node=$2;
  911. scope=_st($MethodLexicalScope())._new();
  912. _st(scope)._addTemp_("bzzz");
  913. self._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  914. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  915. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  916. smalltalk.ScopeVarTest);
  917. smalltalk.addMethod(
  918. smalltalk.method({
  919. selector: "testUnknownVar",
  920. fn: function (){
  921. var self=this;
  922. var node;
  923. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  924. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  925. return smalltalk.withContext(function($ctx1) {
  926. var $1,$2;
  927. $1=_st($VariableNode())._new();
  928. _st($1)._value_("bzzz");
  929. $2=_st($1)._yourself();
  930. node=$2;
  931. self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  932. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  933. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  934. smalltalk.ScopeVarTest);
  935. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  936. smalltalk.addMethod(
  937. smalltalk.method({
  938. selector: "setUp",
  939. fn: function (){
  940. var self=this;
  941. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  942. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  943. return smalltalk.withContext(function($ctx1) {
  944. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  945. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  946. messageSends: ["on:"]}),
  947. smalltalk.SemanticAnalyzerTest);
  948. smalltalk.addMethod(
  949. smalltalk.method({
  950. selector: "testAssignment",
  951. fn: function (){
  952. var self=this;
  953. var src,ast;
  954. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  955. return smalltalk.withContext(function($ctx1) {
  956. src="foo self := 1";
  957. ast=_st(smalltalk)._parse_(src);
  958. self._should_raise_((function(){
  959. return smalltalk.withContext(function($ctx2) {
  960. return _st(self["@analyzer"])._visit_(ast);
  961. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$InvalidAssignmentError());
  962. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  963. messageSends: ["parse:", "should:raise:", "visit:"]}),
  964. smalltalk.SemanticAnalyzerTest);
  965. smalltalk.addMethod(
  966. smalltalk.method({
  967. selector: "testNonLocalReturn",
  968. fn: function (){
  969. var self=this;
  970. var src,ast;
  971. return smalltalk.withContext(function($ctx1) {
  972. src="foo | a | a + 1. ^ a";
  973. ast=_st(smalltalk)._parse_(src);
  974. _st(self["@analyzer"])._visit_(ast);
  975. self._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  976. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  977. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  978. smalltalk.SemanticAnalyzerTest);
  979. smalltalk.addMethod(
  980. smalltalk.method({
  981. selector: "testNonLocalReturn2",
  982. fn: function (){
  983. var self=this;
  984. var src,ast;
  985. return smalltalk.withContext(function($ctx1) {
  986. src="foo | a | a + 1. [ [ ^ a] ]";
  987. ast=_st(smalltalk)._parse_(src);
  988. _st(self["@analyzer"])._visit_(ast);
  989. self._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  990. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  991. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  992. smalltalk.SemanticAnalyzerTest);
  993. smalltalk.addMethod(
  994. smalltalk.method({
  995. selector: "testScope",
  996. fn: function (){
  997. var self=this;
  998. var src,ast;
  999. return smalltalk.withContext(function($ctx1) {
  1000. src="foo | a | a + 1. [ | b | b := a ]";
  1001. ast=_st(smalltalk)._parse_(src);
  1002. _st(self["@analyzer"])._visit_(ast);
  1003. self._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  1004. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1005. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  1006. smalltalk.SemanticAnalyzerTest);
  1007. smalltalk.addMethod(
  1008. smalltalk.method({
  1009. selector: "testScope2",
  1010. fn: function (){
  1011. var self=this;
  1012. var src,ast;
  1013. return smalltalk.withContext(function($ctx1) {
  1014. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1015. ast=_st(smalltalk)._parse_(src);
  1016. _st(self["@analyzer"])._visit_(ast);
  1017. 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()));
  1018. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1019. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  1020. smalltalk.SemanticAnalyzerTest);
  1021. smalltalk.addMethod(
  1022. smalltalk.method({
  1023. selector: "testScopeLevel",
  1024. fn: function (){
  1025. var self=this;
  1026. var src,ast;
  1027. return smalltalk.withContext(function($ctx1) {
  1028. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1029. ast=_st(smalltalk)._parse_(src);
  1030. _st(self["@analyzer"])._visit_(ast);
  1031. self._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  1032. 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));
  1033. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1034. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  1035. smalltalk.SemanticAnalyzerTest);
  1036. smalltalk.addMethod(
  1037. smalltalk.method({
  1038. selector: "testUnknownVariables",
  1039. fn: function (){
  1040. var self=this;
  1041. var src,ast;
  1042. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1043. return smalltalk.withContext(function($ctx1) {
  1044. src="foo | a | b + a";
  1045. ast=_st(smalltalk)._parse_(src);
  1046. self._should_raise_((function(){
  1047. return smalltalk.withContext(function($ctx2) {
  1048. return _st(self["@analyzer"])._visit_(ast);
  1049. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  1050. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1051. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1052. smalltalk.SemanticAnalyzerTest);
  1053. smalltalk.addMethod(
  1054. smalltalk.method({
  1055. selector: "testUnknownVariablesWithScope",
  1056. fn: function (){
  1057. var self=this;
  1058. var src,ast;
  1059. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1060. return smalltalk.withContext(function($ctx1) {
  1061. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  1062. ast=_st(smalltalk)._parse_(src);
  1063. self._should_raise_((function(){
  1064. return smalltalk.withContext(function($ctx2) {
  1065. return _st(self["@analyzer"])._visit_(ast);
  1066. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  1067. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1068. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1069. smalltalk.SemanticAnalyzerTest);
  1070. smalltalk.addMethod(
  1071. smalltalk.method({
  1072. selector: "testVariableShadowing",
  1073. fn: function (){
  1074. var self=this;
  1075. var src,ast;
  1076. return smalltalk.withContext(function($ctx1) {
  1077. src="foo | a | a + 1";
  1078. ast=_st(smalltalk)._parse_(src);
  1079. _st(self["@analyzer"])._visit_(ast);
  1080. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1081. messageSends: ["parse:", "visit:"]}),
  1082. smalltalk.SemanticAnalyzerTest);
  1083. smalltalk.addMethod(
  1084. smalltalk.method({
  1085. selector: "testVariableShadowing2",
  1086. fn: function (){
  1087. var self=this;
  1088. var src,ast;
  1089. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1090. return smalltalk.withContext(function($ctx1) {
  1091. src="foo | a | a + 1. [ | a | a := 2 ]";
  1092. ast=_st(smalltalk)._parse_(src);
  1093. self._should_raise_((function(){
  1094. return smalltalk.withContext(function($ctx2) {
  1095. return _st(self["@analyzer"])._visit_(ast);
  1096. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1097. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1098. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1099. smalltalk.SemanticAnalyzerTest);
  1100. smalltalk.addMethod(
  1101. smalltalk.method({
  1102. selector: "testVariableShadowing3",
  1103. fn: function (){
  1104. var self=this;
  1105. var src,ast;
  1106. return smalltalk.withContext(function($ctx1) {
  1107. src="foo | a | a + 1. [ | b | b := 2 ]";
  1108. ast=_st(smalltalk)._parse_(src);
  1109. _st(self["@analyzer"])._visit_(ast);
  1110. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1111. messageSends: ["parse:", "visit:"]}),
  1112. smalltalk.SemanticAnalyzerTest);
  1113. smalltalk.addMethod(
  1114. smalltalk.method({
  1115. selector: "testVariableShadowing4",
  1116. fn: function (){
  1117. var self=this;
  1118. var src,ast;
  1119. return smalltalk.withContext(function($ctx1) {
  1120. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1121. ast=_st(smalltalk)._parse_(src);
  1122. _st(self["@analyzer"])._visit_(ast);
  1123. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1124. messageSends: ["parse:", "visit:"]}),
  1125. smalltalk.SemanticAnalyzerTest);
  1126. smalltalk.addMethod(
  1127. smalltalk.method({
  1128. selector: "testVariableShadowing5",
  1129. fn: function (){
  1130. var self=this;
  1131. var src,ast;
  1132. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1133. return smalltalk.withContext(function($ctx1) {
  1134. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1135. ast=_st(smalltalk)._parse_(src);
  1136. self._should_raise_((function(){
  1137. return smalltalk.withContext(function($ctx2) {
  1138. return _st(self["@analyzer"])._visit_(ast);
  1139. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1140. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1141. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1142. smalltalk.SemanticAnalyzerTest);
  1143. smalltalk.addMethod(
  1144. smalltalk.method({
  1145. selector: "testVariablesLookup",
  1146. fn: function (){
  1147. var self=this;
  1148. var src,ast;
  1149. return smalltalk.withContext(function($ctx1) {
  1150. src="foo | a | a + 1. [ | b | b := a ]";
  1151. ast=_st(smalltalk)._parse_(src);
  1152. _st(self["@analyzer"])._visit_(ast);
  1153. self._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1154. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1155. 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());
  1156. 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()));
  1157. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1158. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  1159. smalltalk.SemanticAnalyzerTest);
  1160. });