Compiler-Tests.deploy.js 62 KB

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