1
0

Compiler-Tests.deploy.js 62 KB

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