Compiler-Tests.deploy.js 62 KB

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