Compiler-Tests.js 67 KB

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