1
0

Compiler-Tests.js 50 KB

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