1
0

Compiler-Tests.deploy.js 51 KB

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