Compiler-Tests.deploy.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  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. "_testSendReceiverAndArgumentsOrdered",
  518. smalltalk.method({
  519. selector: "testSendReceiverAndArgumentsOrdered",
  520. fn: function (){
  521. var self=this;
  522. 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)]);
  523. _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)]);
  524. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  525. messageSends: ["should:return:"]}),
  526. smalltalk.CodeGeneratorTest);
  527. smalltalk.addMethod(
  528. "_testifFalse",
  529. smalltalk.method({
  530. selector: "testifFalse",
  531. fn: function (){
  532. var self=this;
  533. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  534. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  535. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  536. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  537. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  538. messageSends: ["should:return:"]}),
  539. smalltalk.CodeGeneratorTest);
  540. smalltalk.addMethod(
  541. "_testifFalseIfTrue",
  542. smalltalk.method({
  543. selector: "testifFalseIfTrue",
  544. fn: function (){
  545. var self=this;
  546. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  547. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  548. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  549. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  550. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  551. messageSends: ["should:return:"]}),
  552. smalltalk.CodeGeneratorTest);
  553. smalltalk.addMethod(
  554. "_testifNil",
  555. smalltalk.method({
  556. selector: "testifNil",
  557. fn: function (){
  558. var self=this;
  559. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  560. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  561. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  562. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  563. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  564. messageSends: ["should:return:"]}),
  565. smalltalk.CodeGeneratorTest);
  566. smalltalk.addMethod(
  567. "_testifNilIfNotNil",
  568. smalltalk.method({
  569. selector: "testifNilIfNotNil",
  570. fn: function (){
  571. var self=this;
  572. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  573. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  574. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  575. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  576. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  577. messageSends: ["should:return:"]}),
  578. smalltalk.CodeGeneratorTest);
  579. smalltalk.addMethod(
  580. "_testifNotNil",
  581. smalltalk.method({
  582. selector: "testifNotNil",
  583. fn: function (){
  584. var self=this;
  585. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  586. _st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  587. _st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  588. _st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  589. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  590. messageSends: ["should:return:"]}),
  591. smalltalk.CodeGeneratorTest);
  592. smalltalk.addMethod(
  593. "_testifTrue",
  594. smalltalk.method({
  595. selector: "testifTrue",
  596. fn: function (){
  597. var self=this;
  598. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  599. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  600. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  601. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  602. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  603. messageSends: ["should:return:"]}),
  604. smalltalk.CodeGeneratorTest);
  605. smalltalk.addMethod(
  606. "_testifTrueIfFalse",
  607. smalltalk.method({
  608. selector: "testifTrueIfFalse",
  609. fn: function (){
  610. var self=this;
  611. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  612. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  613. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  614. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  615. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  616. messageSends: ["should:return:"]}),
  617. smalltalk.CodeGeneratorTest);
  618. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  619. smalltalk.addMethod(
  620. "_codeGeneratorClass",
  621. smalltalk.method({
  622. selector: "codeGeneratorClass",
  623. fn: function (){
  624. var self=this;
  625. return smalltalk.withContext(function($ctx1) { var $1;
  626. $1=(smalltalk.InliningCodeGenerator || InliningCodeGenerator);
  627. return $1;
  628. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  629. messageSends: []}),
  630. smalltalk.InliningCodeGeneratorTest);
  631. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  632. smalltalk.addMethod(
  633. "_testClassRefVar",
  634. smalltalk.method({
  635. selector: "testClassRefVar",
  636. fn: function (){
  637. var self=this;
  638. var node;
  639. return smalltalk.withContext(function($ctx1) { var $1,$2;
  640. $1=_st((smalltalk.ClassReferenceNode || ClassReferenceNode))._new();
  641. _st($1)._value_("Object");
  642. $2=_st($1)._yourself();
  643. node=$2;
  644. _st(_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._new())._visit_(node);
  645. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  646. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  647. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  648. smalltalk.ScopeVarTest);
  649. smalltalk.addMethod(
  650. "_testInstanceVar",
  651. smalltalk.method({
  652. selector: "testInstanceVar",
  653. fn: function (){
  654. var self=this;
  655. var node,scope;
  656. return smalltalk.withContext(function($ctx1) { var $1,$2;
  657. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  658. _st($1)._value_("bzzz");
  659. $2=_st($1)._yourself();
  660. node=$2;
  661. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  662. _st(scope)._addIVar_("bzzz");
  663. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  664. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  665. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  666. smalltalk.ScopeVarTest);
  667. smalltalk.addMethod(
  668. "_testPseudoVar",
  669. smalltalk.method({
  670. selector: "testPseudoVar",
  671. fn: function (){
  672. var self=this;
  673. var node,pseudoVars;
  674. return smalltalk.withContext(function($ctx1) { var $1,$2;
  675. pseudoVars=["self", "super", "true", "false", "nil"];
  676. _st(pseudoVars)._do_((function(each){
  677. return smalltalk.withContext(function($ctx2) { $1=_st((smalltalk.VariableNode || VariableNode))._new();
  678. _st($1)._value_(each);
  679. $2=_st($1)._yourself();
  680. node=$2;
  681. node;
  682. return _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isPseudoVar());
  683. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  684. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  685. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  686. smalltalk.ScopeVarTest);
  687. smalltalk.addMethod(
  688. "_testTempVar",
  689. smalltalk.method({
  690. selector: "testTempVar",
  691. fn: function (){
  692. var self=this;
  693. var node,scope;
  694. return smalltalk.withContext(function($ctx1) { var $1,$2;
  695. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  696. _st($1)._value_("bzzz");
  697. $2=_st($1)._yourself();
  698. node=$2;
  699. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  700. _st(scope)._addTemp_("bzzz");
  701. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  702. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  703. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  704. smalltalk.ScopeVarTest);
  705. smalltalk.addMethod(
  706. "_testUnknownVar",
  707. smalltalk.method({
  708. selector: "testUnknownVar",
  709. fn: function (){
  710. var self=this;
  711. var node;
  712. return smalltalk.withContext(function($ctx1) { var $1,$2;
  713. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  714. _st($1)._value_("bzzz");
  715. $2=_st($1)._yourself();
  716. node=$2;
  717. _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isNil());
  718. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  719. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  720. smalltalk.ScopeVarTest);
  721. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  722. smalltalk.addMethod(
  723. "_setUp",
  724. smalltalk.method({
  725. selector: "setUp",
  726. fn: function (){
  727. var self=this;
  728. return smalltalk.withContext(function($ctx1) { self["@analyzer"]=_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._on_((smalltalk.Object || Object));
  729. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  730. messageSends: ["on:"]}),
  731. smalltalk.SemanticAnalyzerTest);
  732. smalltalk.addMethod(
  733. "_testAssignment",
  734. smalltalk.method({
  735. selector: "testAssignment",
  736. fn: function (){
  737. var self=this;
  738. var src,ast;
  739. return smalltalk.withContext(function($ctx1) { src="foo self := 1";
  740. ast=_st(smalltalk)._parse_(src);
  741. _st(self)._should_raise_((function(){
  742. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  743. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.InvalidAssignmentError || InvalidAssignmentError));
  744. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  745. messageSends: ["parse:", "should:raise:", "visit:"]}),
  746. smalltalk.SemanticAnalyzerTest);
  747. smalltalk.addMethod(
  748. "_testNonLocalReturn",
  749. smalltalk.method({
  750. selector: "testNonLocalReturn",
  751. fn: function (){
  752. var self=this;
  753. var src,ast;
  754. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. ^ a";
  755. ast=_st(smalltalk)._parse_(src);
  756. _st(self["@analyzer"])._visit_(ast);
  757. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  758. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  759. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  760. smalltalk.SemanticAnalyzerTest);
  761. smalltalk.addMethod(
  762. "_testNonLocalReturn2",
  763. smalltalk.method({
  764. selector: "testNonLocalReturn2",
  765. fn: function (){
  766. var self=this;
  767. var src,ast;
  768. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ ^ a] ]";
  769. ast=_st(smalltalk)._parse_(src);
  770. _st(self["@analyzer"])._visit_(ast);
  771. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  772. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  773. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  774. smalltalk.SemanticAnalyzerTest);
  775. smalltalk.addMethod(
  776. "_testScope",
  777. smalltalk.method({
  778. selector: "testScope",
  779. fn: function (){
  780. var self=this;
  781. var src,ast;
  782. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  783. ast=_st(smalltalk)._parse_(src);
  784. _st(self["@analyzer"])._visit_(ast);
  785. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  786. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  787. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  788. smalltalk.SemanticAnalyzerTest);
  789. smalltalk.addMethod(
  790. "_testScope2",
  791. smalltalk.method({
  792. selector: "testScope2",
  793. fn: function (){
  794. var self=this;
  795. var src,ast;
  796. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  797. ast=_st(smalltalk)._parse_(src);
  798. _st(self["@analyzer"])._visit_(ast);
  799. _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()));
  800. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  801. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  802. smalltalk.SemanticAnalyzerTest);
  803. smalltalk.addMethod(
  804. "_testScopeLevel",
  805. smalltalk.method({
  806. selector: "testScopeLevel",
  807. fn: function (){
  808. var self=this;
  809. var src,ast;
  810. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  811. ast=_st(smalltalk)._parse_(src);
  812. _st(self["@analyzer"])._visit_(ast);
  813. _st(self)._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  814. _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));
  815. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  816. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  817. smalltalk.SemanticAnalyzerTest);
  818. smalltalk.addMethod(
  819. "_testUnknownVariables",
  820. smalltalk.method({
  821. selector: "testUnknownVariables",
  822. fn: function (){
  823. var self=this;
  824. var src,ast;
  825. return smalltalk.withContext(function($ctx1) { src="foo | a | b + a";
  826. ast=_st(smalltalk)._parse_(src);
  827. _st(self)._should_raise_((function(){
  828. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  829. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  830. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  831. messageSends: ["parse:", "should:raise:", "visit:"]}),
  832. smalltalk.SemanticAnalyzerTest);
  833. smalltalk.addMethod(
  834. "_testUnknownVariablesWithScope",
  835. smalltalk.method({
  836. selector: "testUnknownVariablesWithScope",
  837. fn: function (){
  838. var self=this;
  839. var src,ast;
  840. return smalltalk.withContext(function($ctx1) { src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  841. ast=_st(smalltalk)._parse_(src);
  842. _st(self)._should_raise_((function(){
  843. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  844. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  845. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  846. messageSends: ["parse:", "should:raise:", "visit:"]}),
  847. smalltalk.SemanticAnalyzerTest);
  848. smalltalk.addMethod(
  849. "_testVariableShadowing",
  850. smalltalk.method({
  851. selector: "testVariableShadowing",
  852. fn: function (){
  853. var self=this;
  854. var src,ast;
  855. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1";
  856. ast=_st(smalltalk)._parse_(src);
  857. _st(self["@analyzer"])._visit_(ast);
  858. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  859. messageSends: ["parse:", "visit:"]}),
  860. smalltalk.SemanticAnalyzerTest);
  861. smalltalk.addMethod(
  862. "_testVariableShadowing2",
  863. smalltalk.method({
  864. selector: "testVariableShadowing2",
  865. fn: function (){
  866. var self=this;
  867. var src,ast;
  868. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | a | a := 2 ]";
  869. ast=_st(smalltalk)._parse_(src);
  870. _st(self)._should_raise_((function(){
  871. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  872. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
  873. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  874. messageSends: ["parse:", "should:raise:", "visit:"]}),
  875. smalltalk.SemanticAnalyzerTest);
  876. smalltalk.addMethod(
  877. "_testVariableShadowing3",
  878. smalltalk.method({
  879. selector: "testVariableShadowing3",
  880. fn: function (){
  881. var self=this;
  882. var src,ast;
  883. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := 2 ]";
  884. ast=_st(smalltalk)._parse_(src);
  885. _st(self["@analyzer"])._visit_(ast);
  886. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  887. messageSends: ["parse:", "visit:"]}),
  888. smalltalk.SemanticAnalyzerTest);
  889. smalltalk.addMethod(
  890. "_testVariableShadowing4",
  891. smalltalk.method({
  892. selector: "testVariableShadowing4",
  893. fn: function (){
  894. var self=this;
  895. var src,ast;
  896. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  897. ast=_st(smalltalk)._parse_(src);
  898. _st(self["@analyzer"])._visit_(ast);
  899. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  900. messageSends: ["parse:", "visit:"]}),
  901. smalltalk.SemanticAnalyzerTest);
  902. smalltalk.addMethod(
  903. "_testVariableShadowing5",
  904. smalltalk.method({
  905. selector: "testVariableShadowing5",
  906. fn: function (){
  907. var self=this;
  908. var src,ast;
  909. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  910. ast=_st(smalltalk)._parse_(src);
  911. _st(self)._should_raise_((function(){
  912. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  913. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
  914. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  915. messageSends: ["parse:", "should:raise:", "visit:"]}),
  916. smalltalk.SemanticAnalyzerTest);
  917. smalltalk.addMethod(
  918. "_testVariablesLookup",
  919. smalltalk.method({
  920. selector: "testVariablesLookup",
  921. fn: function (){
  922. var self=this;
  923. var src,ast;
  924. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  925. ast=_st(smalltalk)._parse_(src);
  926. _st(self["@analyzer"])._visit_(ast);
  927. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  928. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  929. _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());
  930. _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()));
  931. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  932. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  933. smalltalk.SemanticAnalyzerTest);