2
0

Compiler-Tests.deploy.js 43 KB

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