2
0

Compiler-Tests.js 68 KB

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