Compiler-Tests.deploy.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109
  1. smalltalk.addPackage('Compiler-Tests');
  2. smalltalk.addClass('AbstractASTInterpreterTest', 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.AbstractASTInterpreterTest)})},
  15. messageSends: ["visit:", "on:"]}),
  16. smalltalk.AbstractASTInterpreterTest);
  17. smalltalk.addMethod(
  18. smalltalk.method({
  19. selector: "interpret:",
  20. fn: function (aString){
  21. var self=this;
  22. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  23. return smalltalk.withContext(function($ctx1) {
  24. var $1;
  25. $1=_st(self)._interpret_withArguments_(aString,_st($Dictionary())._new());
  26. return $1;
  27. }, function($ctx1) {$ctx1.fill(self,"interpret:",{aString:aString},smalltalk.AbstractASTInterpreterTest)})},
  28. messageSends: ["interpret:withArguments:", "new"]}),
  29. smalltalk.AbstractASTInterpreterTest);
  30. smalltalk.addMethod(
  31. smalltalk.method({
  32. selector: "interpret:receiver:withArguments:",
  33. fn: function (aString,anObject,aDictionary){
  34. var self=this;
  35. var ctx;
  36. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  37. return smalltalk.withContext(function($ctx1) {
  38. var $2,$3,$1;
  39. ctx=_st($AIContext())._new();
  40. _st(ctx)._receiver_(anObject);
  41. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  42. return smalltalk.withContext(function($ctx2) {
  43. return _st(ctx)._localAt_put_(key,value);
  44. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  45. $2=_st(self)._interpreter();
  46. _st($2)._context_(ctx);
  47. _st($2)._interpret_(_st(_st(_st(self)._parse_forClass_(aString,_st(anObject)._class()))._nodes())._first());
  48. $3=_st($2)._result();
  49. $1=$3;
  50. return $1;
  51. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx},smalltalk.AbstractASTInterpreterTest)})},
  52. messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "first", "nodes", "parse:forClass:", "class", "result"]}),
  53. smalltalk.AbstractASTInterpreterTest);
  54. smalltalk.addMethod(
  55. smalltalk.method({
  56. selector: "interpret:withArguments:",
  57. fn: function (aString,aDictionary){
  58. var self=this;
  59. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  60. return smalltalk.withContext(function($ctx1) {
  61. var $1;
  62. $1=_st(self)._interpret_receiver_withArguments_(aString,_st($Object())._new(),aDictionary);
  63. return $1;
  64. }, function($ctx1) {$ctx1.fill(self,"interpret:withArguments:",{aString:aString,aDictionary:aDictionary},smalltalk.AbstractASTInterpreterTest)})},
  65. messageSends: ["interpret:receiver:withArguments:", "new"]}),
  66. smalltalk.AbstractASTInterpreterTest);
  67. smalltalk.addMethod(
  68. smalltalk.method({
  69. selector: "interpreter",
  70. fn: function (){
  71. var self=this;
  72. return smalltalk.withContext(function($ctx1) {
  73. var $1;
  74. $1=_st(self)._subclassResponsibility();
  75. return $1;
  76. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AbstractASTInterpreterTest)})},
  77. messageSends: ["subclassResponsibility"]}),
  78. smalltalk.AbstractASTInterpreterTest);
  79. smalltalk.addMethod(
  80. smalltalk.method({
  81. selector: "parse:",
  82. fn: function (aString){
  83. var self=this;
  84. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  85. return smalltalk.withContext(function($ctx1) {
  86. var $1;
  87. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  88. return $1;
  89. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.AbstractASTInterpreterTest)})},
  90. messageSends: ["parse:", "current"]}),
  91. smalltalk.AbstractASTInterpreterTest);
  92. smalltalk.addMethod(
  93. smalltalk.method({
  94. selector: "parse:forClass:",
  95. fn: function (aString,aClass){
  96. var self=this;
  97. return smalltalk.withContext(function($ctx1) {
  98. var $1;
  99. $1=_st(self)._analyze_forClass_(_st(self)._parse_(aString),aClass);
  100. return $1;
  101. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.AbstractASTInterpreterTest)})},
  102. messageSends: ["analyze:forClass:", "parse:"]}),
  103. smalltalk.AbstractASTInterpreterTest);
  104. smalltalk.addClass('ASTInterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
  105. smalltalk.addMethod(
  106. smalltalk.method({
  107. selector: "interpreter",
  108. fn: function (){
  109. var self=this;
  110. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  111. return smalltalk.withContext(function($ctx1) {
  112. var $1;
  113. $1=_st($ASTInterpreter())._new();
  114. return $1;
  115. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTInterpreterTest)})},
  116. messageSends: ["new"]}),
  117. smalltalk.ASTInterpreterTest);
  118. smalltalk.addMethod(
  119. smalltalk.method({
  120. selector: "testBinarySend",
  121. fn: function (){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) {
  124. _st(self)._assert_equals_(_st(self)._interpret_("foo 2+3+4"),(9));
  125. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.ASTInterpreterTest)})},
  126. messageSends: ["assert:equals:", "interpret:"]}),
  127. smalltalk.ASTInterpreterTest);
  128. smalltalk.addMethod(
  129. smalltalk.method({
  130. selector: "testBlockLiteral",
  131. fn: function (){
  132. var self=this;
  133. return smalltalk.withContext(function($ctx1) {
  134. _st(self)._assert_equals_(_st(self)._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  135. _st(self)._assert_equals_(_st(self)._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  136. _st(self)._assert_equals_(_st(self)._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  137. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.ASTInterpreterTest)})},
  138. messageSends: ["assert:equals:", "interpret:"]}),
  139. smalltalk.ASTInterpreterTest);
  140. smalltalk.addMethod(
  141. smalltalk.method({
  142. selector: "testCascade",
  143. fn: function (){
  144. var self=this;
  145. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  146. return smalltalk.withContext(function($ctx1) {
  147. _st(self)._assert_equals_(_st(self)._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  148. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.ASTInterpreterTest)})},
  149. messageSends: ["assert:equals:", "interpret:", "with:with:"]}),
  150. smalltalk.ASTInterpreterTest);
  151. smalltalk.addMethod(
  152. smalltalk.method({
  153. selector: "testDynamicArray",
  154. fn: function (){
  155. var self=this;
  156. return smalltalk.withContext(function($ctx1) {
  157. _st(self)._assert_equals_(_st(self)._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  158. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.ASTInterpreterTest)})},
  159. messageSends: ["assert:equals:", "interpret:"]}),
  160. smalltalk.ASTInterpreterTest);
  161. smalltalk.addMethod(
  162. smalltalk.method({
  163. selector: "testDynamicDictionary",
  164. fn: function (){
  165. var self=this;
  166. return smalltalk.withContext(function($ctx1) {
  167. _st(self)._assert_equals_(_st(self)._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((1)),_st((2)).__minus_gt((3))]));
  168. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.ASTInterpreterTest)})},
  169. messageSends: ["assert:equals:", "interpret:", "->"]}),
  170. smalltalk.ASTInterpreterTest);
  171. smalltalk.addMethod(
  172. smalltalk.method({
  173. selector: "testInlinedJSStatement",
  174. fn: function (){
  175. var self=this;
  176. return smalltalk.withContext(function($ctx1) {
  177. _st(self)._assert_equals_(_st(self)._interpret_("foo <return 2+3>"),(5));
  178. _st(self)._assert_equals_(_st(self)._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._fromPairs_([_st("anInteger").__minus_gt((3))])),(5));
  179. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.ASTInterpreterTest)})},
  180. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"]}),
  181. smalltalk.ASTInterpreterTest);
  182. smalltalk.addMethod(
  183. smalltalk.method({
  184. selector: "testInstVarAccess",
  185. fn: function (){
  186. var self=this;
  187. return smalltalk.withContext(function($ctx1) {
  188. _st(self)._assert_equals_(_st(self)._interpret_receiver_withArguments_("foo ^ x",_st((2)).__at((3)),smalltalk.HashedCollection._fromPairs_([])),(2));
  189. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.ASTInterpreterTest)})},
  190. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  191. smalltalk.ASTInterpreterTest);
  192. smalltalk.addMethod(
  193. smalltalk.method({
  194. selector: "testInstVarAssignment",
  195. fn: function (){
  196. var self=this;
  197. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  198. return smalltalk.withContext(function($ctx1) {
  199. _st(self)._assert_equals_(_st(self)._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._fromPairs_([_st("anInteger").__minus_gt((2))])),(2));
  200. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.ASTInterpreterTest)})},
  201. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"]}),
  202. smalltalk.ASTInterpreterTest);
  203. smalltalk.addMethod(
  204. smalltalk.method({
  205. selector: "testNonlocalReturn",
  206. fn: function (){
  207. var self=this;
  208. return smalltalk.withContext(function($ctx1) {
  209. _st(self)._assert_equals_(_st(self)._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  210. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.ASTInterpreterTest)})},
  211. messageSends: ["assert:equals:", "interpret:"]}),
  212. smalltalk.ASTInterpreterTest);
  213. smalltalk.addMethod(
  214. smalltalk.method({
  215. selector: "testReceiver",
  216. fn: function (){
  217. var self=this;
  218. return smalltalk.withContext(function($ctx1) {
  219. _st(self)._assert_equals_(_st(self)._interpret_receiver_withArguments_("foo ^ self",_st((2)).__at((3)),smalltalk.HashedCollection._fromPairs_([])),_st((2)).__at((3)));
  220. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.ASTInterpreterTest)})},
  221. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  222. smalltalk.ASTInterpreterTest);
  223. smalltalk.addMethod(
  224. smalltalk.method({
  225. selector: "testTempAssignment",
  226. fn: function (){
  227. var self=this;
  228. return smalltalk.withContext(function($ctx1) {
  229. _st(self)._assert_equals_(_st(self)._interpret_("foo | a | a := 2. ^ a"),(2));
  230. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.ASTInterpreterTest)})},
  231. messageSends: ["assert:equals:", "interpret:"]}),
  232. smalltalk.ASTInterpreterTest);
  233. smalltalk.addMethod(
  234. smalltalk.method({
  235. selector: "testThisContext",
  236. fn: function (){
  237. var self=this;
  238. return smalltalk.withContext(function($ctx1) {
  239. _st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  240. _st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  241. _st(self)._assert_(_st(self)._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  242. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.ASTInterpreterTest)})},
  243. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
  244. smalltalk.ASTInterpreterTest);
  245. smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');
  246. smalltalk.addMethod(
  247. smalltalk.method({
  248. selector: "interpreter",
  249. fn: function (){
  250. var self=this;
  251. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  252. return smalltalk.withContext(function($ctx1) {
  253. var $2,$1;
  254. $2=self["@interpreter"];
  255. if(($receiver = $2) == nil || $receiver == undefined){
  256. self["@interpreter"]=_st($ASTSteppingInterpreter())._new();
  257. $1=self["@interpreter"];
  258. } else {
  259. $1=$2;
  260. };
  261. return $1;
  262. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTSteppingInterpreterTest)})},
  263. messageSends: ["ifNil:", "new"]}),
  264. smalltalk.ASTSteppingInterpreterTest);
  265. smalltalk.addMethod(
  266. smalltalk.method({
  267. selector: "testAtEnd",
  268. fn: function (){
  269. var self=this;
  270. return smalltalk.withContext(function($ctx1) {
  271. _st(self)._interpret_("foo 1 + 2");
  272. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  273. _st(_st(self)._interpreter())._step();
  274. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  275. _st(_st(self)._interpreter())._step();
  276. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  277. _st(_st(self)._interpreter())._step();
  278. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  279. _st(_st(self)._interpreter())._step();
  280. _st(self)._assert_(_st(_st(self)._interpreter())._atEnd());
  281. return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.ASTSteppingInterpreterTest)})},
  282. messageSends: ["interpret:", "deny:", "atEnd", "interpreter", "step", "assert:"]}),
  283. smalltalk.ASTSteppingInterpreterTest);
  284. smalltalk.addMethod(
  285. smalltalk.method({
  286. selector: "testMessageSend",
  287. fn: function (){
  288. var self=this;
  289. return smalltalk.withContext(function($ctx1) {
  290. _st(self)._interpret_("foo 1 + 2");
  291. _st(_st(self)._interpreter())._step();
  292. _st(_st(self)._interpreter())._step();
  293. _st(_st(self)._interpreter())._step();
  294. _st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(1));
  295. _st(_st(self)._interpreter())._step();
  296. _st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(2));
  297. _st(_st(self)._interpreter())._step();
  298. _st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(3));
  299. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.ASTSteppingInterpreterTest)})},
  300. messageSends: ["interpret:", "step", "interpreter", "assert:equals:", "value", "currentNode", "result"]}),
  301. smalltalk.ASTSteppingInterpreterTest);
  302. smalltalk.addMethod(
  303. smalltalk.method({
  304. selector: "testSimpleStepping",
  305. fn: function (){
  306. var self=this;
  307. return smalltalk.withContext(function($ctx1) {
  308. _st(self)._interpret_("foo 1");
  309. _st(_st(self)._interpreter())._step();
  310. _st(self)._assert_(_st(_st(_st(self)._interpreter())._result())._isNil());
  311. _st(_st(self)._interpreter())._step();
  312. _st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(1));
  313. return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{},smalltalk.ASTSteppingInterpreterTest)})},
  314. messageSends: ["interpret:", "step", "interpreter", "assert:", "isNil", "result", "assert:equals:"]}),
  315. smalltalk.ASTSteppingInterpreterTest);
  316. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  317. smalltalk.addMethod(
  318. smalltalk.method({
  319. selector: "codeGeneratorClass",
  320. fn: function (){
  321. var self=this;
  322. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  323. return smalltalk.withContext(function($ctx1) {
  324. var $1;
  325. $1=$CodeGenerator();
  326. return $1;
  327. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  328. messageSends: []}),
  329. smalltalk.CodeGeneratorTest);
  330. smalltalk.addMethod(
  331. smalltalk.method({
  332. selector: "compiler",
  333. fn: function (){
  334. var self=this;
  335. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  336. return smalltalk.withContext(function($ctx1) {
  337. var $2,$3,$1;
  338. $2=_st($Compiler())._new();
  339. _st($2)._codeGeneratorClass_(_st(self)._codeGeneratorClass());
  340. $3=_st($2)._yourself();
  341. $1=$3;
  342. return $1;
  343. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  344. messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"]}),
  345. smalltalk.CodeGeneratorTest);
  346. smalltalk.addMethod(
  347. smalltalk.method({
  348. selector: "setUp",
  349. fn: function (){
  350. var self=this;
  351. return smalltalk.withContext(function($ctx1) {
  352. self["@receiver"]=_st(_st(self)._targetClass())._new();
  353. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  354. messageSends: ["new", "targetClass"]}),
  355. smalltalk.CodeGeneratorTest);
  356. smalltalk.addMethod(
  357. smalltalk.method({
  358. selector: "should:return:",
  359. fn: function (aString,anObject){
  360. var self=this;
  361. var method,result;
  362. return smalltalk.withContext(function($ctx1) {
  363. method=_st(_st(self)._compiler())._install_forClass_category_(aString,_st(self)._targetClass(),"tests");
  364. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  365. _st(_st(self)._targetClass())._removeCompiledMethod_(method);
  366. _st(self)._assert_equals_(anObject,result);
  367. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  368. messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"]}),
  369. smalltalk.CodeGeneratorTest);
  370. smalltalk.addMethod(
  371. smalltalk.method({
  372. selector: "targetClass",
  373. fn: function (){
  374. var self=this;
  375. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  376. return smalltalk.withContext(function($ctx1) {
  377. var $1;
  378. $1=$DoIt();
  379. return $1;
  380. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  381. messageSends: []}),
  382. smalltalk.CodeGeneratorTest);
  383. smalltalk.addMethod(
  384. smalltalk.method({
  385. selector: "tearDown",
  386. fn: function (){
  387. var self=this;
  388. return smalltalk.withContext(function($ctx1) {
  389. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  390. messageSends: []}),
  391. smalltalk.CodeGeneratorTest);
  392. smalltalk.addMethod(
  393. smalltalk.method({
  394. selector: "testAssignment",
  395. fn: function (){
  396. var self=this;
  397. return smalltalk.withContext(function($ctx1) {
  398. _st(self)._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  399. _st(self)._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  400. _st(self)._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  401. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  402. messageSends: ["should:return:"]}),
  403. smalltalk.CodeGeneratorTest);
  404. smalltalk.addMethod(
  405. smalltalk.method({
  406. selector: "testBackslashSelectors",
  407. fn: function (){
  408. var self=this;
  409. return smalltalk.withContext(function($ctx1) {
  410. _st(self)._should_return_("\x5c arg ^ 4",(4));
  411. _st(self)._should_return_("\x5c\x5c arg ^ 42",(42));
  412. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  413. messageSends: ["should:return:"]}),
  414. smalltalk.CodeGeneratorTest);
  415. smalltalk.addMethod(
  416. smalltalk.method({
  417. selector: "testBlockReturn",
  418. fn: function (){
  419. var self=this;
  420. return smalltalk.withContext(function($ctx1) {
  421. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  422. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  423. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  424. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  425. messageSends: ["should:return:"]}),
  426. smalltalk.CodeGeneratorTest);
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "testCascades",
  430. fn: function (){
  431. var self=this;
  432. return smalltalk.withContext(function($ctx1) {
  433. _st(self)._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  434. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  435. messageSends: ["should:return:"]}),
  436. smalltalk.CodeGeneratorTest);
  437. smalltalk.addMethod(
  438. smalltalk.method({
  439. selector: "testDynamicArrayElementsOrdered",
  440. fn: function (){
  441. var self=this;
  442. return smalltalk.withContext(function($ctx1) {
  443. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  444. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  445. messageSends: ["should:return:"]}),
  446. smalltalk.CodeGeneratorTest);
  447. smalltalk.addMethod(
  448. smalltalk.method({
  449. selector: "testDynamicDictionaryElementsOrdered",
  450. fn: function (){
  451. var self=this;
  452. return smalltalk.withContext(function($ctx1) {
  453. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 'foo'->1.\x0a\x09^ #{ x. (true ifTrue: [ x := 'bar'->2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  454. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  455. messageSends: ["should:return:", "->"]}),
  456. smalltalk.CodeGeneratorTest);
  457. smalltalk.addMethod(
  458. smalltalk.method({
  459. selector: "testInnerTemporalDependentElementsOrdered",
  460. fn: function (){
  461. var self=this;
  462. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  463. return smalltalk.withContext(function($ctx1) {
  464. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt($Array()),_st("bar").__minus_gt((2))]);
  465. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  466. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  467. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  468. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  469. messageSends: ["should:return:", "->"]}),
  470. smalltalk.CodeGeneratorTest);
  471. smalltalk.addMethod(
  472. smalltalk.method({
  473. selector: "testLiterals",
  474. fn: function (){
  475. var self=this;
  476. return smalltalk.withContext(function($ctx1) {
  477. _st(self)._should_return_("foo ^ 1",(1));
  478. _st(self)._should_return_("foo ^ 'hello'","hello");
  479. _st(self)._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  480. _st(self)._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  481. _st(self)._should_return_("foo ^ true",true);
  482. _st(self)._should_return_("foo ^ false",false);
  483. _st(self)._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((2)),_st((3)).__minus_gt((4))]));
  484. _st(self)._should_return_("foo ^ #hello","hello");
  485. _st(self)._should_return_("foo ^ -123.456",(-123.456));
  486. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  487. messageSends: ["should:return:", "->"]}),
  488. smalltalk.CodeGeneratorTest);
  489. smalltalk.addMethod(
  490. smalltalk.method({
  491. selector: "testLocalReturn",
  492. fn: function (){
  493. var self=this;
  494. return smalltalk.withContext(function($ctx1) {
  495. _st(self)._should_return_("foo ^ 1",(1));
  496. _st(self)._should_return_("foo ^ 1 + 1",(2));
  497. _st(self)._should_return_("foo ",self["@receiver"]);
  498. _st(self)._should_return_("foo self asString",self["@receiver"]);
  499. _st(self)._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  500. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  501. messageSends: ["should:return:"]}),
  502. smalltalk.CodeGeneratorTest);
  503. smalltalk.addMethod(
  504. smalltalk.method({
  505. selector: "testMessageSends",
  506. fn: function (){
  507. var self=this;
  508. return smalltalk.withContext(function($ctx1) {
  509. _st(self)._should_return_("foo ^ 1 asString","1");
  510. _st(self)._should_return_("foo ^ 1 + 1",(2));
  511. _st(self)._should_return_("foo ^ 1 + 2 * 3",(9));
  512. _st(self)._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  513. _st(self)._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  514. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  515. messageSends: ["should:return:"]}),
  516. smalltalk.CodeGeneratorTest);
  517. smalltalk.addMethod(
  518. smalltalk.method({
  519. selector: "testMutableLiterals",
  520. fn: function (){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) {
  523. _st(self)._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  524. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  525. messageSends: ["should:return:"]}),
  526. smalltalk.CodeGeneratorTest);
  527. smalltalk.addMethod(
  528. smalltalk.method({
  529. selector: "testNestedIfTrue",
  530. fn: function (){
  531. var self=this;
  532. return smalltalk.withContext(function($ctx1) {
  533. _st(self)._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  534. _st(self)._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  535. _st(self)._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  536. _st(self)._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  537. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  538. messageSends: ["should:return:"]}),
  539. smalltalk.CodeGeneratorTest);
  540. smalltalk.addMethod(
  541. smalltalk.method({
  542. selector: "testNonLocalReturn",
  543. fn: function (){
  544. var self=this;
  545. return smalltalk.withContext(function($ctx1) {
  546. _st(self)._should_return_("foo [ ^ 1 ] value",(1));
  547. _st(self)._should_return_("foo [ ^ 1 + 1 ] value",(2));
  548. _st(self)._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  549. _st(self)._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  550. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  551. messageSends: ["should:return:"]}),
  552. smalltalk.CodeGeneratorTest);
  553. smalltalk.addMethod(
  554. smalltalk.method({
  555. selector: "testPascalCaseGlobal",
  556. fn: function (){
  557. var self=this;
  558. return smalltalk.withContext(function($ctx1) {
  559. _st(self)._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  560. _st(self)._should_return_("foo ^NonExistent",nil);
  561. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  562. messageSends: ["should:return:", "at:"]}),
  563. smalltalk.CodeGeneratorTest);
  564. smalltalk.addMethod(
  565. smalltalk.method({
  566. selector: "testSendReceiverAndArgumentsOrdered",
  567. fn: function (){
  568. var self=this;
  569. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  570. return smalltalk.withContext(function($ctx1) {
  571. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  572. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  573. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  574. messageSends: ["should:return:"]}),
  575. smalltalk.CodeGeneratorTest);
  576. smalltalk.addMethod(
  577. smalltalk.method({
  578. selector: "testifFalse",
  579. fn: function (){
  580. var self=this;
  581. return smalltalk.withContext(function($ctx1) {
  582. _st(self)._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  583. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  584. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  585. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  586. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  587. messageSends: ["should:return:"]}),
  588. smalltalk.CodeGeneratorTest);
  589. smalltalk.addMethod(
  590. smalltalk.method({
  591. selector: "testifFalseIfTrue",
  592. fn: function (){
  593. var self=this;
  594. return smalltalk.withContext(function($ctx1) {
  595. _st(self)._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  596. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  597. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  598. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  599. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  600. messageSends: ["should:return:"]}),
  601. smalltalk.CodeGeneratorTest);
  602. smalltalk.addMethod(
  603. smalltalk.method({
  604. selector: "testifNil",
  605. fn: function (){
  606. var self=this;
  607. return smalltalk.withContext(function($ctx1) {
  608. _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  609. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  610. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  611. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  612. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  613. messageSends: ["should:return:"]}),
  614. smalltalk.CodeGeneratorTest);
  615. smalltalk.addMethod(
  616. smalltalk.method({
  617. selector: "testifNilIfNotNil",
  618. fn: function (){
  619. var self=this;
  620. return smalltalk.withContext(function($ctx1) {
  621. _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  622. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  623. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  624. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  625. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  626. messageSends: ["should:return:"]}),
  627. smalltalk.CodeGeneratorTest);
  628. smalltalk.addMethod(
  629. smalltalk.method({
  630. selector: "testifNotNil",
  631. fn: function (){
  632. var self=this;
  633. return smalltalk.withContext(function($ctx1) {
  634. _st(self)._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  635. _st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  636. _st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  637. _st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  638. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  639. messageSends: ["should:return:"]}),
  640. smalltalk.CodeGeneratorTest);
  641. smalltalk.addMethod(
  642. smalltalk.method({
  643. selector: "testifNotNilWithArgument",
  644. fn: function (){
  645. var self=this;
  646. return smalltalk.withContext(function($ctx1) {
  647. _st(self)._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  648. _st(self)._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  649. _st(self)._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  650. _st(self)._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  651. _st(self)._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  652. _st(self)._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  653. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  654. messageSends: ["should:return:"]}),
  655. smalltalk.CodeGeneratorTest);
  656. smalltalk.addMethod(
  657. smalltalk.method({
  658. selector: "testifTrue",
  659. fn: function (){
  660. var self=this;
  661. return smalltalk.withContext(function($ctx1) {
  662. _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  663. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  664. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  665. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  666. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  667. messageSends: ["should:return:"]}),
  668. smalltalk.CodeGeneratorTest);
  669. smalltalk.addMethod(
  670. smalltalk.method({
  671. selector: "testifTrueIfFalse",
  672. fn: function (){
  673. var self=this;
  674. return smalltalk.withContext(function($ctx1) {
  675. _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  676. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  677. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  678. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  679. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  680. messageSends: ["should:return:"]}),
  681. smalltalk.CodeGeneratorTest);
  682. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  683. smalltalk.addMethod(
  684. smalltalk.method({
  685. selector: "codeGeneratorClass",
  686. fn: function (){
  687. var self=this;
  688. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  689. return smalltalk.withContext(function($ctx1) {
  690. var $1;
  691. $1=$InliningCodeGenerator();
  692. return $1;
  693. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  694. messageSends: []}),
  695. smalltalk.InliningCodeGeneratorTest);
  696. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  697. smalltalk.addMethod(
  698. smalltalk.method({
  699. selector: "testClassRefVar",
  700. fn: function (){
  701. var self=this;
  702. var node;
  703. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  704. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  705. return smalltalk.withContext(function($ctx1) {
  706. var $1,$2;
  707. $1=_st($ClassReferenceNode())._new();
  708. _st($1)._value_("Object");
  709. $2=_st($1)._yourself();
  710. node=$2;
  711. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  712. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  713. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  714. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  715. smalltalk.ScopeVarTest);
  716. smalltalk.addMethod(
  717. smalltalk.method({
  718. selector: "testInstanceVar",
  719. fn: function (){
  720. var self=this;
  721. var node,scope;
  722. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  723. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  724. return smalltalk.withContext(function($ctx1) {
  725. var $1,$2;
  726. $1=_st($VariableNode())._new();
  727. _st($1)._value_("bzzz");
  728. $2=_st($1)._yourself();
  729. node=$2;
  730. scope=_st($MethodLexicalScope())._new();
  731. _st(scope)._addIVar_("bzzz");
  732. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  733. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  734. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  735. smalltalk.ScopeVarTest);
  736. smalltalk.addMethod(
  737. smalltalk.method({
  738. selector: "testPseudoVar",
  739. fn: function (){
  740. var self=this;
  741. var node,pseudoVars;
  742. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  743. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  744. return smalltalk.withContext(function($ctx1) {
  745. var $1,$2;
  746. pseudoVars=["self", "super", "true", "false", "nil"];
  747. _st(pseudoVars)._do_((function(each){
  748. return smalltalk.withContext(function($ctx2) {
  749. $1=_st($VariableNode())._new();
  750. _st($1)._value_(each);
  751. $2=_st($1)._yourself();
  752. node=$2;
  753. node;
  754. return _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  755. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  756. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  757. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  758. smalltalk.ScopeVarTest);
  759. smalltalk.addMethod(
  760. smalltalk.method({
  761. selector: "testTempVar",
  762. fn: function (){
  763. var self=this;
  764. var node,scope;
  765. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  766. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  767. return smalltalk.withContext(function($ctx1) {
  768. var $1,$2;
  769. $1=_st($VariableNode())._new();
  770. _st($1)._value_("bzzz");
  771. $2=_st($1)._yourself();
  772. node=$2;
  773. scope=_st($MethodLexicalScope())._new();
  774. _st(scope)._addTemp_("bzzz");
  775. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  776. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  777. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  778. smalltalk.ScopeVarTest);
  779. smalltalk.addMethod(
  780. smalltalk.method({
  781. selector: "testUnknownVar",
  782. fn: function (){
  783. var self=this;
  784. var node;
  785. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  786. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  787. return smalltalk.withContext(function($ctx1) {
  788. var $1,$2;
  789. $1=_st($VariableNode())._new();
  790. _st($1)._value_("bzzz");
  791. $2=_st($1)._yourself();
  792. node=$2;
  793. _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  794. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  795. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  796. smalltalk.ScopeVarTest);
  797. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  798. smalltalk.addMethod(
  799. smalltalk.method({
  800. selector: "setUp",
  801. fn: function (){
  802. var self=this;
  803. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  804. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  805. return smalltalk.withContext(function($ctx1) {
  806. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  807. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  808. messageSends: ["on:"]}),
  809. smalltalk.SemanticAnalyzerTest);
  810. smalltalk.addMethod(
  811. smalltalk.method({
  812. selector: "testAssignment",
  813. fn: function (){
  814. var self=this;
  815. var src,ast;
  816. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  817. return smalltalk.withContext(function($ctx1) {
  818. src="foo self := 1";
  819. ast=_st(smalltalk)._parse_(src);
  820. _st(self)._should_raise_((function(){
  821. return smalltalk.withContext(function($ctx2) {
  822. return _st(self["@analyzer"])._visit_(ast);
  823. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$InvalidAssignmentError());
  824. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  825. messageSends: ["parse:", "should:raise:", "visit:"]}),
  826. smalltalk.SemanticAnalyzerTest);
  827. smalltalk.addMethod(
  828. smalltalk.method({
  829. selector: "testNonLocalReturn",
  830. fn: function (){
  831. var self=this;
  832. var src,ast;
  833. return smalltalk.withContext(function($ctx1) {
  834. src="foo | a | a + 1. ^ a";
  835. ast=_st(smalltalk)._parse_(src);
  836. _st(self["@analyzer"])._visit_(ast);
  837. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  838. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  839. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  840. smalltalk.SemanticAnalyzerTest);
  841. smalltalk.addMethod(
  842. smalltalk.method({
  843. selector: "testNonLocalReturn2",
  844. fn: function (){
  845. var self=this;
  846. var src,ast;
  847. return smalltalk.withContext(function($ctx1) {
  848. src="foo | a | a + 1. [ [ ^ a] ]";
  849. ast=_st(smalltalk)._parse_(src);
  850. _st(self["@analyzer"])._visit_(ast);
  851. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  852. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  853. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  854. smalltalk.SemanticAnalyzerTest);
  855. smalltalk.addMethod(
  856. smalltalk.method({
  857. selector: "testScope",
  858. fn: function (){
  859. var self=this;
  860. var src,ast;
  861. return smalltalk.withContext(function($ctx1) {
  862. src="foo | a | a + 1. [ | b | b := a ]";
  863. ast=_st(smalltalk)._parse_(src);
  864. _st(self["@analyzer"])._visit_(ast);
  865. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  866. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  867. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  868. smalltalk.SemanticAnalyzerTest);
  869. smalltalk.addMethod(
  870. smalltalk.method({
  871. selector: "testScope2",
  872. fn: function (){
  873. var self=this;
  874. var src,ast;
  875. return smalltalk.withContext(function($ctx1) {
  876. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  877. ast=_st(smalltalk)._parse_(src);
  878. _st(self["@analyzer"])._visit_(ast);
  879. _st(self)._deny_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope()).__eq_eq(_st(ast)._scope()));
  880. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  881. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  882. smalltalk.SemanticAnalyzerTest);
  883. smalltalk.addMethod(
  884. smalltalk.method({
  885. selector: "testScopeLevel",
  886. fn: function (){
  887. var self=this;
  888. var src,ast;
  889. return smalltalk.withContext(function($ctx1) {
  890. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  891. ast=_st(smalltalk)._parse_(src);
  892. _st(self["@analyzer"])._visit_(ast);
  893. _st(self)._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  894. _st(self)._assert_equals_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope())._scopeLevel(),(3));
  895. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  896. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  897. smalltalk.SemanticAnalyzerTest);
  898. smalltalk.addMethod(
  899. smalltalk.method({
  900. selector: "testUnknownVariables",
  901. fn: function (){
  902. var self=this;
  903. var src,ast;
  904. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  905. return smalltalk.withContext(function($ctx1) {
  906. src="foo | a | b + a";
  907. ast=_st(smalltalk)._parse_(src);
  908. _st(self)._should_raise_((function(){
  909. return smalltalk.withContext(function($ctx2) {
  910. return _st(self["@analyzer"])._visit_(ast);
  911. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  912. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  913. messageSends: ["parse:", "should:raise:", "visit:"]}),
  914. smalltalk.SemanticAnalyzerTest);
  915. smalltalk.addMethod(
  916. smalltalk.method({
  917. selector: "testUnknownVariablesWithScope",
  918. fn: function (){
  919. var self=this;
  920. var src,ast;
  921. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  922. return smalltalk.withContext(function($ctx1) {
  923. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  924. ast=_st(smalltalk)._parse_(src);
  925. _st(self)._should_raise_((function(){
  926. return smalltalk.withContext(function($ctx2) {
  927. return _st(self["@analyzer"])._visit_(ast);
  928. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  929. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  930. messageSends: ["parse:", "should:raise:", "visit:"]}),
  931. smalltalk.SemanticAnalyzerTest);
  932. smalltalk.addMethod(
  933. smalltalk.method({
  934. selector: "testVariableShadowing",
  935. fn: function (){
  936. var self=this;
  937. var src,ast;
  938. return smalltalk.withContext(function($ctx1) {
  939. src="foo | a | a + 1";
  940. ast=_st(smalltalk)._parse_(src);
  941. _st(self["@analyzer"])._visit_(ast);
  942. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  943. messageSends: ["parse:", "visit:"]}),
  944. smalltalk.SemanticAnalyzerTest);
  945. smalltalk.addMethod(
  946. smalltalk.method({
  947. selector: "testVariableShadowing2",
  948. fn: function (){
  949. var self=this;
  950. var src,ast;
  951. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  952. return smalltalk.withContext(function($ctx1) {
  953. src="foo | a | a + 1. [ | a | a := 2 ]";
  954. ast=_st(smalltalk)._parse_(src);
  955. _st(self)._should_raise_((function(){
  956. return smalltalk.withContext(function($ctx2) {
  957. return _st(self["@analyzer"])._visit_(ast);
  958. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  959. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  960. messageSends: ["parse:", "should:raise:", "visit:"]}),
  961. smalltalk.SemanticAnalyzerTest);
  962. smalltalk.addMethod(
  963. smalltalk.method({
  964. selector: "testVariableShadowing3",
  965. fn: function (){
  966. var self=this;
  967. var src,ast;
  968. return smalltalk.withContext(function($ctx1) {
  969. src="foo | a | a + 1. [ | b | b := 2 ]";
  970. ast=_st(smalltalk)._parse_(src);
  971. _st(self["@analyzer"])._visit_(ast);
  972. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  973. messageSends: ["parse:", "visit:"]}),
  974. smalltalk.SemanticAnalyzerTest);
  975. smalltalk.addMethod(
  976. smalltalk.method({
  977. selector: "testVariableShadowing4",
  978. fn: function (){
  979. var self=this;
  980. var src,ast;
  981. return smalltalk.withContext(function($ctx1) {
  982. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  983. ast=_st(smalltalk)._parse_(src);
  984. _st(self["@analyzer"])._visit_(ast);
  985. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  986. messageSends: ["parse:", "visit:"]}),
  987. smalltalk.SemanticAnalyzerTest);
  988. smalltalk.addMethod(
  989. smalltalk.method({
  990. selector: "testVariableShadowing5",
  991. fn: function (){
  992. var self=this;
  993. var src,ast;
  994. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  995. return smalltalk.withContext(function($ctx1) {
  996. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  997. ast=_st(smalltalk)._parse_(src);
  998. _st(self)._should_raise_((function(){
  999. return smalltalk.withContext(function($ctx2) {
  1000. return _st(self["@analyzer"])._visit_(ast);
  1001. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1002. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1003. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1004. smalltalk.SemanticAnalyzerTest);
  1005. smalltalk.addMethod(
  1006. smalltalk.method({
  1007. selector: "testVariablesLookup",
  1008. fn: function (){
  1009. var self=this;
  1010. var src,ast;
  1011. return smalltalk.withContext(function($ctx1) {
  1012. src="foo | a | a + 1. [ | b | b := a ]";
  1013. ast=_st(smalltalk)._parse_(src);
  1014. _st(self["@analyzer"])._visit_(ast);
  1015. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1016. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1017. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._isTempVar());
  1018. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._scope()).__eq_eq(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()));
  1019. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1020. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  1021. smalltalk.SemanticAnalyzerTest);