Compiler-Tests.deploy.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  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. }),
  223. smalltalk.ASTInterpreterTest);
  224. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  225. smalltalk.addMethod(
  226. "_codeGeneratorClass",
  227. smalltalk.method({
  228. selector: "codeGeneratorClass",
  229. fn: function (){
  230. var self=this;
  231. return smalltalk.withContext(function($ctx1) { var $1;
  232. $1=(smalltalk.CodeGenerator || CodeGenerator);
  233. return $1;
  234. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.CodeGeneratorTest)})}
  235. }),
  236. smalltalk.CodeGeneratorTest);
  237. smalltalk.addMethod(
  238. "_compiler",
  239. smalltalk.method({
  240. selector: "compiler",
  241. fn: function (){
  242. var self=this;
  243. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  244. $2=_st((smalltalk.Compiler || Compiler))._new();
  245. _st($2)._codeGeneratorClass_(_st(self)._codeGeneratorClass());
  246. $3=_st($2)._yourself();
  247. $1=$3;
  248. return $1;
  249. }, function($ctx1) {$ctx1.fill(self,"compiler",{}, smalltalk.CodeGeneratorTest)})}
  250. }),
  251. smalltalk.CodeGeneratorTest);
  252. smalltalk.addMethod(
  253. "_setUp",
  254. smalltalk.method({
  255. selector: "setUp",
  256. fn: function (){
  257. var self=this;
  258. return smalltalk.withContext(function($ctx1) { self["@receiver"]=_st(_st(self)._targetClass())._new();
  259. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.CodeGeneratorTest)})}
  260. }),
  261. smalltalk.CodeGeneratorTest);
  262. smalltalk.addMethod(
  263. "_should_return_",
  264. smalltalk.method({
  265. selector: "should:return:",
  266. fn: function (aString,anObject){
  267. var self=this;
  268. var method,result;
  269. return smalltalk.withContext(function($ctx1) { method=_st(_st(self)._compiler())._install_forClass_category_(aString,_st(self)._targetClass(),"tests");
  270. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  271. _st(_st(self)._targetClass())._removeCompiledMethod_(method);
  272. _st(self)._assert_equals_(anObject,result);
  273. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result}, smalltalk.CodeGeneratorTest)})}
  274. }),
  275. smalltalk.CodeGeneratorTest);
  276. smalltalk.addMethod(
  277. "_targetClass",
  278. smalltalk.method({
  279. selector: "targetClass",
  280. fn: function (){
  281. var self=this;
  282. return smalltalk.withContext(function($ctx1) { var $1;
  283. $1=(smalltalk.DoIt || DoIt);
  284. return $1;
  285. }, function($ctx1) {$ctx1.fill(self,"targetClass",{}, smalltalk.CodeGeneratorTest)})}
  286. }),
  287. smalltalk.CodeGeneratorTest);
  288. smalltalk.addMethod(
  289. "_tearDown",
  290. smalltalk.method({
  291. selector: "tearDown",
  292. fn: function (){
  293. var self=this;
  294. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{}, smalltalk.CodeGeneratorTest)})}
  295. }),
  296. smalltalk.CodeGeneratorTest);
  297. smalltalk.addMethod(
  298. "_testAssignment",
  299. smalltalk.method({
  300. selector: "testAssignment",
  301. fn: function (){
  302. var self=this;
  303. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  304. _st(self)._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  305. _st(self)._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  306. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{}, smalltalk.CodeGeneratorTest)})}
  307. }),
  308. smalltalk.CodeGeneratorTest);
  309. smalltalk.addMethod(
  310. "_testBlockReturn",
  311. smalltalk.method({
  312. selector: "testBlockReturn",
  313. fn: function (){
  314. var self=this;
  315. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  316. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  317. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  318. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{}, smalltalk.CodeGeneratorTest)})}
  319. }),
  320. smalltalk.CodeGeneratorTest);
  321. smalltalk.addMethod(
  322. "_testCascades",
  323. smalltalk.method({
  324. selector: "testCascades",
  325. fn: function (){
  326. var self=this;
  327. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  328. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{}, smalltalk.CodeGeneratorTest)})}
  329. }),
  330. smalltalk.CodeGeneratorTest);
  331. smalltalk.addMethod(
  332. "_testDynamicArrayElementsOrdered",
  333. smalltalk.method({
  334. selector: "testDynamicArrayElementsOrdered",
  335. fn: function (){
  336. var self=this;
  337. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  338. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  339. }),
  340. smalltalk.CodeGeneratorTest);
  341. smalltalk.addMethod(
  342. "_testDynamicDictionaryElementsOrdered",
  343. smalltalk.method({
  344. selector: "testDynamicDictionaryElementsOrdered",
  345. fn: function (){
  346. var self=this;
  347. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := 'foo'->1.\x0a ^ #{ x. (true ifTrue: [ x := 'bar'->2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  348. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  349. }),
  350. smalltalk.CodeGeneratorTest);
  351. smalltalk.addMethod(
  352. "_testInnerTemporalDependentElementsOrdered",
  353. smalltalk.method({
  354. selector: "testInnerTemporalDependentElementsOrdered",
  355. fn: function (){
  356. var self=this;
  357. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := Array.\x0a ^ x with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt((smalltalk.Array || Array)),_st("bar").__minus_gt((2))]);
  358. _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  359. _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  360. _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  361. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  362. }),
  363. smalltalk.CodeGeneratorTest);
  364. smalltalk.addMethod(
  365. "_testLiterals",
  366. smalltalk.method({
  367. selector: "testLiterals",
  368. fn: function (){
  369. var self=this;
  370. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  371. _st(self)._should_return_("foo ^ 'hello'","hello");
  372. _st(self)._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  373. _st(self)._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  374. _st(self)._should_return_("foo ^ true",true);
  375. _st(self)._should_return_("foo ^ false",false);
  376. _st(self)._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((2)),_st((3)).__minus_gt((4))]));
  377. _st(self)._should_return_("foo ^ #hello",smalltalk.symbolFor("hello"));
  378. _st(self)._should_return_("foo ^ -123.456",(-123.456));
  379. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{}, smalltalk.CodeGeneratorTest)})}
  380. }),
  381. smalltalk.CodeGeneratorTest);
  382. smalltalk.addMethod(
  383. "_testLocalReturn",
  384. smalltalk.method({
  385. selector: "testLocalReturn",
  386. fn: function (){
  387. var self=this;
  388. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  389. _st(self)._should_return_("foo ^ 1 + 1",(2));
  390. _st(self)._should_return_("foo ",self["@receiver"]);
  391. _st(self)._should_return_("foo self asString",self["@receiver"]);
  392. _st(self)._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  393. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{}, smalltalk.CodeGeneratorTest)})}
  394. }),
  395. smalltalk.CodeGeneratorTest);
  396. smalltalk.addMethod(
  397. "_testMessageSends",
  398. smalltalk.method({
  399. selector: "testMessageSends",
  400. fn: function (){
  401. var self=this;
  402. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 asString","1");
  403. _st(self)._should_return_("foo ^ 1 + 1",(2));
  404. _st(self)._should_return_("foo ^ 1 + 2 * 3",(9));
  405. _st(self)._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  406. _st(self)._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  407. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{}, smalltalk.CodeGeneratorTest)})}
  408. }),
  409. smalltalk.CodeGeneratorTest);
  410. smalltalk.addMethod(
  411. "_testNestedIfTrue",
  412. smalltalk.method({
  413. selector: "testNestedIfTrue",
  414. fn: function (){
  415. var self=this;
  416. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  417. _st(self)._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  418. _st(self)._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  419. _st(self)._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  420. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{}, smalltalk.CodeGeneratorTest)})}
  421. }),
  422. smalltalk.CodeGeneratorTest);
  423. smalltalk.addMethod(
  424. "_testNonLocalReturn",
  425. smalltalk.method({
  426. selector: "testNonLocalReturn",
  427. fn: function (){
  428. var self=this;
  429. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo [ ^ 1 ] value",(1));
  430. _st(self)._should_return_("foo [ ^ 1 + 1 ] value",(2));
  431. _st(self)._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  432. _st(self)._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  433. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{}, smalltalk.CodeGeneratorTest)})}
  434. }),
  435. smalltalk.CodeGeneratorTest);
  436. smalltalk.addMethod(
  437. "_testSendReceiverAndArgumentsOrdered",
  438. smalltalk.method({
  439. selector: "testSendReceiverAndArgumentsOrdered",
  440. fn: function (){
  441. var self=this;
  442. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a | x |\x0a x := 1.\x0a ^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  443. _st(self)._should_return_("foo\x0a | x |\x0a x := Array.\x0a ^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[(smalltalk.Array || Array),(2)]);
  444. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{}, smalltalk.CodeGeneratorTest)})}
  445. }),
  446. smalltalk.CodeGeneratorTest);
  447. smalltalk.addMethod(
  448. "_testifFalse",
  449. smalltalk.method({
  450. selector: "testifFalse",
  451. fn: function (){
  452. var self=this;
  453. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  454. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  455. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  456. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  457. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{}, smalltalk.CodeGeneratorTest)})}
  458. }),
  459. smalltalk.CodeGeneratorTest);
  460. smalltalk.addMethod(
  461. "_testifFalseIfTrue",
  462. smalltalk.method({
  463. selector: "testifFalseIfTrue",
  464. fn: function (){
  465. var self=this;
  466. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  467. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  468. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  469. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  470. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{}, smalltalk.CodeGeneratorTest)})}
  471. }),
  472. smalltalk.CodeGeneratorTest);
  473. smalltalk.addMethod(
  474. "_testifNil",
  475. smalltalk.method({
  476. selector: "testifNil",
  477. fn: function (){
  478. var self=this;
  479. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  480. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  481. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  482. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  483. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{}, smalltalk.CodeGeneratorTest)})}
  484. }),
  485. smalltalk.CodeGeneratorTest);
  486. smalltalk.addMethod(
  487. "_testifNilIfNotNil",
  488. smalltalk.method({
  489. selector: "testifNilIfNotNil",
  490. fn: function (){
  491. var self=this;
  492. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  493. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  494. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  495. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  496. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{}, smalltalk.CodeGeneratorTest)})}
  497. }),
  498. smalltalk.CodeGeneratorTest);
  499. smalltalk.addMethod(
  500. "_testifNotNil",
  501. smalltalk.method({
  502. selector: "testifNotNil",
  503. fn: function (){
  504. var self=this;
  505. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  506. _st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  507. _st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  508. _st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  509. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{}, smalltalk.CodeGeneratorTest)})}
  510. }),
  511. smalltalk.CodeGeneratorTest);
  512. smalltalk.addMethod(
  513. "_testifTrue",
  514. smalltalk.method({
  515. selector: "testifTrue",
  516. fn: function (){
  517. var self=this;
  518. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  519. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  520. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  521. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  522. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{}, smalltalk.CodeGeneratorTest)})}
  523. }),
  524. smalltalk.CodeGeneratorTest);
  525. smalltalk.addMethod(
  526. "_testifTrueIfFalse",
  527. smalltalk.method({
  528. selector: "testifTrueIfFalse",
  529. fn: function (){
  530. var self=this;
  531. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  532. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  533. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  534. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  535. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{}, smalltalk.CodeGeneratorTest)})}
  536. }),
  537. smalltalk.CodeGeneratorTest);
  538. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  539. smalltalk.addMethod(
  540. "_codeGeneratorClass",
  541. smalltalk.method({
  542. selector: "codeGeneratorClass",
  543. fn: function (){
  544. var self=this;
  545. return smalltalk.withContext(function($ctx1) { var $1;
  546. $1=(smalltalk.InliningCodeGenerator || InliningCodeGenerator);
  547. return $1;
  548. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{}, smalltalk.InliningCodeGeneratorTest)})}
  549. }),
  550. smalltalk.InliningCodeGeneratorTest);
  551. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  552. smalltalk.addMethod(
  553. "_testClassRefVar",
  554. smalltalk.method({
  555. selector: "testClassRefVar",
  556. fn: function (){
  557. var self=this;
  558. var node;
  559. return smalltalk.withContext(function($ctx1) { var $1,$2;
  560. $1=_st((smalltalk.ClassReferenceNode || ClassReferenceNode))._new();
  561. _st($1)._value_("Object");
  562. $2=_st($1)._yourself();
  563. node=$2;
  564. _st(_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._new())._visit_(node);
  565. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  566. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node}, smalltalk.ScopeVarTest)})}
  567. }),
  568. smalltalk.ScopeVarTest);
  569. smalltalk.addMethod(
  570. "_testInstanceVar",
  571. smalltalk.method({
  572. selector: "testInstanceVar",
  573. fn: function (){
  574. var self=this;
  575. var node,scope;
  576. return smalltalk.withContext(function($ctx1) { var $1,$2;
  577. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  578. _st($1)._value_("bzzz");
  579. $2=_st($1)._yourself();
  580. node=$2;
  581. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  582. _st(scope)._addIVar_("bzzz");
  583. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  584. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})}
  585. }),
  586. smalltalk.ScopeVarTest);
  587. smalltalk.addMethod(
  588. "_testPseudoVar",
  589. smalltalk.method({
  590. selector: "testPseudoVar",
  591. fn: function (){
  592. var self=this;
  593. var node,pseudoVars;
  594. return smalltalk.withContext(function($ctx1) { var $1,$2;
  595. pseudoVars=["self", "super", "true", "false", "nil"];
  596. _st(pseudoVars)._do_((function(each){
  597. return smalltalk.withContext(function($ctx2) { $1=_st((smalltalk.VariableNode || VariableNode))._new();
  598. _st($1)._value_(each);
  599. $2=_st($1)._yourself();
  600. node=$2;
  601. node;
  602. return _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isPseudoVar());
  603. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  604. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars}, smalltalk.ScopeVarTest)})}
  605. }),
  606. smalltalk.ScopeVarTest);
  607. smalltalk.addMethod(
  608. "_testTempVar",
  609. smalltalk.method({
  610. selector: "testTempVar",
  611. fn: function (){
  612. var self=this;
  613. var node,scope;
  614. return smalltalk.withContext(function($ctx1) { var $1,$2;
  615. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  616. _st($1)._value_("bzzz");
  617. $2=_st($1)._yourself();
  618. node=$2;
  619. scope=_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new();
  620. _st(scope)._addTemp_("bzzz");
  621. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  622. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope}, smalltalk.ScopeVarTest)})}
  623. }),
  624. smalltalk.ScopeVarTest);
  625. smalltalk.addMethod(
  626. "_testUnknownVar",
  627. smalltalk.method({
  628. selector: "testUnknownVar",
  629. fn: function (){
  630. var self=this;
  631. var node;
  632. return smalltalk.withContext(function($ctx1) { var $1,$2;
  633. $1=_st((smalltalk.VariableNode || VariableNode))._new();
  634. _st($1)._value_("bzzz");
  635. $2=_st($1)._yourself();
  636. node=$2;
  637. _st(self)._assert_(_st(_st(_st((smalltalk.MethodLexicalScope || MethodLexicalScope))._new())._bindingFor_(node))._isNil());
  638. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node}, smalltalk.ScopeVarTest)})}
  639. }),
  640. smalltalk.ScopeVarTest);
  641. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  642. smalltalk.addMethod(
  643. "_setUp",
  644. smalltalk.method({
  645. selector: "setUp",
  646. fn: function (){
  647. var self=this;
  648. return smalltalk.withContext(function($ctx1) { self["@analyzer"]=_st((smalltalk.SemanticAnalyzer || SemanticAnalyzer))._on_((smalltalk.Object || Object));
  649. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{}, smalltalk.SemanticAnalyzerTest)})}
  650. }),
  651. smalltalk.SemanticAnalyzerTest);
  652. smalltalk.addMethod(
  653. "_testAssignment",
  654. smalltalk.method({
  655. selector: "testAssignment",
  656. fn: function (){
  657. var self=this;
  658. var src,ast;
  659. return smalltalk.withContext(function($ctx1) { src="foo self := 1";
  660. ast=_st(smalltalk)._parse_(src);
  661. _st(self)._should_raise_((function(){
  662. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  663. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.InvalidAssignmentError || InvalidAssignmentError));
  664. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  665. }),
  666. smalltalk.SemanticAnalyzerTest);
  667. smalltalk.addMethod(
  668. "_testNonLocalReturn",
  669. smalltalk.method({
  670. selector: "testNonLocalReturn",
  671. fn: function (){
  672. var self=this;
  673. var src,ast;
  674. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. ^ a";
  675. ast=_st(smalltalk)._parse_(src);
  676. _st(self["@analyzer"])._visit_(ast);
  677. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  678. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  679. }),
  680. smalltalk.SemanticAnalyzerTest);
  681. smalltalk.addMethod(
  682. "_testNonLocalReturn2",
  683. smalltalk.method({
  684. selector: "testNonLocalReturn2",
  685. fn: function (){
  686. var self=this;
  687. var src,ast;
  688. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ ^ a] ]";
  689. ast=_st(smalltalk)._parse_(src);
  690. _st(self["@analyzer"])._visit_(ast);
  691. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  692. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  693. }),
  694. smalltalk.SemanticAnalyzerTest);
  695. smalltalk.addMethod(
  696. "_testScope",
  697. smalltalk.method({
  698. selector: "testScope",
  699. fn: function (){
  700. var self=this;
  701. var src,ast;
  702. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  703. ast=_st(smalltalk)._parse_(src);
  704. _st(self["@analyzer"])._visit_(ast);
  705. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  706. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  707. }),
  708. smalltalk.SemanticAnalyzerTest);
  709. smalltalk.addMethod(
  710. "_testScope2",
  711. smalltalk.method({
  712. selector: "testScope2",
  713. fn: function (){
  714. var self=this;
  715. var src,ast;
  716. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  717. ast=_st(smalltalk)._parse_(src);
  718. _st(self["@analyzer"])._visit_(ast);
  719. _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()));
  720. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  721. }),
  722. smalltalk.SemanticAnalyzerTest);
  723. smalltalk.addMethod(
  724. "_testScopeLevel",
  725. smalltalk.method({
  726. selector: "testScopeLevel",
  727. fn: function (){
  728. var self=this;
  729. var src,ast;
  730. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  731. ast=_st(smalltalk)._parse_(src);
  732. _st(self["@analyzer"])._visit_(ast);
  733. _st(self)._assert_(_st(_st(_st(ast)._scope())._scopeLevel()).__eq((1)));
  734. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope())._scopeLevel()).__eq((3)));
  735. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  736. }),
  737. smalltalk.SemanticAnalyzerTest);
  738. smalltalk.addMethod(
  739. "_testUnknownVariables",
  740. smalltalk.method({
  741. selector: "testUnknownVariables",
  742. fn: function (){
  743. var self=this;
  744. var src,ast;
  745. return smalltalk.withContext(function($ctx1) { src="foo | a | b + a";
  746. ast=_st(smalltalk)._parse_(src);
  747. _st(self)._should_raise_((function(){
  748. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  749. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  750. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  751. }),
  752. smalltalk.SemanticAnalyzerTest);
  753. smalltalk.addMethod(
  754. "_testUnknownVariablesWithScope",
  755. smalltalk.method({
  756. selector: "testUnknownVariablesWithScope",
  757. fn: function (){
  758. var self=this;
  759. var src,ast;
  760. return smalltalk.withContext(function($ctx1) { src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  761. ast=_st(smalltalk)._parse_(src);
  762. _st(self)._should_raise_((function(){
  763. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  764. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.UnknownVariableError || UnknownVariableError));
  765. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  766. }),
  767. smalltalk.SemanticAnalyzerTest);
  768. smalltalk.addMethod(
  769. "_testVariableShadowing",
  770. smalltalk.method({
  771. selector: "testVariableShadowing",
  772. fn: function (){
  773. var self=this;
  774. var src,ast;
  775. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1";
  776. ast=_st(smalltalk)._parse_(src);
  777. _st(self["@analyzer"])._visit_(ast);
  778. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  779. }),
  780. smalltalk.SemanticAnalyzerTest);
  781. smalltalk.addMethod(
  782. "_testVariableShadowing2",
  783. smalltalk.method({
  784. selector: "testVariableShadowing2",
  785. fn: function (){
  786. var self=this;
  787. var src,ast;
  788. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | a | a := 2 ]";
  789. ast=_st(smalltalk)._parse_(src);
  790. _st(self)._should_raise_((function(){
  791. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  792. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
  793. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  794. }),
  795. smalltalk.SemanticAnalyzerTest);
  796. smalltalk.addMethod(
  797. "_testVariableShadowing3",
  798. smalltalk.method({
  799. selector: "testVariableShadowing3",
  800. fn: function (){
  801. var self=this;
  802. var src,ast;
  803. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := 2 ]";
  804. ast=_st(smalltalk)._parse_(src);
  805. _st(self["@analyzer"])._visit_(ast);
  806. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  807. }),
  808. smalltalk.SemanticAnalyzerTest);
  809. smalltalk.addMethod(
  810. "_testVariableShadowing4",
  811. smalltalk.method({
  812. selector: "testVariableShadowing4",
  813. fn: function (){
  814. var self=this;
  815. var src,ast;
  816. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  817. ast=_st(smalltalk)._parse_(src);
  818. _st(self["@analyzer"])._visit_(ast);
  819. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  820. }),
  821. smalltalk.SemanticAnalyzerTest);
  822. smalltalk.addMethod(
  823. "_testVariableShadowing5",
  824. smalltalk.method({
  825. selector: "testVariableShadowing5",
  826. fn: function (){
  827. var self=this;
  828. var src,ast;
  829. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  830. ast=_st(smalltalk)._parse_(src);
  831. _st(self)._should_raise_((function(){
  832. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  833. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(smalltalk.ShadowingVariableError || ShadowingVariableError));
  834. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  835. }),
  836. smalltalk.SemanticAnalyzerTest);
  837. smalltalk.addMethod(
  838. "_testVariablesLookup",
  839. smalltalk.method({
  840. selector: "testVariablesLookup",
  841. fn: function (){
  842. var self=this;
  843. var src,ast;
  844. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  845. ast=_st(smalltalk)._parse_(src);
  846. _st(self["@analyzer"])._visit_(ast);
  847. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  848. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  849. _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());
  850. _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()));
  851. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast}, smalltalk.SemanticAnalyzerTest)})}
  852. }),
  853. smalltalk.SemanticAnalyzerTest);