Compiler-Tests.deploy.js 60 KB

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