Compiler-Tests.deploy.js 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496
  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)})}));
  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._fromPairs_([(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._fromPairs_(["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._fromPairs_([])),(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._fromPairs_(["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._fromPairs_([])),(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;
  459. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  460. return smalltalk.withContext(function($ctx1) {
  461. var $2,$3,$1;
  462. ctx=_st($AIContext())._new();
  463. _st(ctx)._receiver_(anObject);
  464. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  465. return smalltalk.withContext(function($ctx2) {
  466. return _st(ctx)._localAt_put_(key,value);
  467. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  468. $2=self._interpreter();
  469. _st($2)._context_(ctx);
  470. _st($2)._interpret_(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nextChild());
  471. _st($2)._proceed();
  472. $3=_st($2)._result();
  473. $1=$3;
  474. return $1;
  475. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx},smalltalk.InterpreterTest)})},
  476. messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "nextChild", "parse:forClass:", "class", "proceed", "result"]}),
  477. smalltalk.InterpreterTest);
  478. smalltalk.addMethod(
  479. smalltalk.method({
  480. selector: "interpreter",
  481. fn: function (){
  482. var self=this;
  483. function $Interpreter(){return smalltalk.Interpreter||(typeof Interpreter=="undefined"?nil:Interpreter)}
  484. return smalltalk.withContext(function($ctx1) {
  485. var $1;
  486. $1=_st($Interpreter())._new();
  487. return $1;
  488. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.InterpreterTest)})},
  489. messageSends: ["new"]}),
  490. smalltalk.InterpreterTest);
  491. smalltalk.addMethod(
  492. smalltalk.method({
  493. selector: "testBinarySend",
  494. fn: function (){
  495. var self=this;
  496. return smalltalk.withContext(function($ctx1) {
  497. self._assert_equals_(self._interpret_("foo ^ 2+3+4"),(9));
  498. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.InterpreterTest)})},
  499. messageSends: ["assert:equals:", "interpret:"]}),
  500. smalltalk.InterpreterTest);
  501. smalltalk.addMethod(
  502. smalltalk.method({
  503. selector: "testBlockLiteral",
  504. fn: function (){
  505. var self=this;
  506. return smalltalk.withContext(function($ctx1) {
  507. self._assert_equals_(self._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  508. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  509. self._assert_equals_(self._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  510. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.InterpreterTest)})},
  511. messageSends: ["assert:equals:", "interpret:"]}),
  512. smalltalk.InterpreterTest);
  513. smalltalk.addMethod(
  514. smalltalk.method({
  515. selector: "testCascade",
  516. fn: function (){
  517. var self=this;
  518. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  519. return smalltalk.withContext(function($ctx1) {
  520. self._assert_equals_(self._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  521. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.InterpreterTest)})},
  522. messageSends: ["assert:equals:", "interpret:", "with:with:"]}),
  523. smalltalk.InterpreterTest);
  524. smalltalk.addMethod(
  525. smalltalk.method({
  526. selector: "testDynamicArray",
  527. fn: function (){
  528. var self=this;
  529. return smalltalk.withContext(function($ctx1) {
  530. self._assert_equals_(self._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  531. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.InterpreterTest)})},
  532. messageSends: ["assert:equals:", "interpret:"]}),
  533. smalltalk.InterpreterTest);
  534. smalltalk.addMethod(
  535. smalltalk.method({
  536. selector: "testDynamicDictionary",
  537. fn: function (){
  538. var self=this;
  539. return smalltalk.withContext(function($ctx1) {
  540. self._assert_equals_(self._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._fromPairs_([(1).__minus_gt((1)),(2).__minus_gt((3))]));
  541. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.InterpreterTest)})},
  542. messageSends: ["assert:equals:", "interpret:", "->"]}),
  543. smalltalk.InterpreterTest);
  544. smalltalk.addMethod(
  545. smalltalk.method({
  546. selector: "testInlinedJSStatement",
  547. fn: function (){
  548. var self=this;
  549. return smalltalk.withContext(function($ctx1) {
  550. self._assert_equals_(self._interpret_("foo <return 2+3>"),(5));
  551. self._assert_equals_(self._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._fromPairs_(["anInteger".__minus_gt((3))])),(5));
  552. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.InterpreterTest)})},
  553. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"]}),
  554. smalltalk.InterpreterTest);
  555. smalltalk.addMethod(
  556. smalltalk.method({
  557. selector: "testInstVarAccess",
  558. fn: function (){
  559. var self=this;
  560. return smalltalk.withContext(function($ctx1) {
  561. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ x",(2).__at((3)),smalltalk.HashedCollection._fromPairs_([])),(2));
  562. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.InterpreterTest)})},
  563. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  564. smalltalk.InterpreterTest);
  565. smalltalk.addMethod(
  566. smalltalk.method({
  567. selector: "testInstVarAssignment",
  568. fn: function (){
  569. var self=this;
  570. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  571. return smalltalk.withContext(function($ctx1) {
  572. self._assert_equals_(self._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._fromPairs_(["anInteger".__minus_gt((2))])),(2));
  573. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.InterpreterTest)})},
  574. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"]}),
  575. smalltalk.InterpreterTest);
  576. smalltalk.addMethod(
  577. smalltalk.method({
  578. selector: "testKeywordSend",
  579. fn: function (){
  580. var self=this;
  581. return smalltalk.withContext(function($ctx1) {
  582. self._assert_equals_(self._interpret_("foo ^ Point x: 1 y: 2"),(1).__at((2)));
  583. return self}, function($ctx1) {$ctx1.fill(self,"testKeywordSend",{},smalltalk.InterpreterTest)})},
  584. messageSends: ["assert:equals:", "interpret:", "@"]}),
  585. smalltalk.InterpreterTest);
  586. smalltalk.addMethod(
  587. smalltalk.method({
  588. selector: "testMultipleSequences",
  589. fn: function (){
  590. var self=this;
  591. return smalltalk.withContext(function($ctx1) {
  592. self._assert_equals_(self._interpret_("foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6"),(30));
  593. return self}, function($ctx1) {$ctx1.fill(self,"testMultipleSequences",{},smalltalk.InterpreterTest)})},
  594. messageSends: ["assert:equals:", "interpret:"]}),
  595. smalltalk.InterpreterTest);
  596. smalltalk.addMethod(
  597. smalltalk.method({
  598. selector: "testNestedSends",
  599. fn: function (){
  600. var self=this;
  601. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  602. return smalltalk.withContext(function($ctx1) {
  603. 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());
  604. return self}, function($ctx1) {$ctx1.fill(self,"testNestedSends",{},smalltalk.InterpreterTest)})},
  605. messageSends: ["assert:equals:", "interpret:", "asString", "x:y:", "@"]}),
  606. smalltalk.InterpreterTest);
  607. smalltalk.addMethod(
  608. smalltalk.method({
  609. selector: "testNonlocalReturn",
  610. fn: function (){
  611. var self=this;
  612. return smalltalk.withContext(function($ctx1) {
  613. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  614. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.InterpreterTest)})},
  615. messageSends: ["assert:equals:", "interpret:"]}),
  616. smalltalk.InterpreterTest);
  617. smalltalk.addMethod(
  618. smalltalk.method({
  619. selector: "testReceiver",
  620. fn: function (){
  621. var self=this;
  622. return smalltalk.withContext(function($ctx1) {
  623. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ self",(2).__at((3)),smalltalk.HashedCollection._fromPairs_([])),(2).__at((3)));
  624. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.InterpreterTest)})},
  625. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  626. smalltalk.InterpreterTest);
  627. smalltalk.addMethod(
  628. smalltalk.method({
  629. selector: "testSuper",
  630. fn: function (){
  631. var self=this;
  632. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  633. return smalltalk.withContext(function($ctx1) {
  634. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ super isBoolean",true,_st($Dictionary())._new()),false);
  635. return self}, function($ctx1) {$ctx1.fill(self,"testSuper",{},smalltalk.InterpreterTest)})},
  636. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new"]}),
  637. smalltalk.InterpreterTest);
  638. smalltalk.addMethod(
  639. smalltalk.method({
  640. selector: "testTempAssignment",
  641. fn: function (){
  642. var self=this;
  643. return smalltalk.withContext(function($ctx1) {
  644. self._assert_equals_(self._interpret_("foo | a | a := 2. ^ a"),(2));
  645. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.InterpreterTest)})},
  646. messageSends: ["assert:equals:", "interpret:"]}),
  647. smalltalk.InterpreterTest);
  648. smalltalk.addMethod(
  649. smalltalk.method({
  650. selector: "testThisContext",
  651. fn: function (){
  652. var self=this;
  653. return smalltalk.withContext(function($ctx1) {
  654. self._assert_(_st(_st(self._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  655. self._assert_(_st(_st(self._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  656. self._assert_(self._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  657. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.InterpreterTest)})},
  658. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
  659. smalltalk.InterpreterTest);
  660. smalltalk.addMethod(
  661. smalltalk.method({
  662. selector: "testUnarySend",
  663. fn: function (){
  664. var self=this;
  665. return smalltalk.withContext(function($ctx1) {
  666. self._assert_equals_(self._interpret_("foo ^ 1 asString"),"1");
  667. return self}, function($ctx1) {$ctx1.fill(self,"testUnarySend",{},smalltalk.InterpreterTest)})},
  668. messageSends: ["assert:equals:", "interpret:"]}),
  669. smalltalk.InterpreterTest);
  670. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  671. smalltalk.addMethod(
  672. smalltalk.method({
  673. selector: "codeGeneratorClass",
  674. fn: function (){
  675. var self=this;
  676. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  677. return smalltalk.withContext(function($ctx1) {
  678. var $1;
  679. $1=$CodeGenerator();
  680. return $1;
  681. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  682. messageSends: []}),
  683. smalltalk.CodeGeneratorTest);
  684. smalltalk.addMethod(
  685. smalltalk.method({
  686. selector: "compiler",
  687. fn: function (){
  688. var self=this;
  689. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  690. return smalltalk.withContext(function($ctx1) {
  691. var $2,$3,$1;
  692. $2=_st($Compiler())._new();
  693. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  694. $3=_st($2)._yourself();
  695. $1=$3;
  696. return $1;
  697. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  698. messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"]}),
  699. smalltalk.CodeGeneratorTest);
  700. smalltalk.addMethod(
  701. smalltalk.method({
  702. selector: "setUp",
  703. fn: function (){
  704. var self=this;
  705. return smalltalk.withContext(function($ctx1) {
  706. self["@receiver"]=_st(self._targetClass())._new();
  707. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  708. messageSends: ["new", "targetClass"]}),
  709. smalltalk.CodeGeneratorTest);
  710. smalltalk.addMethod(
  711. smalltalk.method({
  712. selector: "should:return:",
  713. fn: function (aString,anObject){
  714. var self=this;
  715. var method,result;
  716. return smalltalk.withContext(function($ctx1) {
  717. method=_st(self._compiler())._install_forClass_category_(aString,self._targetClass(),"tests");
  718. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  719. _st(self._targetClass())._removeCompiledMethod_(method);
  720. self._assert_equals_(anObject,result);
  721. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  722. messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"]}),
  723. smalltalk.CodeGeneratorTest);
  724. smalltalk.addMethod(
  725. smalltalk.method({
  726. selector: "targetClass",
  727. fn: function (){
  728. var self=this;
  729. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  730. return smalltalk.withContext(function($ctx1) {
  731. var $1;
  732. $1=$DoIt();
  733. return $1;
  734. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  735. messageSends: []}),
  736. smalltalk.CodeGeneratorTest);
  737. smalltalk.addMethod(
  738. smalltalk.method({
  739. selector: "tearDown",
  740. fn: function (){
  741. var self=this;
  742. return smalltalk.withContext(function($ctx1) {
  743. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  744. messageSends: []}),
  745. smalltalk.CodeGeneratorTest);
  746. smalltalk.addMethod(
  747. smalltalk.method({
  748. selector: "testAssignment",
  749. fn: function (){
  750. var self=this;
  751. return smalltalk.withContext(function($ctx1) {
  752. self._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  753. self._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  754. self._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  755. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  756. messageSends: ["should:return:"]}),
  757. smalltalk.CodeGeneratorTest);
  758. smalltalk.addMethod(
  759. smalltalk.method({
  760. selector: "testBackslashSelectors",
  761. fn: function (){
  762. var self=this;
  763. return smalltalk.withContext(function($ctx1) {
  764. self._should_return_("\x5c arg ^ 4",(4));
  765. self._should_return_("\x5c\x5c arg ^ 42",(42));
  766. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  767. messageSends: ["should:return:"]}),
  768. smalltalk.CodeGeneratorTest);
  769. smalltalk.addMethod(
  770. smalltalk.method({
  771. selector: "testBlockReturn",
  772. fn: function (){
  773. var self=this;
  774. return smalltalk.withContext(function($ctx1) {
  775. self._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  776. self._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  777. self._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  778. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  779. messageSends: ["should:return:"]}),
  780. smalltalk.CodeGeneratorTest);
  781. smalltalk.addMethod(
  782. smalltalk.method({
  783. selector: "testCascades",
  784. fn: function (){
  785. var self=this;
  786. return smalltalk.withContext(function($ctx1) {
  787. self._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  788. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  789. messageSends: ["should:return:"]}),
  790. smalltalk.CodeGeneratorTest);
  791. smalltalk.addMethod(
  792. smalltalk.method({
  793. selector: "testDynamicArrayElementsOrdered",
  794. fn: function (){
  795. var self=this;
  796. return smalltalk.withContext(function($ctx1) {
  797. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  798. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  799. messageSends: ["should:return:"]}),
  800. smalltalk.CodeGeneratorTest);
  801. smalltalk.addMethod(
  802. smalltalk.method({
  803. selector: "testDynamicDictionaryElementsOrdered",
  804. fn: function (){
  805. var self=this;
  806. return smalltalk.withContext(function($ctx1) {
  807. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 'foo'->1.\x0a\x09^ #{ x. (true ifTrue: [ x := 'bar'->2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_(["foo".__minus_gt((1)),"bar".__minus_gt((2))]));
  808. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  809. messageSends: ["should:return:", "->"]}),
  810. smalltalk.CodeGeneratorTest);
  811. smalltalk.addMethod(
  812. smalltalk.method({
  813. selector: "testInnerTemporalDependentElementsOrdered",
  814. fn: function (){
  815. var self=this;
  816. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  817. return smalltalk.withContext(function($ctx1) {
  818. 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))]);
  819. 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))]);
  820. 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))]);
  821. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_(["foo".__minus_gt((1)),"bar".__minus_gt((2))]));
  822. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  823. messageSends: ["should:return:", "->"]}),
  824. smalltalk.CodeGeneratorTest);
  825. smalltalk.addMethod(
  826. smalltalk.method({
  827. selector: "testLiterals",
  828. fn: function (){
  829. var self=this;
  830. return smalltalk.withContext(function($ctx1) {
  831. self._should_return_("foo ^ 1",(1));
  832. self._should_return_("foo ^ 'hello'","hello");
  833. self._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  834. self._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  835. self._should_return_("foo ^ true",true);
  836. self._should_return_("foo ^ false",false);
  837. self._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([(1).__minus_gt((2)),(3).__minus_gt((4))]));
  838. self._should_return_("foo ^ #hello","hello");
  839. self._should_return_("foo ^ -123.456",(-123.456));
  840. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  841. messageSends: ["should:return:", "->"]}),
  842. smalltalk.CodeGeneratorTest);
  843. smalltalk.addMethod(
  844. smalltalk.method({
  845. selector: "testLocalReturn",
  846. fn: function (){
  847. var self=this;
  848. return smalltalk.withContext(function($ctx1) {
  849. self._should_return_("foo ^ 1",(1));
  850. self._should_return_("foo ^ 1 + 1",(2));
  851. self._should_return_("foo ",self["@receiver"]);
  852. self._should_return_("foo self asString",self["@receiver"]);
  853. self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  854. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  855. messageSends: ["should:return:"]}),
  856. smalltalk.CodeGeneratorTest);
  857. smalltalk.addMethod(
  858. smalltalk.method({
  859. selector: "testMessageSends",
  860. fn: function (){
  861. var self=this;
  862. return smalltalk.withContext(function($ctx1) {
  863. self._should_return_("foo ^ 1 asString","1");
  864. self._should_return_("foo ^ 1 + 1",(2));
  865. self._should_return_("foo ^ 1 + 2 * 3",(9));
  866. self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  867. self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  868. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  869. messageSends: ["should:return:"]}),
  870. smalltalk.CodeGeneratorTest);
  871. smalltalk.addMethod(
  872. smalltalk.method({
  873. selector: "testMutableLiterals",
  874. fn: function (){
  875. var self=this;
  876. return smalltalk.withContext(function($ctx1) {
  877. self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  878. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  879. messageSends: ["should:return:"]}),
  880. smalltalk.CodeGeneratorTest);
  881. smalltalk.addMethod(
  882. smalltalk.method({
  883. selector: "testNestedIfTrue",
  884. fn: function (){
  885. var self=this;
  886. return smalltalk.withContext(function($ctx1) {
  887. self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  888. self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  889. self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  890. self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  891. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  892. messageSends: ["should:return:"]}),
  893. smalltalk.CodeGeneratorTest);
  894. smalltalk.addMethod(
  895. smalltalk.method({
  896. selector: "testNonLocalReturn",
  897. fn: function (){
  898. var self=this;
  899. return smalltalk.withContext(function($ctx1) {
  900. self._should_return_("foo [ ^ 1 ] value",(1));
  901. self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  902. self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  903. self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  904. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  905. messageSends: ["should:return:"]}),
  906. smalltalk.CodeGeneratorTest);
  907. smalltalk.addMethod(
  908. smalltalk.method({
  909. selector: "testPascalCaseGlobal",
  910. fn: function (){
  911. var self=this;
  912. return smalltalk.withContext(function($ctx1) {
  913. self._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  914. self._should_return_("foo ^NonExistent",nil);
  915. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  916. messageSends: ["should:return:", "at:"]}),
  917. smalltalk.CodeGeneratorTest);
  918. smalltalk.addMethod(
  919. smalltalk.method({
  920. selector: "testSendReceiverAndArgumentsOrdered",
  921. fn: function (){
  922. var self=this;
  923. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  924. return smalltalk.withContext(function($ctx1) {
  925. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  926. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  927. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  928. messageSends: ["should:return:"]}),
  929. smalltalk.CodeGeneratorTest);
  930. smalltalk.addMethod(
  931. smalltalk.method({
  932. selector: "testifFalse",
  933. fn: function (){
  934. var self=this;
  935. return smalltalk.withContext(function($ctx1) {
  936. self._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  937. self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  938. self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  939. self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  940. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  941. messageSends: ["should:return:"]}),
  942. smalltalk.CodeGeneratorTest);
  943. smalltalk.addMethod(
  944. smalltalk.method({
  945. selector: "testifFalseIfTrue",
  946. fn: function (){
  947. var self=this;
  948. return smalltalk.withContext(function($ctx1) {
  949. self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  950. self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  951. self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  952. self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  953. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  954. messageSends: ["should:return:"]}),
  955. smalltalk.CodeGeneratorTest);
  956. smalltalk.addMethod(
  957. smalltalk.method({
  958. selector: "testifNil",
  959. fn: function (){
  960. var self=this;
  961. return smalltalk.withContext(function($ctx1) {
  962. self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  963. self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  964. self._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  965. self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  966. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  967. messageSends: ["should:return:"]}),
  968. smalltalk.CodeGeneratorTest);
  969. smalltalk.addMethod(
  970. smalltalk.method({
  971. selector: "testifNilIfNotNil",
  972. fn: function (){
  973. var self=this;
  974. return smalltalk.withContext(function($ctx1) {
  975. self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  976. self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  977. self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  978. self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  979. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  980. messageSends: ["should:return:"]}),
  981. smalltalk.CodeGeneratorTest);
  982. smalltalk.addMethod(
  983. smalltalk.method({
  984. selector: "testifNotNil",
  985. fn: function (){
  986. var self=this;
  987. return smalltalk.withContext(function($ctx1) {
  988. self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  989. self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  990. self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  991. self._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  992. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  993. messageSends: ["should:return:"]}),
  994. smalltalk.CodeGeneratorTest);
  995. smalltalk.addMethod(
  996. smalltalk.method({
  997. selector: "testifNotNilWithArgument",
  998. fn: function (){
  999. var self=this;
  1000. return smalltalk.withContext(function($ctx1) {
  1001. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  1002. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  1003. self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  1004. self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  1005. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  1006. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  1007. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  1008. messageSends: ["should:return:"]}),
  1009. smalltalk.CodeGeneratorTest);
  1010. smalltalk.addMethod(
  1011. smalltalk.method({
  1012. selector: "testifTrue",
  1013. fn: function (){
  1014. var self=this;
  1015. return smalltalk.withContext(function($ctx1) {
  1016. self._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  1017. self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  1018. self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  1019. self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  1020. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  1021. messageSends: ["should:return:"]}),
  1022. smalltalk.CodeGeneratorTest);
  1023. smalltalk.addMethod(
  1024. smalltalk.method({
  1025. selector: "testifTrueIfFalse",
  1026. fn: function (){
  1027. var self=this;
  1028. return smalltalk.withContext(function($ctx1) {
  1029. self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  1030. self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  1031. self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  1032. self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  1033. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  1034. messageSends: ["should:return:"]}),
  1035. smalltalk.CodeGeneratorTest);
  1036. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  1037. smalltalk.addMethod(
  1038. smalltalk.method({
  1039. selector: "codeGeneratorClass",
  1040. fn: function (){
  1041. var self=this;
  1042. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  1043. return smalltalk.withContext(function($ctx1) {
  1044. var $1;
  1045. $1=$InliningCodeGenerator();
  1046. return $1;
  1047. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  1048. messageSends: []}),
  1049. smalltalk.InliningCodeGeneratorTest);
  1050. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  1051. smalltalk.addMethod(
  1052. smalltalk.method({
  1053. selector: "testClassRefVar",
  1054. fn: function (){
  1055. var self=this;
  1056. var node;
  1057. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  1058. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1059. return smalltalk.withContext(function($ctx1) {
  1060. var $1,$2;
  1061. $1=_st($ClassReferenceNode())._new();
  1062. _st($1)._value_("Object");
  1063. $2=_st($1)._yourself();
  1064. node=$2;
  1065. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  1066. self._assert_(_st(_st(node)._binding())._isClassRefVar());
  1067. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  1068. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  1069. smalltalk.ScopeVarTest);
  1070. smalltalk.addMethod(
  1071. smalltalk.method({
  1072. selector: "testInstanceVar",
  1073. fn: function (){
  1074. var self=this;
  1075. var node,scope;
  1076. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1077. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1078. return smalltalk.withContext(function($ctx1) {
  1079. var $1,$2;
  1080. $1=_st($VariableNode())._new();
  1081. _st($1)._value_("bzzz");
  1082. $2=_st($1)._yourself();
  1083. node=$2;
  1084. scope=_st($MethodLexicalScope())._new();
  1085. _st(scope)._addIVar_("bzzz");
  1086. self._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  1087. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1088. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  1089. smalltalk.ScopeVarTest);
  1090. smalltalk.addMethod(
  1091. smalltalk.method({
  1092. selector: "testPseudoVar",
  1093. fn: function (){
  1094. var self=this;
  1095. var node,pseudoVars;
  1096. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1097. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1098. return smalltalk.withContext(function($ctx1) {
  1099. var $1,$2;
  1100. pseudoVars=["self", "super", "true", "false", "nil"];
  1101. _st(pseudoVars)._do_((function(each){
  1102. return smalltalk.withContext(function($ctx2) {
  1103. $1=_st($VariableNode())._new();
  1104. _st($1)._value_(each);
  1105. $2=_st($1)._yourself();
  1106. node=$2;
  1107. node;
  1108. return self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  1109. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1110. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  1111. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  1112. smalltalk.ScopeVarTest);
  1113. smalltalk.addMethod(
  1114. smalltalk.method({
  1115. selector: "testTempVar",
  1116. fn: function (){
  1117. var self=this;
  1118. var node,scope;
  1119. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1120. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1121. return smalltalk.withContext(function($ctx1) {
  1122. var $1,$2;
  1123. $1=_st($VariableNode())._new();
  1124. _st($1)._value_("bzzz");
  1125. $2=_st($1)._yourself();
  1126. node=$2;
  1127. scope=_st($MethodLexicalScope())._new();
  1128. _st(scope)._addTemp_("bzzz");
  1129. self._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  1130. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1131. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  1132. smalltalk.ScopeVarTest);
  1133. smalltalk.addMethod(
  1134. smalltalk.method({
  1135. selector: "testUnknownVar",
  1136. fn: function (){
  1137. var self=this;
  1138. var node;
  1139. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1140. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1141. return smalltalk.withContext(function($ctx1) {
  1142. var $1,$2;
  1143. $1=_st($VariableNode())._new();
  1144. _st($1)._value_("bzzz");
  1145. $2=_st($1)._yourself();
  1146. node=$2;
  1147. self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  1148. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  1149. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  1150. smalltalk.ScopeVarTest);
  1151. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  1152. smalltalk.addMethod(
  1153. smalltalk.method({
  1154. selector: "setUp",
  1155. fn: function (){
  1156. var self=this;
  1157. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1158. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1159. return smalltalk.withContext(function($ctx1) {
  1160. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  1161. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  1162. messageSends: ["on:"]}),
  1163. smalltalk.SemanticAnalyzerTest);
  1164. smalltalk.addMethod(
  1165. smalltalk.method({
  1166. selector: "testAssignment",
  1167. fn: function (){
  1168. var self=this;
  1169. var src,ast;
  1170. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  1171. return smalltalk.withContext(function($ctx1) {
  1172. src="foo self := 1";
  1173. ast=_st(smalltalk)._parse_(src);
  1174. self._should_raise_((function(){
  1175. return smalltalk.withContext(function($ctx2) {
  1176. return _st(self["@analyzer"])._visit_(ast);
  1177. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$InvalidAssignmentError());
  1178. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1179. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1180. smalltalk.SemanticAnalyzerTest);
  1181. smalltalk.addMethod(
  1182. smalltalk.method({
  1183. selector: "testNonLocalReturn",
  1184. fn: function (){
  1185. var self=this;
  1186. var src,ast;
  1187. return smalltalk.withContext(function($ctx1) {
  1188. src="foo | a | a + 1. ^ a";
  1189. ast=_st(smalltalk)._parse_(src);
  1190. _st(self["@analyzer"])._visit_(ast);
  1191. self._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1192. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1193. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  1194. smalltalk.SemanticAnalyzerTest);
  1195. smalltalk.addMethod(
  1196. smalltalk.method({
  1197. selector: "testNonLocalReturn2",
  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._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1206. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1207. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  1208. smalltalk.SemanticAnalyzerTest);
  1209. smalltalk.addMethod(
  1210. smalltalk.method({
  1211. selector: "testScope",
  1212. fn: function (){
  1213. var self=this;
  1214. var src,ast;
  1215. return smalltalk.withContext(function($ctx1) {
  1216. src="foo | a | a + 1. [ | b | b := a ]";
  1217. ast=_st(smalltalk)._parse_(src);
  1218. _st(self["@analyzer"])._visit_(ast);
  1219. self._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  1220. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1221. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  1222. smalltalk.SemanticAnalyzerTest);
  1223. smalltalk.addMethod(
  1224. smalltalk.method({
  1225. selector: "testScope2",
  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(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope()).__eq_eq(_st(ast)._scope()));
  1234. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1235. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  1236. smalltalk.SemanticAnalyzerTest);
  1237. smalltalk.addMethod(
  1238. smalltalk.method({
  1239. selector: "testScopeLevel",
  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._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  1248. 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));
  1249. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1250. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  1251. smalltalk.SemanticAnalyzerTest);
  1252. smalltalk.addMethod(
  1253. smalltalk.method({
  1254. selector: "testUnknownVariables",
  1255. fn: function (){
  1256. var self=this;
  1257. var src,ast;
  1258. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1259. return smalltalk.withContext(function($ctx1) {
  1260. src="foo | a | b + a";
  1261. ast=_st(smalltalk)._parse_(src);
  1262. self._should_raise_((function(){
  1263. return smalltalk.withContext(function($ctx2) {
  1264. return _st(self["@analyzer"])._visit_(ast);
  1265. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  1266. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1267. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1268. smalltalk.SemanticAnalyzerTest);
  1269. smalltalk.addMethod(
  1270. smalltalk.method({
  1271. selector: "testUnknownVariablesWithScope",
  1272. fn: function (){
  1273. var self=this;
  1274. var src,ast;
  1275. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1276. return smalltalk.withContext(function($ctx1) {
  1277. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  1278. ast=_st(smalltalk)._parse_(src);
  1279. self._should_raise_((function(){
  1280. return smalltalk.withContext(function($ctx2) {
  1281. return _st(self["@analyzer"])._visit_(ast);
  1282. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  1283. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1284. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1285. smalltalk.SemanticAnalyzerTest);
  1286. smalltalk.addMethod(
  1287. smalltalk.method({
  1288. selector: "testVariableShadowing",
  1289. fn: function (){
  1290. var self=this;
  1291. var src,ast;
  1292. return smalltalk.withContext(function($ctx1) {
  1293. src="foo | a | a + 1";
  1294. ast=_st(smalltalk)._parse_(src);
  1295. _st(self["@analyzer"])._visit_(ast);
  1296. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1297. messageSends: ["parse:", "visit:"]}),
  1298. smalltalk.SemanticAnalyzerTest);
  1299. smalltalk.addMethod(
  1300. smalltalk.method({
  1301. selector: "testVariableShadowing2",
  1302. fn: function (){
  1303. var self=this;
  1304. var src,ast;
  1305. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1306. return smalltalk.withContext(function($ctx1) {
  1307. src="foo | a | a + 1. [ | a | a := 2 ]";
  1308. ast=_st(smalltalk)._parse_(src);
  1309. self._should_raise_((function(){
  1310. return smalltalk.withContext(function($ctx2) {
  1311. return _st(self["@analyzer"])._visit_(ast);
  1312. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1313. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1314. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1315. smalltalk.SemanticAnalyzerTest);
  1316. smalltalk.addMethod(
  1317. smalltalk.method({
  1318. selector: "testVariableShadowing3",
  1319. fn: function (){
  1320. var self=this;
  1321. var src,ast;
  1322. return smalltalk.withContext(function($ctx1) {
  1323. src="foo | a | a + 1. [ | b | b := 2 ]";
  1324. ast=_st(smalltalk)._parse_(src);
  1325. _st(self["@analyzer"])._visit_(ast);
  1326. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1327. messageSends: ["parse:", "visit:"]}),
  1328. smalltalk.SemanticAnalyzerTest);
  1329. smalltalk.addMethod(
  1330. smalltalk.method({
  1331. selector: "testVariableShadowing4",
  1332. fn: function (){
  1333. var self=this;
  1334. var src,ast;
  1335. return smalltalk.withContext(function($ctx1) {
  1336. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1337. ast=_st(smalltalk)._parse_(src);
  1338. _st(self["@analyzer"])._visit_(ast);
  1339. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1340. messageSends: ["parse:", "visit:"]}),
  1341. smalltalk.SemanticAnalyzerTest);
  1342. smalltalk.addMethod(
  1343. smalltalk.method({
  1344. selector: "testVariableShadowing5",
  1345. fn: function (){
  1346. var self=this;
  1347. var src,ast;
  1348. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1349. return smalltalk.withContext(function($ctx1) {
  1350. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1351. ast=_st(smalltalk)._parse_(src);
  1352. self._should_raise_((function(){
  1353. return smalltalk.withContext(function($ctx2) {
  1354. return _st(self["@analyzer"])._visit_(ast);
  1355. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1356. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1357. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1358. smalltalk.SemanticAnalyzerTest);
  1359. smalltalk.addMethod(
  1360. smalltalk.method({
  1361. selector: "testVariablesLookup",
  1362. fn: function (){
  1363. var self=this;
  1364. var src,ast;
  1365. return smalltalk.withContext(function($ctx1) {
  1366. src="foo | a | a + 1. [ | b | b := a ]";
  1367. ast=_st(smalltalk)._parse_(src);
  1368. _st(self["@analyzer"])._visit_(ast);
  1369. self._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1370. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1371. 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());
  1372. 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()));
  1373. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1374. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  1375. smalltalk.SemanticAnalyzerTest);