Compiler-Tests.deploy.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507
  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._from_([(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._from_(["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._from_([])),(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._from_(["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._from_([])),(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: "testGlobalVar",
  547. fn: function (){
  548. var self=this;
  549. return smalltalk.withContext(function($ctx1) {
  550. self._assert_equals_(self._interpret_("foo ^ window document title"),_st(_st(window)._document())._title());
  551. return self}, function($ctx1) {$ctx1.fill(self,"testGlobalVar",{},smalltalk.InterpreterTest)})},
  552. messageSends: ["assert:equals:", "interpret:", "title", "document"]}),
  553. smalltalk.InterpreterTest);
  554. smalltalk.addMethod(
  555. smalltalk.method({
  556. selector: "testInlinedJSStatement",
  557. fn: function (){
  558. var self=this;
  559. return smalltalk.withContext(function($ctx1) {
  560. self._assert_equals_(self._interpret_("foo <return 2+3>"),(5));
  561. self._assert_equals_(self._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._fromPairs_(["anInteger".__minus_gt((3))])),(5));
  562. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.InterpreterTest)})},
  563. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"]}),
  564. smalltalk.InterpreterTest);
  565. smalltalk.addMethod(
  566. smalltalk.method({
  567. selector: "testInstVarAccess",
  568. fn: function (){
  569. var self=this;
  570. return smalltalk.withContext(function($ctx1) {
  571. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ x",(2).__at((3)),smalltalk.HashedCollection._fromPairs_([])),(2));
  572. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.InterpreterTest)})},
  573. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  574. smalltalk.InterpreterTest);
  575. smalltalk.addMethod(
  576. smalltalk.method({
  577. selector: "testInstVarAssignment",
  578. fn: function (){
  579. var self=this;
  580. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  581. return smalltalk.withContext(function($ctx1) {
  582. self._assert_equals_(self._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._fromPairs_(["anInteger".__minus_gt((2))])),(2));
  583. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.InterpreterTest)})},
  584. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"]}),
  585. smalltalk.InterpreterTest);
  586. smalltalk.addMethod(
  587. smalltalk.method({
  588. selector: "testKeywordSend",
  589. fn: function (){
  590. var self=this;
  591. return smalltalk.withContext(function($ctx1) {
  592. self._assert_equals_(self._interpret_("foo ^ Point x: 1 y: 2"),(1).__at((2)));
  593. return self}, function($ctx1) {$ctx1.fill(self,"testKeywordSend",{},smalltalk.InterpreterTest)})},
  594. messageSends: ["assert:equals:", "interpret:", "@"]}),
  595. smalltalk.InterpreterTest);
  596. smalltalk.addMethod(
  597. smalltalk.method({
  598. selector: "testMultipleSequences",
  599. fn: function (){
  600. var self=this;
  601. return smalltalk.withContext(function($ctx1) {
  602. self._assert_equals_(self._interpret_("foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6"),(30));
  603. return self}, function($ctx1) {$ctx1.fill(self,"testMultipleSequences",{},smalltalk.InterpreterTest)})},
  604. messageSends: ["assert:equals:", "interpret:"]}),
  605. smalltalk.InterpreterTest);
  606. smalltalk.addMethod(
  607. smalltalk.method({
  608. selector: "testNestedSends",
  609. fn: function (){
  610. var self=this;
  611. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  612. return smalltalk.withContext(function($ctx1) {
  613. 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());
  614. return self}, function($ctx1) {$ctx1.fill(self,"testNestedSends",{},smalltalk.InterpreterTest)})},
  615. messageSends: ["assert:equals:", "interpret:", "asString", "x:y:", "@"]}),
  616. smalltalk.InterpreterTest);
  617. smalltalk.addMethod(
  618. smalltalk.method({
  619. selector: "testNonlocalReturn",
  620. fn: function (){
  621. var self=this;
  622. return smalltalk.withContext(function($ctx1) {
  623. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  624. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.InterpreterTest)})},
  625. messageSends: ["assert:equals:", "interpret:"]}),
  626. smalltalk.InterpreterTest);
  627. smalltalk.addMethod(
  628. smalltalk.method({
  629. selector: "testReceiver",
  630. fn: function (){
  631. var self=this;
  632. return smalltalk.withContext(function($ctx1) {
  633. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ self",(2).__at((3)),smalltalk.HashedCollection._fromPairs_([])),(2).__at((3)));
  634. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.InterpreterTest)})},
  635. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  636. smalltalk.InterpreterTest);
  637. smalltalk.addMethod(
  638. smalltalk.method({
  639. selector: "testSuper",
  640. fn: function (){
  641. var self=this;
  642. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  643. return smalltalk.withContext(function($ctx1) {
  644. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ super isBoolean",true,_st($Dictionary())._new()),false);
  645. return self}, function($ctx1) {$ctx1.fill(self,"testSuper",{},smalltalk.InterpreterTest)})},
  646. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new"]}),
  647. smalltalk.InterpreterTest);
  648. smalltalk.addMethod(
  649. smalltalk.method({
  650. selector: "testTempAssignment",
  651. fn: function (){
  652. var self=this;
  653. return smalltalk.withContext(function($ctx1) {
  654. self._assert_equals_(self._interpret_("foo | a | a := 2. ^ a"),(2));
  655. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.InterpreterTest)})},
  656. messageSends: ["assert:equals:", "interpret:"]}),
  657. smalltalk.InterpreterTest);
  658. smalltalk.addMethod(
  659. smalltalk.method({
  660. selector: "testThisContext",
  661. fn: function (){
  662. var self=this;
  663. return smalltalk.withContext(function($ctx1) {
  664. self._assert_(_st(_st(self._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  665. self._assert_(_st(_st(self._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  666. self._assert_(self._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  667. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.InterpreterTest)})},
  668. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
  669. smalltalk.InterpreterTest);
  670. smalltalk.addMethod(
  671. smalltalk.method({
  672. selector: "testUnarySend",
  673. fn: function (){
  674. var self=this;
  675. return smalltalk.withContext(function($ctx1) {
  676. self._assert_equals_(self._interpret_("foo ^ 1 asString"),"1");
  677. return self}, function($ctx1) {$ctx1.fill(self,"testUnarySend",{},smalltalk.InterpreterTest)})},
  678. messageSends: ["assert:equals:", "interpret:"]}),
  679. smalltalk.InterpreterTest);
  680. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  681. smalltalk.addMethod(
  682. smalltalk.method({
  683. selector: "codeGeneratorClass",
  684. fn: function (){
  685. var self=this;
  686. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  687. return smalltalk.withContext(function($ctx1) {
  688. var $1;
  689. $1=$CodeGenerator();
  690. return $1;
  691. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  692. messageSends: []}),
  693. smalltalk.CodeGeneratorTest);
  694. smalltalk.addMethod(
  695. smalltalk.method({
  696. selector: "compiler",
  697. fn: function (){
  698. var self=this;
  699. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  700. return smalltalk.withContext(function($ctx1) {
  701. var $2,$3,$1;
  702. $2=_st($Compiler())._new();
  703. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  704. $3=_st($2)._yourself();
  705. $1=$3;
  706. return $1;
  707. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  708. messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"]}),
  709. smalltalk.CodeGeneratorTest);
  710. smalltalk.addMethod(
  711. smalltalk.method({
  712. selector: "setUp",
  713. fn: function (){
  714. var self=this;
  715. return smalltalk.withContext(function($ctx1) {
  716. self["@receiver"]=_st(self._targetClass())._new();
  717. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  718. messageSends: ["new", "targetClass"]}),
  719. smalltalk.CodeGeneratorTest);
  720. smalltalk.addMethod(
  721. smalltalk.method({
  722. selector: "should:return:",
  723. fn: function (aString,anObject){
  724. var self=this;
  725. var method,result;
  726. return smalltalk.withContext(function($ctx1) {
  727. method=_st(self._compiler())._install_forClass_category_(aString,self._targetClass(),"tests");
  728. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  729. _st(self._targetClass())._removeCompiledMethod_(method);
  730. self._assert_equals_(anObject,result);
  731. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  732. messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"]}),
  733. smalltalk.CodeGeneratorTest);
  734. smalltalk.addMethod(
  735. smalltalk.method({
  736. selector: "targetClass",
  737. fn: function (){
  738. var self=this;
  739. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  740. return smalltalk.withContext(function($ctx1) {
  741. var $1;
  742. $1=$DoIt();
  743. return $1;
  744. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  745. messageSends: []}),
  746. smalltalk.CodeGeneratorTest);
  747. smalltalk.addMethod(
  748. smalltalk.method({
  749. selector: "tearDown",
  750. fn: function (){
  751. var self=this;
  752. return smalltalk.withContext(function($ctx1) {
  753. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  754. messageSends: []}),
  755. smalltalk.CodeGeneratorTest);
  756. smalltalk.addMethod(
  757. smalltalk.method({
  758. selector: "testAssignment",
  759. fn: function (){
  760. var self=this;
  761. return smalltalk.withContext(function($ctx1) {
  762. self._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  763. self._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  764. self._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  765. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  766. messageSends: ["should:return:"]}),
  767. smalltalk.CodeGeneratorTest);
  768. smalltalk.addMethod(
  769. smalltalk.method({
  770. selector: "testBackslashSelectors",
  771. fn: function (){
  772. var self=this;
  773. return smalltalk.withContext(function($ctx1) {
  774. self._should_return_("\x5c arg ^ 4",(4));
  775. self._should_return_("\x5c\x5c arg ^ 42",(42));
  776. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  777. messageSends: ["should:return:"]}),
  778. smalltalk.CodeGeneratorTest);
  779. smalltalk.addMethod(
  780. smalltalk.method({
  781. selector: "testBlockReturn",
  782. fn: function (){
  783. var self=this;
  784. return smalltalk.withContext(function($ctx1) {
  785. self._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  786. self._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  787. self._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  788. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  789. messageSends: ["should:return:"]}),
  790. smalltalk.CodeGeneratorTest);
  791. smalltalk.addMethod(
  792. smalltalk.method({
  793. selector: "testCascades",
  794. fn: function (){
  795. var self=this;
  796. return smalltalk.withContext(function($ctx1) {
  797. self._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  798. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  799. messageSends: ["should:return:"]}),
  800. smalltalk.CodeGeneratorTest);
  801. smalltalk.addMethod(
  802. smalltalk.method({
  803. selector: "testDynamicArrayElementsOrdered",
  804. fn: function (){
  805. var self=this;
  806. return smalltalk.withContext(function($ctx1) {
  807. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  808. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  809. messageSends: ["should:return:"]}),
  810. smalltalk.CodeGeneratorTest);
  811. smalltalk.addMethod(
  812. smalltalk.method({
  813. selector: "testDynamicDictionaryElementsOrdered",
  814. fn: function (){
  815. var self=this;
  816. return smalltalk.withContext(function($ctx1) {
  817. 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))]));
  818. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  819. messageSends: ["should:return:", "->"]}),
  820. smalltalk.CodeGeneratorTest);
  821. smalltalk.addMethod(
  822. smalltalk.method({
  823. selector: "testInnerTemporalDependentElementsOrdered",
  824. fn: function (){
  825. var self=this;
  826. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  827. return smalltalk.withContext(function($ctx1) {
  828. 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))]);
  829. 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))]);
  830. 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))]);
  831. 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))]));
  832. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  833. messageSends: ["should:return:", "->"]}),
  834. smalltalk.CodeGeneratorTest);
  835. smalltalk.addMethod(
  836. smalltalk.method({
  837. selector: "testLiterals",
  838. fn: function (){
  839. var self=this;
  840. return smalltalk.withContext(function($ctx1) {
  841. self._should_return_("foo ^ 1",(1));
  842. self._should_return_("foo ^ 'hello'","hello");
  843. self._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  844. self._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  845. self._should_return_("foo ^ true",true);
  846. self._should_return_("foo ^ false",false);
  847. self._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._from_([(1).__minus_gt((2)),(3).__minus_gt((4))]));
  848. self._should_return_("foo ^ #hello","hello");
  849. self._should_return_("foo ^ -123.456",(-123.456));
  850. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  851. messageSends: ["should:return:", "->"]}),
  852. smalltalk.CodeGeneratorTest);
  853. smalltalk.addMethod(
  854. smalltalk.method({
  855. selector: "testLocalReturn",
  856. fn: function (){
  857. var self=this;
  858. return smalltalk.withContext(function($ctx1) {
  859. self._should_return_("foo ^ 1",(1));
  860. self._should_return_("foo ^ 1 + 1",(2));
  861. self._should_return_("foo ",self["@receiver"]);
  862. self._should_return_("foo self asString",self["@receiver"]);
  863. self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  864. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  865. messageSends: ["should:return:"]}),
  866. smalltalk.CodeGeneratorTest);
  867. smalltalk.addMethod(
  868. smalltalk.method({
  869. selector: "testMessageSends",
  870. fn: function (){
  871. var self=this;
  872. return smalltalk.withContext(function($ctx1) {
  873. self._should_return_("foo ^ 1 asString","1");
  874. self._should_return_("foo ^ 1 + 1",(2));
  875. self._should_return_("foo ^ 1 + 2 * 3",(9));
  876. self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  877. self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  878. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  879. messageSends: ["should:return:"]}),
  880. smalltalk.CodeGeneratorTest);
  881. smalltalk.addMethod(
  882. smalltalk.method({
  883. selector: "testMutableLiterals",
  884. fn: function (){
  885. var self=this;
  886. return smalltalk.withContext(function($ctx1) {
  887. self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  888. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  889. messageSends: ["should:return:"]}),
  890. smalltalk.CodeGeneratorTest);
  891. smalltalk.addMethod(
  892. smalltalk.method({
  893. selector: "testNestedIfTrue",
  894. fn: function (){
  895. var self=this;
  896. return smalltalk.withContext(function($ctx1) {
  897. self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  898. self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  899. self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  900. self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  901. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  902. messageSends: ["should:return:"]}),
  903. smalltalk.CodeGeneratorTest);
  904. smalltalk.addMethod(
  905. smalltalk.method({
  906. selector: "testNonLocalReturn",
  907. fn: function (){
  908. var self=this;
  909. return smalltalk.withContext(function($ctx1) {
  910. self._should_return_("foo [ ^ 1 ] value",(1));
  911. self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  912. self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  913. self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  914. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  915. messageSends: ["should:return:"]}),
  916. smalltalk.CodeGeneratorTest);
  917. smalltalk.addMethod(
  918. smalltalk.method({
  919. selector: "testPascalCaseGlobal",
  920. fn: function (){
  921. var self=this;
  922. return smalltalk.withContext(function($ctx1) {
  923. self._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  924. self._should_return_("foo ^NonExistent",nil);
  925. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  926. messageSends: ["should:return:", "at:"]}),
  927. smalltalk.CodeGeneratorTest);
  928. smalltalk.addMethod(
  929. smalltalk.method({
  930. selector: "testSendReceiverAndArgumentsOrdered",
  931. fn: function (){
  932. var self=this;
  933. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  934. return smalltalk.withContext(function($ctx1) {
  935. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  936. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  937. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  938. messageSends: ["should:return:"]}),
  939. smalltalk.CodeGeneratorTest);
  940. smalltalk.addMethod(
  941. smalltalk.method({
  942. selector: "testifFalse",
  943. fn: function (){
  944. var self=this;
  945. return smalltalk.withContext(function($ctx1) {
  946. self._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  947. self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  948. self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  949. self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  950. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  951. messageSends: ["should:return:"]}),
  952. smalltalk.CodeGeneratorTest);
  953. smalltalk.addMethod(
  954. smalltalk.method({
  955. selector: "testifFalseIfTrue",
  956. fn: function (){
  957. var self=this;
  958. return smalltalk.withContext(function($ctx1) {
  959. self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  960. self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  961. self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  962. self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  963. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  964. messageSends: ["should:return:"]}),
  965. smalltalk.CodeGeneratorTest);
  966. smalltalk.addMethod(
  967. smalltalk.method({
  968. selector: "testifNil",
  969. fn: function (){
  970. var self=this;
  971. return smalltalk.withContext(function($ctx1) {
  972. self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  973. self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  974. self._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  975. self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  976. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  977. messageSends: ["should:return:"]}),
  978. smalltalk.CodeGeneratorTest);
  979. smalltalk.addMethod(
  980. smalltalk.method({
  981. selector: "testifNilIfNotNil",
  982. fn: function (){
  983. var self=this;
  984. return smalltalk.withContext(function($ctx1) {
  985. self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  986. self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  987. self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  988. self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  989. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  990. messageSends: ["should:return:"]}),
  991. smalltalk.CodeGeneratorTest);
  992. smalltalk.addMethod(
  993. smalltalk.method({
  994. selector: "testifNotNil",
  995. fn: function (){
  996. var self=this;
  997. return smalltalk.withContext(function($ctx1) {
  998. self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  999. self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  1000. self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  1001. self._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  1002. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  1003. messageSends: ["should:return:"]}),
  1004. smalltalk.CodeGeneratorTest);
  1005. smalltalk.addMethod(
  1006. smalltalk.method({
  1007. selector: "testifNotNilWithArgument",
  1008. fn: function (){
  1009. var self=this;
  1010. return smalltalk.withContext(function($ctx1) {
  1011. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  1012. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  1013. self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  1014. self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  1015. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  1016. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  1017. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  1018. messageSends: ["should:return:"]}),
  1019. smalltalk.CodeGeneratorTest);
  1020. smalltalk.addMethod(
  1021. smalltalk.method({
  1022. selector: "testifTrue",
  1023. fn: function (){
  1024. var self=this;
  1025. return smalltalk.withContext(function($ctx1) {
  1026. self._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  1027. self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  1028. self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  1029. self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  1030. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  1031. messageSends: ["should:return:"]}),
  1032. smalltalk.CodeGeneratorTest);
  1033. smalltalk.addMethod(
  1034. smalltalk.method({
  1035. selector: "testifTrueIfFalse",
  1036. fn: function (){
  1037. var self=this;
  1038. return smalltalk.withContext(function($ctx1) {
  1039. self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  1040. self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  1041. self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  1042. self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  1043. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  1044. messageSends: ["should:return:"]}),
  1045. smalltalk.CodeGeneratorTest);
  1046. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  1047. smalltalk.addMethod(
  1048. smalltalk.method({
  1049. selector: "codeGeneratorClass",
  1050. fn: function (){
  1051. var self=this;
  1052. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  1053. return smalltalk.withContext(function($ctx1) {
  1054. var $1;
  1055. $1=$InliningCodeGenerator();
  1056. return $1;
  1057. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  1058. messageSends: []}),
  1059. smalltalk.InliningCodeGeneratorTest);
  1060. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  1061. smalltalk.addMethod(
  1062. smalltalk.method({
  1063. selector: "testClassRefVar",
  1064. fn: function (){
  1065. var self=this;
  1066. var node;
  1067. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  1068. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1069. return smalltalk.withContext(function($ctx1) {
  1070. var $1,$2;
  1071. $1=_st($ClassReferenceNode())._new();
  1072. _st($1)._value_("Object");
  1073. $2=_st($1)._yourself();
  1074. node=$2;
  1075. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  1076. self._assert_(_st(_st(node)._binding())._isClassRefVar());
  1077. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  1078. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  1079. smalltalk.ScopeVarTest);
  1080. smalltalk.addMethod(
  1081. smalltalk.method({
  1082. selector: "testInstanceVar",
  1083. fn: function (){
  1084. var self=this;
  1085. var node,scope;
  1086. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1087. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1088. return smalltalk.withContext(function($ctx1) {
  1089. var $1,$2;
  1090. $1=_st($VariableNode())._new();
  1091. _st($1)._value_("bzzz");
  1092. $2=_st($1)._yourself();
  1093. node=$2;
  1094. scope=_st($MethodLexicalScope())._new();
  1095. _st(scope)._addIVar_("bzzz");
  1096. self._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  1097. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1098. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  1099. smalltalk.ScopeVarTest);
  1100. smalltalk.addMethod(
  1101. smalltalk.method({
  1102. selector: "testPseudoVar",
  1103. fn: function (){
  1104. var self=this;
  1105. var node,pseudoVars;
  1106. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1107. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1108. return smalltalk.withContext(function($ctx1) {
  1109. var $1,$2;
  1110. pseudoVars=["self", "super", "true", "false", "nil"];
  1111. _st(pseudoVars)._do_((function(each){
  1112. return smalltalk.withContext(function($ctx2) {
  1113. $1=_st($VariableNode())._new();
  1114. _st($1)._value_(each);
  1115. $2=_st($1)._yourself();
  1116. node=$2;
  1117. node;
  1118. return self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  1119. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1120. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  1121. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  1122. smalltalk.ScopeVarTest);
  1123. smalltalk.addMethod(
  1124. smalltalk.method({
  1125. selector: "testTempVar",
  1126. fn: function (){
  1127. var self=this;
  1128. var node,scope;
  1129. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1130. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1131. return smalltalk.withContext(function($ctx1) {
  1132. var $1,$2;
  1133. $1=_st($VariableNode())._new();
  1134. _st($1)._value_("bzzz");
  1135. $2=_st($1)._yourself();
  1136. node=$2;
  1137. scope=_st($MethodLexicalScope())._new();
  1138. _st(scope)._addTemp_("bzzz");
  1139. self._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  1140. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1141. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  1142. smalltalk.ScopeVarTest);
  1143. smalltalk.addMethod(
  1144. smalltalk.method({
  1145. selector: "testUnknownVar",
  1146. fn: function (){
  1147. var self=this;
  1148. var node;
  1149. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1150. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1151. return smalltalk.withContext(function($ctx1) {
  1152. var $1,$2;
  1153. $1=_st($VariableNode())._new();
  1154. _st($1)._value_("bzzz");
  1155. $2=_st($1)._yourself();
  1156. node=$2;
  1157. self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  1158. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  1159. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  1160. smalltalk.ScopeVarTest);
  1161. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  1162. smalltalk.addMethod(
  1163. smalltalk.method({
  1164. selector: "setUp",
  1165. fn: function (){
  1166. var self=this;
  1167. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1168. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1169. return smalltalk.withContext(function($ctx1) {
  1170. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  1171. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  1172. messageSends: ["on:"]}),
  1173. smalltalk.SemanticAnalyzerTest);
  1174. smalltalk.addMethod(
  1175. smalltalk.method({
  1176. selector: "testAssignment",
  1177. fn: function (){
  1178. var self=this;
  1179. var src,ast;
  1180. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  1181. return smalltalk.withContext(function($ctx1) {
  1182. src="foo self := 1";
  1183. ast=_st(smalltalk)._parse_(src);
  1184. self._should_raise_((function(){
  1185. return smalltalk.withContext(function($ctx2) {
  1186. return _st(self["@analyzer"])._visit_(ast);
  1187. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$InvalidAssignmentError());
  1188. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1189. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1190. smalltalk.SemanticAnalyzerTest);
  1191. smalltalk.addMethod(
  1192. smalltalk.method({
  1193. selector: "testNonLocalReturn",
  1194. fn: function (){
  1195. var self=this;
  1196. var src,ast;
  1197. return smalltalk.withContext(function($ctx1) {
  1198. src="foo | a | a + 1. ^ a";
  1199. ast=_st(smalltalk)._parse_(src);
  1200. _st(self["@analyzer"])._visit_(ast);
  1201. self._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1202. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1203. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  1204. smalltalk.SemanticAnalyzerTest);
  1205. smalltalk.addMethod(
  1206. smalltalk.method({
  1207. selector: "testNonLocalReturn2",
  1208. fn: function (){
  1209. var self=this;
  1210. var src,ast;
  1211. return smalltalk.withContext(function($ctx1) {
  1212. src="foo | a | a + 1. [ [ ^ a] ]";
  1213. ast=_st(smalltalk)._parse_(src);
  1214. _st(self["@analyzer"])._visit_(ast);
  1215. self._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1216. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1217. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  1218. smalltalk.SemanticAnalyzerTest);
  1219. smalltalk.addMethod(
  1220. smalltalk.method({
  1221. selector: "testScope",
  1222. fn: function (){
  1223. var self=this;
  1224. var src,ast;
  1225. return smalltalk.withContext(function($ctx1) {
  1226. src="foo | a | a + 1. [ | b | b := a ]";
  1227. ast=_st(smalltalk)._parse_(src);
  1228. _st(self["@analyzer"])._visit_(ast);
  1229. self._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  1230. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1231. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  1232. smalltalk.SemanticAnalyzerTest);
  1233. smalltalk.addMethod(
  1234. smalltalk.method({
  1235. selector: "testScope2",
  1236. fn: function (){
  1237. var self=this;
  1238. var src,ast;
  1239. return smalltalk.withContext(function($ctx1) {
  1240. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1241. ast=_st(smalltalk)._parse_(src);
  1242. _st(self["@analyzer"])._visit_(ast);
  1243. 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()));
  1244. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1245. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  1246. smalltalk.SemanticAnalyzerTest);
  1247. smalltalk.addMethod(
  1248. smalltalk.method({
  1249. selector: "testScopeLevel",
  1250. fn: function (){
  1251. var self=this;
  1252. var src,ast;
  1253. return smalltalk.withContext(function($ctx1) {
  1254. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1255. ast=_st(smalltalk)._parse_(src);
  1256. _st(self["@analyzer"])._visit_(ast);
  1257. self._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  1258. 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));
  1259. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1260. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  1261. smalltalk.SemanticAnalyzerTest);
  1262. smalltalk.addMethod(
  1263. smalltalk.method({
  1264. selector: "testUnknownVariables",
  1265. fn: function (){
  1266. var self=this;
  1267. var src,ast;
  1268. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1269. return smalltalk.withContext(function($ctx1) {
  1270. src="foo | a | b + a";
  1271. ast=_st(smalltalk)._parse_(src);
  1272. self._should_raise_((function(){
  1273. return smalltalk.withContext(function($ctx2) {
  1274. return _st(self["@analyzer"])._visit_(ast);
  1275. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  1276. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1277. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1278. smalltalk.SemanticAnalyzerTest);
  1279. smalltalk.addMethod(
  1280. smalltalk.method({
  1281. selector: "testUnknownVariablesWithScope",
  1282. fn: function (){
  1283. var self=this;
  1284. var src,ast;
  1285. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1286. return smalltalk.withContext(function($ctx1) {
  1287. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  1288. ast=_st(smalltalk)._parse_(src);
  1289. self._should_raise_((function(){
  1290. return smalltalk.withContext(function($ctx2) {
  1291. return _st(self["@analyzer"])._visit_(ast);
  1292. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  1293. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1294. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1295. smalltalk.SemanticAnalyzerTest);
  1296. smalltalk.addMethod(
  1297. smalltalk.method({
  1298. selector: "testVariableShadowing",
  1299. fn: function (){
  1300. var self=this;
  1301. var src,ast;
  1302. return smalltalk.withContext(function($ctx1) {
  1303. src="foo | a | a + 1";
  1304. ast=_st(smalltalk)._parse_(src);
  1305. _st(self["@analyzer"])._visit_(ast);
  1306. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1307. messageSends: ["parse:", "visit:"]}),
  1308. smalltalk.SemanticAnalyzerTest);
  1309. smalltalk.addMethod(
  1310. smalltalk.method({
  1311. selector: "testVariableShadowing2",
  1312. fn: function (){
  1313. var self=this;
  1314. var src,ast;
  1315. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1316. return smalltalk.withContext(function($ctx1) {
  1317. src="foo | a | a + 1. [ | a | a := 2 ]";
  1318. ast=_st(smalltalk)._parse_(src);
  1319. self._should_raise_((function(){
  1320. return smalltalk.withContext(function($ctx2) {
  1321. return _st(self["@analyzer"])._visit_(ast);
  1322. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1323. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1324. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1325. smalltalk.SemanticAnalyzerTest);
  1326. smalltalk.addMethod(
  1327. smalltalk.method({
  1328. selector: "testVariableShadowing3",
  1329. fn: function (){
  1330. var self=this;
  1331. var src,ast;
  1332. return smalltalk.withContext(function($ctx1) {
  1333. src="foo | a | a + 1. [ | b | b := 2 ]";
  1334. ast=_st(smalltalk)._parse_(src);
  1335. _st(self["@analyzer"])._visit_(ast);
  1336. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1337. messageSends: ["parse:", "visit:"]}),
  1338. smalltalk.SemanticAnalyzerTest);
  1339. smalltalk.addMethod(
  1340. smalltalk.method({
  1341. selector: "testVariableShadowing4",
  1342. fn: function (){
  1343. var self=this;
  1344. var src,ast;
  1345. return smalltalk.withContext(function($ctx1) {
  1346. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1347. ast=_st(smalltalk)._parse_(src);
  1348. _st(self["@analyzer"])._visit_(ast);
  1349. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1350. messageSends: ["parse:", "visit:"]}),
  1351. smalltalk.SemanticAnalyzerTest);
  1352. smalltalk.addMethod(
  1353. smalltalk.method({
  1354. selector: "testVariableShadowing5",
  1355. fn: function (){
  1356. var self=this;
  1357. var src,ast;
  1358. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1359. return smalltalk.withContext(function($ctx1) {
  1360. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1361. ast=_st(smalltalk)._parse_(src);
  1362. self._should_raise_((function(){
  1363. return smalltalk.withContext(function($ctx2) {
  1364. return _st(self["@analyzer"])._visit_(ast);
  1365. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1366. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1367. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1368. smalltalk.SemanticAnalyzerTest);
  1369. smalltalk.addMethod(
  1370. smalltalk.method({
  1371. selector: "testVariablesLookup",
  1372. fn: function (){
  1373. var self=this;
  1374. var src,ast;
  1375. return smalltalk.withContext(function($ctx1) {
  1376. src="foo | a | a + 1. [ | b | b := a ]";
  1377. ast=_st(smalltalk)._parse_(src);
  1378. _st(self["@analyzer"])._visit_(ast);
  1379. self._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1380. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1381. 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());
  1382. 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()));
  1383. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1384. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  1385. smalltalk.SemanticAnalyzerTest);